| 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_CONTEXT_H_ | 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ |
| 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ | 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // The local storage file extension. | 102 // The local storage file extension. |
| 103 static const FilePath::CharType kLocalStorageExtension[]; | 103 static const FilePath::CharType kLocalStorageExtension[]; |
| 104 | 104 |
| 105 // Get the file name of the local storage file for the given origin. | 105 // Get the file name of the local storage file for the given origin. |
| 106 FilePath GetLocalStorageFilePath(const string16& origin_id) const; | 106 FilePath GetLocalStorageFilePath(const string16& origin_id) const; |
| 107 | 107 |
| 108 void set_clear_local_state_on_exit_(bool clear_local_state) { | 108 void set_clear_local_state_on_exit_(bool clear_local_state) { |
| 109 clear_local_state_on_exit_ = clear_local_state; | 109 clear_local_state_on_exit_ = clear_local_state; |
| 110 } | 110 } |
| 111 | 111 |
| 112 // Disables the exit-time deletion for all data (also session-only data). |
| 113 void SaveSessionState() { |
| 114 save_session_state_ = true; |
| 115 } |
| 116 |
| 112 void set_data_path_for_testing(const FilePath& data_path) { | 117 void set_data_path_for_testing(const FilePath& data_path) { |
| 113 data_path_ = data_path; | 118 data_path_ = data_path; |
| 114 } | 119 } |
| 115 | 120 |
| 116 private: | 121 private: |
| 117 | 122 |
| 118 FRIEND_TEST_ALL_PREFIXES(DOMStorageTest, SessionOnly); | 123 FRIEND_TEST_ALL_PREFIXES(DOMStorageTest, SessionOnly); |
| 124 FRIEND_TEST_ALL_PREFIXES(DOMStorageTest, SaveSessionState); |
| 119 | 125 |
| 120 // Get the local storage instance. The object is owned by this class. | 126 // Get the local storage instance. The object is owned by this class. |
| 121 DOMStorageNamespace* CreateLocalStorage(); | 127 DOMStorageNamespace* CreateLocalStorage(); |
| 122 | 128 |
| 123 // Get a new session storage namespace. The object is owned by this class. | 129 // Get a new session storage namespace. The object is owned by this class. |
| 124 DOMStorageNamespace* CreateSessionStorage(int64 namespace_id); | 130 DOMStorageNamespace* CreateSessionStorage(int64 namespace_id); |
| 125 | 131 |
| 126 // Used internally to register storage namespaces we create. | 132 // Used internally to register storage namespaces we create. |
| 127 void RegisterStorageNamespace(DOMStorageNamespace* storage_namespace); | 133 void RegisterStorageNamespace(DOMStorageNamespace* storage_namespace); |
| 128 | 134 |
| 129 // The WebKit thread half of CloneSessionStorage above. Static because | 135 // The WebKit thread half of CloneSessionStorage above. Static because |
| 130 // DOMStorageContext isn't ref counted thus we can't use a runnable method. | 136 // DOMStorageContext isn't ref counted thus we can't use a runnable method. |
| 131 // That said, we know this is safe because this class is destroyed on the | 137 // That said, we know this is safe because this class is destroyed on the |
| 132 // WebKit thread, so there's no way it could be destroyed before this is run. | 138 // WebKit thread, so there's no way it could be destroyed before this is run. |
| 133 static void CompleteCloningSessionStorage(DOMStorageContext* context, | 139 static void CompleteCloningSessionStorage(DOMStorageContext* context, |
| 134 int64 existing_id, int64 clone_id); | 140 int64 existing_id, int64 clone_id); |
| 135 | 141 |
| 136 // The last used storage_area_id and storage_namespace_id's. For the storage | 142 // The last used storage_area_id and storage_namespace_id's. For the storage |
| 137 // namespaces, IDs allocated on the UI thread are positive and count up while | 143 // namespaces, IDs allocated on the UI thread are positive and count up while |
| 138 // IDs allocated on the IO thread are negative and count down. This allows us | 144 // IDs allocated on the IO thread are negative and count down. This allows us |
| 139 // to allocate unique IDs on both without any locking. All storage area ids | 145 // to allocate unique IDs on both without any locking. All storage area ids |
| 140 // are allocated on the WebKit thread. | 146 // are allocated on the WebKit thread. |
| 141 int64 last_storage_area_id_; | 147 int64 last_storage_area_id_; |
| 142 int64 last_session_storage_namespace_id_on_ui_thread_; | 148 int64 last_session_storage_namespace_id_on_ui_thread_; |
| 143 int64 last_session_storage_namespace_id_on_io_thread_; | 149 int64 last_session_storage_namespace_id_on_io_thread_; |
| 144 | 150 |
| 145 // True if the destructor should delete its files. | 151 // True if the destructor should delete its files. |
| 146 bool clear_local_state_on_exit_; | 152 bool clear_local_state_on_exit_; |
| 147 | 153 |
| 154 // If true, nothing (not even session-only data) should be deleted on exit. |
| 155 bool save_session_state_; |
| 156 |
| 148 // Path where the browser context data is stored. | 157 // Path where the browser context data is stored. |
| 149 // TODO(pastarmovj): Keep in mind that unlike indexed db data_path_ variable | 158 // TODO(pastarmovj): Keep in mind that unlike indexed db data_path_ variable |
| 150 // this one still has to point to the upper level dir because of the | 159 // this one still has to point to the upper level dir because of the |
| 151 // MigrateLocalStorageDirectory function. Once this function disappears we can | 160 // MigrateLocalStorageDirectory function. Once this function disappears we can |
| 152 // make it point directly to the dom storage path. | 161 // make it point directly to the dom storage path. |
| 153 FilePath data_path_; | 162 FilePath data_path_; |
| 154 | 163 |
| 155 // All the DOMStorageMessageFilters that are attached to us. ONLY USE ON THE | 164 // All the DOMStorageMessageFilters that are attached to us. ONLY USE ON THE |
| 156 // IO THREAD! | 165 // IO THREAD! |
| 157 MessageFilterSet message_filter_set_; | 166 MessageFilterSet message_filter_set_; |
| 158 | 167 |
| 159 // Maps ids to StorageAreas. We do NOT own these objects. StorageNamespace | 168 // Maps ids to StorageAreas. We do NOT own these objects. StorageNamespace |
| 160 // (which does own them) will notify us when we should remove the entries. | 169 // (which does own them) will notify us when we should remove the entries. |
| 161 typedef std::map<int64, DOMStorageArea*> StorageAreaMap; | 170 typedef std::map<int64, DOMStorageArea*> StorageAreaMap; |
| 162 StorageAreaMap storage_area_map_; | 171 StorageAreaMap storage_area_map_; |
| 163 | 172 |
| 164 // Maps ids to StorageNamespaces. We own these objects. | 173 // Maps ids to StorageNamespaces. We own these objects. |
| 165 typedef std::map<int64, DOMStorageNamespace*> StorageNamespaceMap; | 174 typedef std::map<int64, DOMStorageNamespace*> StorageNamespaceMap; |
| 166 StorageNamespaceMap storage_namespace_map_; | 175 StorageNamespaceMap storage_namespace_map_; |
| 167 | 176 |
| 168 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 177 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
| 169 | 178 |
| 170 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContext); | 179 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContext); |
| 171 }; | 180 }; |
| 172 | 181 |
| 173 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ | 182 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ |
| OLD | NEW |