Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ | 5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
| 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ | 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/hash_tables.h" | 9 #include "base/file_path.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/nullable_string16.h" | 11 #include "base/nullable_string16.h" |
| 13 #include "base/string16.h" | 12 #include "base/string16.h" |
| 14 #include "content/common/dom_storage_common.h" | |
| 15 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h" | 14 #include "webkit/dom_storage/dom_storage_task_runner.h" |
| 17 | 15 |
| 18 class DOMStorageNamespace; | 16 class FilePath; |
| 19 // Only use on the WebKit thread. DOMStorageNamespace manages our registration | 17 class GURL; |
| 20 // with DOMStorageContext. | 18 |
| 21 class DOMStorageArea { | 19 namespace dom_storage { |
| 20 | |
| 21 class DomStorageMap; | |
| 22 | |
| 23 // Not thread-safe, should only be called on the | |
| 24 // background thread. | |
|
benm (inactive)
2012/02/02 16:23:19
Can you add comments to these classes like those y
michaeln
2012/02/03 00:33:42
Done, added class with an overview on DomStorageCo
| |
| 25 class DomStorageArea | |
| 26 : public base::RefCountedThreadSafe<DomStorageArea> { | |
| 27 | |
| 22 public: | 28 public: |
| 23 DOMStorageArea(const string16& origin, | 29 DomStorageArea(int64 namespace_id, |
| 24 int64 id, | 30 const GURL& origin, |
| 25 DOMStorageNamespace* owner); | 31 const FilePath& backing_file, |
| 26 ~DOMStorageArea(); | 32 DomStorageTaskRunner* task_runner); |
| 33 | |
| 34 const GURL& origin() const { return origin_; } | |
| 35 const int64 namespace_id() const { return namespace_id_; } | |
| 27 | 36 |
| 28 unsigned Length(); | 37 unsigned Length(); |
| 29 NullableString16 Key(unsigned index); | 38 NullableString16 Key(unsigned index); |
| 30 NullableString16 GetItem(const string16& key); | 39 NullableString16 GetItem(const string16& key); |
| 31 NullableString16 SetItem( | 40 bool SetItem(const string16& key, const string16& value, |
| 32 const string16& key, const string16& value, | 41 NullableString16* old_value); |
| 33 WebKit::WebStorageArea::Result* result); | 42 bool RemoveItem(const string16& key, string16* old_value); |
| 34 NullableString16 RemoveItem(const string16& key); | |
| 35 bool Clear(); | 43 bool Clear(); |
| 36 void PurgeMemory(); | |
| 37 | 44 |
| 38 int64 id() const { return id_; } | 45 DomStorageArea* ShallowCopy(int64 destination_namespace_id); |
| 39 | |
| 40 DOMStorageNamespace* owner() const { return owner_; } | |
| 41 | 46 |
| 42 private: | 47 private: |
| 43 // Creates the underlying WebStorageArea on demand. | 48 friend class base::RefCountedThreadSafe<DomStorageArea>; |
| 44 void CreateWebStorageAreaIfNecessary(); | |
| 45 | 49 |
| 46 // The origin this storage area represents. | 50 ~DomStorageArea(); |
| 47 string16 origin_; | |
| 48 GURL origin_url_; | |
| 49 | 51 |
| 50 // The storage area we wrap. | 52 int64 namespace_id_; |
| 51 scoped_ptr<WebKit::WebStorageArea> storage_area_; | 53 GURL origin_; |
| 52 | 54 FilePath backing_file_; |
| 53 // Our storage area id. Unique to our parent WebKitContext. | 55 scoped_refptr<DomStorageTaskRunner> task_runner_; |
| 54 int64 id_; | 56 scoped_refptr<DomStorageMap> map_; |
|
benm (inactive)
2012/02/02 16:23:19
We're still planning on having a changed_values_ D
michaeln
2012/02/03 00:33:42
yes, but i think just need strictly owned ValuesMa
| |
| 55 | 57 // TODO(michaeln): make it so this class can persist stuff to disk |
|
benm (inactive)
2012/02/02 16:23:19
Should just need a DomStorageDatabase instance and
michaeln
2012/02/03 00:33:42
Right... i think a DomStorageMap.SwapValues(Values
| |
| 56 // The DOMStorageNamespace that owns us. | |
| 57 DOMStorageNamespace* owner_; | |
| 58 | |
| 59 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageArea); | |
| 60 }; | 58 }; |
| 61 | 59 |
| 62 #if defined(COMPILER_GCC) | 60 } // namespace dom_storage |
| 63 namespace __gnu_cxx { | |
| 64 | 61 |
| 65 template<> | 62 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
| 66 struct hash<DOMStorageArea*> { | |
| 67 std::size_t operator()(DOMStorageArea* const& p) const { | |
| 68 return reinterpret_cast<std::size_t>(p); | |
| 69 } | |
| 70 }; | |
| 71 | |
| 72 } // namespace __gnu_cxx | |
| 73 #endif | |
| 74 | |
| 75 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ | |
| OLD | NEW |