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> |
11 | 11 |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 | 16 |
17 class DOMStorageArea; | 17 class DOMStorageArea; |
18 class DOMStorageMessageFilter; | 18 class DOMStorageMessageFilter; |
19 class DOMStorageNamespace; | 19 class DOMStorageNamespace; |
20 class WebKitContext; | 20 class WebKitContext; |
21 | 21 |
22 namespace quota { | 22 namespace quota { |
23 class SpecialStoragePolicy; | 23 class SpecialStoragePolicy; |
24 } | 24 } |
25 | 25 |
26 // This is owned by WebKitContext and is all the dom storage information that's | 26 // This is owned by WebKitContext and is all the dom storage information that's |
27 // shared by all the DOMStorageMessageFilters that share the same profile. The | 27 // shared by all the DOMStorageMessageFilters that share the same browser |
28 // specifics of responsibilities are fairly well documented here and in | 28 // context. The specifics of responsibilities are fairly well documented here |
29 // StorageNamespace and StorageArea. Everything is only to be accessed on the | 29 // and in StorageNamespace and StorageArea. Everything is only to be accessed |
30 // WebKit thread unless noted otherwise. | 30 // on the WebKit thread unless noted otherwise. |
31 // | 31 // |
32 // NOTE: Virtual methods facilitate mocking functions for testing. | 32 // NOTE: Virtual methods facilitate mocking functions for testing. |
33 class DOMStorageContext { | 33 class DOMStorageContext { |
34 public: | 34 public: |
35 DOMStorageContext(WebKitContext* webkit_context, | 35 DOMStorageContext(WebKitContext* webkit_context, |
36 quota::SpecialStoragePolicy* special_storage_policy); | 36 quota::SpecialStoragePolicy* special_storage_policy); |
37 virtual ~DOMStorageContext(); | 37 virtual ~DOMStorageContext(); |
38 | 38 |
39 // Invalid storage id. No storage session will ever report this value. | 39 // Invalid storage id. No storage session will ever report this value. |
40 // Used in DOMStorageMessageFilter::OnStorageAreaId when coping with | 40 // Used in DOMStorageMessageFilter::OnStorageAreaId when coping with |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // IDs allocated on the IO thread are negative and count down. This allows us | 129 // IDs allocated on the IO thread are negative and count down. This allows us |
130 // to allocate unique IDs on both without any locking. All storage area ids | 130 // to allocate unique IDs on both without any locking. All storage area ids |
131 // are allocated on the WebKit thread. | 131 // are allocated on the WebKit thread. |
132 int64 last_storage_area_id_; | 132 int64 last_storage_area_id_; |
133 int64 last_session_storage_namespace_id_on_ui_thread_; | 133 int64 last_session_storage_namespace_id_on_ui_thread_; |
134 int64 last_session_storage_namespace_id_on_io_thread_; | 134 int64 last_session_storage_namespace_id_on_io_thread_; |
135 | 135 |
136 // True if the destructor should delete its files. | 136 // True if the destructor should delete its files. |
137 bool clear_local_state_on_exit_; | 137 bool clear_local_state_on_exit_; |
138 | 138 |
139 // Path where the profile data is stored. | 139 // Path where the browser context data is stored. |
140 // TODO(pastarmovj): Keep in mind that unlike indexed db data_path_ variable | 140 // TODO(pastarmovj): Keep in mind that unlike indexed db data_path_ variable |
141 // this one still has to point to the upper level dir because of the | 141 // this one still has to point to the upper level dir because of the |
142 // MigrateLocalStorageDirectory function. Once this function disappears we can | 142 // MigrateLocalStorageDirectory function. Once this function disappears we can |
143 // make it point directly to the dom storage path. | 143 // make it point directly to the dom storage path. |
144 FilePath data_path_; | 144 FilePath data_path_; |
145 | 145 |
146 // All the DOMStorageMessageFilters that are attached to us. ONLY USE ON THE | 146 // All the DOMStorageMessageFilters that are attached to us. ONLY USE ON THE |
147 // IO THREAD! | 147 // IO THREAD! |
148 MessageFilterSet message_filter_set_; | 148 MessageFilterSet message_filter_set_; |
149 | 149 |
150 // Maps ids to StorageAreas. We do NOT own these objects. StorageNamespace | 150 // Maps ids to StorageAreas. We do NOT own these objects. StorageNamespace |
151 // (which does own them) will notify us when we should remove the entries. | 151 // (which does own them) will notify us when we should remove the entries. |
152 typedef std::map<int64, DOMStorageArea*> StorageAreaMap; | 152 typedef std::map<int64, DOMStorageArea*> StorageAreaMap; |
153 StorageAreaMap storage_area_map_; | 153 StorageAreaMap storage_area_map_; |
154 | 154 |
155 // Maps ids to StorageNamespaces. We own these objects. | 155 // Maps ids to StorageNamespaces. We own these objects. |
156 typedef std::map<int64, DOMStorageNamespace*> StorageNamespaceMap; | 156 typedef std::map<int64, DOMStorageNamespace*> StorageNamespaceMap; |
157 StorageNamespaceMap storage_namespace_map_; | 157 StorageNamespaceMap storage_namespace_map_; |
158 | 158 |
159 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 159 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
160 | 160 |
161 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContext); | 161 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContext); |
162 }; | 162 }; |
163 | 163 |
164 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ | 164 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ |
OLD | NEW |