| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_NAMESPACE_H_ | 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_NAMESPACE_H_ |
| 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_NAMESPACE_H_ | 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_NAMESPACE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // Only to be used on the WebKit thread. | 24 // Only to be used on the WebKit thread. |
| 25 class DOMStorageNamespace { | 25 class DOMStorageNamespace { |
| 26 public: | 26 public: |
| 27 static DOMStorageNamespace* CreateLocalStorageNamespace( | 27 static DOMStorageNamespace* CreateLocalStorageNamespace( |
| 28 DOMStorageContext* dom_storage_context, const FilePath& data_dir_path); | 28 DOMStorageContext* dom_storage_context, const FilePath& data_dir_path); |
| 29 static DOMStorageNamespace* CreateSessionStorageNamespace( | 29 static DOMStorageNamespace* CreateSessionStorageNamespace( |
| 30 DOMStorageContext* dom_storage_context, int64 namespace_id); | 30 DOMStorageContext* dom_storage_context, int64 namespace_id); |
| 31 | 31 |
| 32 ~DOMStorageNamespace(); | 32 ~DOMStorageNamespace(); |
| 33 | 33 |
| 34 DOMStorageArea* GetStorageArea(const string16& origin); | 34 DOMStorageArea* GetStorageArea(const string16& origin, |
| 35 bool enforce_session_only_storage); |
| 35 DOMStorageNamespace* Copy(int64 clone_namespace_id); | 36 DOMStorageNamespace* Copy(int64 clone_namespace_id); |
| 36 | 37 |
| 37 void PurgeMemory(); | 38 void PurgeMemory(); |
| 38 | 39 |
| 39 const DOMStorageContext* dom_storage_context() const { | 40 const DOMStorageContext* dom_storage_context() const { |
| 40 return dom_storage_context_; | 41 return dom_storage_context_; |
| 41 } | 42 } |
| 42 int64 id() const { return id_; } | 43 int64 id() const { return id_; } |
| 43 const WebKit::WebString& data_dir_path() const { return data_dir_path_; } | 44 const WebKit::WebString& data_dir_path() const { return data_dir_path_; } |
| 44 DOMStorageType dom_storage_type() const { return dom_storage_type_; } | 45 DOMStorageType dom_storage_type() const { return dom_storage_type_; } |
| 45 | 46 |
| 46 // Creates a WebStorageArea for the given origin. This should only be called | 47 // Creates a WebStorageArea for the given origin. This should only be called |
| 47 // by an owned DOMStorageArea. | 48 // by an owned DOMStorageArea. |
| 48 WebKit::WebStorageArea* CreateWebStorageArea(const string16& origin); | 49 WebKit::WebStorageArea* CreateWebStorageArea(const string16& origin); |
| 49 | 50 |
| 50 private: | 51 private: |
| 51 // Called by the static factory methods above. | 52 // Called by the static factory methods above. |
| 52 DOMStorageNamespace(DOMStorageContext* dom_storage_context, | 53 DOMStorageNamespace(DOMStorageContext* dom_storage_context, |
| 53 int64 id, | 54 int64 id, |
| 54 const WebKit::WebString& data_dir_path, | 55 const WebKit::WebString& data_dir_path, |
| 55 DOMStorageType storage_type); | 56 DOMStorageType storage_type); |
| 56 | 57 |
| 57 // Creates the underlying WebStorageNamespace on demand. | 58 // Creates the underlying WebStorageNamespace on demand. |
| 58 void CreateWebStorageNamespaceIfNecessary(); | 59 void CreateWebStorageNamespaceIfNecessary(); |
| 59 | 60 |
| 61 // Helpers for creating DOMStorageAreas. |
| 62 DOMStorageArea* GetExistingStorageArea(const string16& origin); |
| 63 DOMStorageArea* CreateStorageArea(const string16& origin); |
| 64 |
| 65 // Returns true if this DOMStorageNamespace represents localStorage and should |
| 66 // have a pointer to a session-only localStorage DOMStorageNamespace (which is |
| 67 // lazily created). Returns false if this DOMStorageNamespace is a |
| 68 // sessionStorage, or a session-only localStorage, or a localStorage |
| 69 // associated with an off the record profile. |
| 70 bool ShouldHaveSessionOnlyLocalStorage() const; |
| 71 |
| 72 // Lazy creation of the DOMStorageNamespace representing session-only |
| 73 // localStorage. |
| 74 void EnsureSessionOnlyLocalStorageCreated(); |
| 75 |
| 60 // All the storage areas we own. | 76 // All the storage areas we own. |
| 61 typedef base::hash_map<string16, DOMStorageArea*> OriginToStorageAreaMap; | 77 typedef base::hash_map<string16, DOMStorageArea*> OriginToStorageAreaMap; |
| 62 OriginToStorageAreaMap origin_to_storage_area_; | 78 OriginToStorageAreaMap origin_to_storage_area_; |
| 63 | 79 |
| 64 // The DOMStorageContext that owns us. | 80 // The DOMStorageContext that owns us. |
| 65 DOMStorageContext* dom_storage_context_; | 81 DOMStorageContext* dom_storage_context_; |
| 66 | 82 |
| 67 // The WebKit storage namespace we manage. | 83 // The WebKit storage namespace we manage. |
| 68 scoped_ptr<WebKit::WebStorageNamespace> storage_namespace_; | 84 scoped_ptr<WebKit::WebStorageNamespace> storage_namespace_; |
| 69 | 85 |
| 70 // Our id. Unique to our parent WebKitContext class. | 86 // Our id. Unique to our parent WebKitContext class. |
| 71 int64 id_; | 87 int64 id_; |
| 72 | 88 |
| 73 // The path used to create us, so we can recreate our WebStorageNamespace on | 89 // The path used to create us, so we can recreate our WebStorageNamespace on |
| 74 // demand. | 90 // demand. |
| 75 WebKit::WebString data_dir_path_; | 91 WebKit::WebString data_dir_path_; |
| 76 | 92 |
| 77 // SessionStorage vs. LocalStorage. | 93 // SessionStorage vs. LocalStorage. |
| 78 const DOMStorageType dom_storage_type_; | 94 const DOMStorageType dom_storage_type_; |
| 79 | 95 |
| 96 // Session-only version of the same localStorage (lazily created). |
| 97 scoped_ptr<DOMStorageNamespace> session_only_local_storage_; |
| 98 |
| 80 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageNamespace); | 99 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageNamespace); |
| 81 }; | 100 }; |
| 82 | 101 |
| 83 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_NAMESPACE_H_ | 102 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_NAMESPACE_H_ |
| OLD | NEW |