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" | |
| 10 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/nullable_string16.h" | 10 #include "base/nullable_string16.h" |
| 13 #include "base/string16.h" | 11 #include "base/string16.h" |
| 14 #include "content/common/dom_storage_common.h" | |
| 15 #include "googleurl/src/gurl.h" | |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h" | |
| 17 | 12 |
| 18 class DOMStorageNamespace; | 13 class FilePath; |
| 19 // Only use on the WebKit thread. DOMStorageNamespace manages our registration | 14 class GURL; |
| 20 // with DOMStorageContext. | 15 |
| 21 class DOMStorageArea { | 16 namespace dom_storage { |
| 17 | |
| 18 // Not thread-safe, should only be called on the | |
| 19 // background thread. | |
| 20 class DOMStorageArea | |
| 21 : public base::RefCounted<DOMStorageArea> { | |
| 22 | |
| 22 public: | 23 public: |
| 23 DOMStorageArea(const string16& origin, | 24 DOMStorageArea(const GURL& origin, |
| 24 int64 id, | 25 const FilePath& backing_file); |
|
benm (inactive)
2012/01/25 18:46:59
I was thinking this would be the path where the ba
| |
| 25 DOMStorageNamespace* owner); | |
| 26 ~DOMStorageArea(); | |
| 27 | 26 |
| 28 unsigned Length(); | 27 int Length(); |
|
benm (inactive)
2012/01/25 18:46:59
why int and not unsigned?
| |
| 29 NullableString16 Key(unsigned index); | 28 NullableString16 Key(int index); |
| 30 NullableString16 GetItem(const string16& key); | 29 NullableString16 GetItem(const string16& key); |
| 31 NullableString16 SetItem( | 30 bool SetItem( |
| 32 const string16& key, const string16& value, | 31 const string16& key, const string16& value, |
| 33 WebKit::WebStorageArea::Result* result); | 32 NullableString16* old_value); |
| 34 NullableString16 RemoveItem(const string16& key); | 33 bool RemoveItem( |
| 34 const string16& key, | |
| 35 NullableString16* old_value); | |
| 35 bool Clear(); | 36 bool Clear(); |
| 37 | |
| 36 void PurgeMemory(); | 38 void PurgeMemory(); |
| 37 | 39 |
| 38 int64 id() const { return id_; } | 40 private: |
| 41 friend class base::RefCounted<DOMStorageArea>; | |
| 39 | 42 |
| 40 DOMStorageNamespace* owner() const { return owner_; } | 43 ~DOMStorageArea(); |
| 41 | |
| 42 private: | |
| 43 // Creates the underlying WebStorageArea on demand. | |
| 44 void CreateWebStorageAreaIfNecessary(); | |
| 45 | |
| 46 // The origin this storage area represents. | |
| 47 string16 origin_; | |
| 48 GURL origin_url_; | |
| 49 | |
| 50 // The storage area we wrap. | |
| 51 scoped_ptr<WebKit::WebStorageArea> storage_area_; | |
| 52 | |
| 53 // Our storage area id. Unique to our parent WebKitContext. | |
| 54 int64 id_; | |
| 55 | |
| 56 // The DOMStorageNamespace that owns us. | |
| 57 DOMStorageNamespace* owner_; | |
| 58 | |
| 59 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageArea); | |
| 60 }; | 44 }; |
| 61 | 45 |
| 62 #if defined(COMPILER_GCC) | 46 } // namespace dom_storage |
| 63 namespace __gnu_cxx { | |
| 64 | 47 |
| 65 template<> | 48 #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 |