| Index: webkit/dom_storage/dom_storage_area.h
|
| ===================================================================
|
| --- webkit/dom_storage/dom_storage_area.h (revision 0)
|
| +++ webkit/dom_storage/dom_storage_area.h (working copy)
|
| @@ -1,75 +1,65 @@
|
| -// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2012 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.
|
|
|
| -#ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_
|
| -#define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_
|
| +#ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_
|
| +#define WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_
|
| #pragma once
|
|
|
| -#include "base/hash_tables.h"
|
| +#include "base/file_path.h"
|
| #include "base/memory/ref_counted.h"
|
| -#include "base/memory/scoped_ptr.h"
|
| #include "base/nullable_string16.h"
|
| #include "base/string16.h"
|
| -#include "content/common/dom_storage_common.h"
|
| #include "googleurl/src/gurl.h"
|
| -#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h"
|
| +#include "webkit/dom_storage/dom_storage_task_runner.h"
|
|
|
| -class DOMStorageNamespace;
|
| -// Only use on the WebKit thread. DOMStorageNamespace manages our registration
|
| -// with DOMStorageContext.
|
| -class DOMStorageArea {
|
| +class FilePath;
|
| +class GURL;
|
| +
|
| +namespace dom_storage {
|
| +
|
| +class DomStorageMap;
|
| +
|
| +// Container for a per-origin Map of key/value pairs potentially
|
| +// backed by storage on disk and lazily commits changes to disk.
|
| +// See class comments for DomStorageContext for a larger overview.
|
| +class DomStorageArea
|
| + : public base::RefCountedThreadSafe<DomStorageArea> {
|
| +
|
| public:
|
| - DOMStorageArea(const string16& origin,
|
| - int64 id,
|
| - DOMStorageNamespace* owner);
|
| - ~DOMStorageArea();
|
| + DomStorageArea(int64 namespace_id,
|
| + const GURL& origin,
|
| + const FilePath& directory,
|
| + DomStorageTaskRunner* task_runner);
|
|
|
| + const GURL& origin() const { return origin_; }
|
| + int64 namespace_id() const { return namespace_id_; }
|
| +
|
| unsigned Length();
|
| NullableString16 Key(unsigned index);
|
| NullableString16 GetItem(const string16& key);
|
| - NullableString16 SetItem(
|
| - const string16& key, const string16& value,
|
| - WebKit::WebStorageArea::Result* result);
|
| - NullableString16 RemoveItem(const string16& key);
|
| + bool SetItem(const string16& key, const string16& value,
|
| + NullableString16* old_value);
|
| + bool RemoveItem(const string16& key, string16* old_value);
|
| bool Clear();
|
| - void PurgeMemory();
|
|
|
| - int64 id() const { return id_; }
|
| + DomStorageArea* ShallowCopy(int64 destination_namespace_id);
|
|
|
| - DOMStorageNamespace* owner() const { return owner_; }
|
| -
|
| private:
|
| - // Creates the underlying WebStorageArea on demand.
|
| - void CreateWebStorageAreaIfNecessary();
|
| + FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, DomStorageAreaBasics);
|
| + friend class base::RefCountedThreadSafe<DomStorageArea>;
|
|
|
| - // The origin this storage area represents.
|
| - string16 origin_;
|
| - GURL origin_url_;
|
| + ~DomStorageArea();
|
|
|
| - // The storage area we wrap.
|
| - scoped_ptr<WebKit::WebStorageArea> storage_area_;
|
| -
|
| - // Our storage area id. Unique to our parent WebKitContext.
|
| - int64 id_;
|
| -
|
| - // The DOMStorageNamespace that owns us.
|
| - DOMStorageNamespace* owner_;
|
| -
|
| - DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageArea);
|
| + int64 namespace_id_;
|
| + GURL origin_;
|
| + FilePath directory_;
|
| + scoped_refptr<DomStorageTaskRunner> task_runner_;
|
| + scoped_refptr<DomStorageMap> map_;
|
| + // TODO(benm): integrate with DomStorageDatabase to read from
|
| + // and lazily write to disk.
|
| };
|
|
|
| -#if defined(COMPILER_GCC)
|
| -namespace __gnu_cxx {
|
| +} // namespace dom_storage
|
|
|
| -template<>
|
| -struct hash<DOMStorageArea*> {
|
| - std::size_t operator()(DOMStorageArea* const& p) const {
|
| - return reinterpret_cast<std::size_t>(p);
|
| - }
|
| -};
|
| -
|
| -} // namespace __gnu_cxx
|
| -#endif
|
| -
|
| -#endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_
|
| +#endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_
|
|
|