blob: 01ed6f22673bb26234c35aa087accaabababf61d [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "content/renderer/dom_storage/local_storage_cached_area.h"
#include "third_party/blink/public/platform/web_storage_area.h"
namespace content {
// There could be n instances of this class for the same origin in a renderer
// process. It delegates to the one LocalStorageCachedArea instance in a process
// for a given origin.
class LocalStorageArea : public blink::WebStorageArea {
explicit LocalStorageArea(scoped_refptr<LocalStorageCachedArea> cached_area);
~LocalStorageArea() override;
// blink::WebStorageArea:
unsigned length() override;
blink::WebString Key(unsigned index, bool* did_decrease_iterator) override;
blink::WebString GetItem(const blink::WebString& key) override;
void SetItem(const blink::WebString& key,
const blink::WebString& value,
const blink::WebURL& page_url,
WebStorageArea::Result& result) override;
void RemoveItem(const blink::WebString& key,
const blink::WebURL& page_url) override;
void Clear(const blink::WebURL& url) override;
const std::string& id() const { return id_; }
scoped_refptr<LocalStorageCachedArea> cached_area_;
// A globally unique identifier for this storage area. It's used to pass the
// source storage area, if any, in mutation events.
std::string id_;
} // namespace content