Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ |
| 6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ | 6 #define CHROME_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/string16.h" | 13 #include "base/string16.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 | 15 |
| 16 class DOMStorageArea; | 16 class DOMStorageArea; |
| 17 class DOMStorageDispatcherHost; | 17 class DOMStorageMessageFilter; |
| 18 class DOMStorageNamespace; | 18 class DOMStorageNamespace; |
| 19 class WebKitContext; | 19 class WebKitContext; |
| 20 | 20 |
| 21 // This is owned by WebKitContext and is all the dom storage information that's | 21 // This is owned by WebKitContext and is all the dom storage information that's |
| 22 // shared by all the ResourceMessageFilter/DOMStorageDispatcherHosts that share | 22 // shared by all the DOMStorageMessageFilterss that share the same profile. The |
|
jorlow
2010/12/13 10:36:15
no 2 s's.
| |
| 23 // the same profile. The specifics of responsibilities are fairly well | 23 // specifics of responsibilities are fairly well documented here and in |
| 24 // documented here and in StorageNamespace and StorageArea. Everything is only | 24 // StorageNamespace and StorageArea. Everything is only to be accessed on the |
| 25 // to be accessed on the WebKit thread unless noted otherwise. | 25 // WebKit thread unless noted otherwise. |
| 26 // | 26 // |
| 27 // NOTE: Virtual methods facilitate mocking functions for testing. | 27 // NOTE: Virtual methods facilitate mocking functions for testing. |
| 28 class DOMStorageContext { | 28 class DOMStorageContext { |
| 29 public: | 29 public: |
| 30 explicit DOMStorageContext(WebKitContext* webkit_context); | 30 explicit DOMStorageContext(WebKitContext* webkit_context); |
| 31 virtual ~DOMStorageContext(); | 31 virtual ~DOMStorageContext(); |
| 32 | 32 |
| 33 // Allocate a new storage area id. Only call on the WebKit thread. | 33 // Allocate a new storage area id. Only call on the WebKit thread. |
| 34 int64 AllocateStorageAreaId(); | 34 int64 AllocateStorageAreaId(); |
| 35 | 35 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 47 DOMStorageArea* GetStorageArea(int64 id); | 47 DOMStorageArea* GetStorageArea(int64 id); |
| 48 | 48 |
| 49 // Called on WebKit thread when a session storage namespace can be deleted. | 49 // Called on WebKit thread when a session storage namespace can be deleted. |
| 50 void DeleteSessionStorageNamespace(int64 namespace_id); | 50 void DeleteSessionStorageNamespace(int64 namespace_id); |
| 51 | 51 |
| 52 // Get a namespace from an id. What's returned is owned by this class. If | 52 // Get a namespace from an id. What's returned is owned by this class. If |
| 53 // allocation_allowed is true, then this function will create the storage | 53 // allocation_allowed is true, then this function will create the storage |
| 54 // namespace if it hasn't been already. | 54 // namespace if it hasn't been already. |
| 55 DOMStorageNamespace* GetStorageNamespace(int64 id, bool allocation_allowed); | 55 DOMStorageNamespace* GetStorageNamespace(int64 id, bool allocation_allowed); |
| 56 | 56 |
| 57 // Sometimes an event from one DOM storage dispatcher host requires | 57 // Sometimes an event from one DOM storage message filter requires |
| 58 // communication to all of them. | 58 // communication to all of them. |
| 59 typedef std::set<DOMStorageDispatcherHost*> DispatcherHostSet; | 59 typedef std::set<DOMStorageMessageFilter*> MessageFilterSet; |
| 60 void RegisterDispatcherHost(DOMStorageDispatcherHost* dispatcher_host); | 60 void RegisterMessageFilter(DOMStorageMessageFilter* message_filter); |
| 61 void UnregisterDispatcherHost(DOMStorageDispatcherHost* dispatcher_host); | 61 void UnregisterMessageFilter(DOMStorageMessageFilter* MessageFilter); |
| 62 const DispatcherHostSet* GetDispatcherHostSet() const; | 62 const MessageFilterSet* GetMessageFilterSet() const; |
| 63 | 63 |
| 64 // Tells storage namespaces to purge any memory they do not need. | 64 // Tells storage namespaces to purge any memory they do not need. |
| 65 virtual void PurgeMemory(); | 65 virtual void PurgeMemory(); |
| 66 | 66 |
| 67 // Delete any local storage files that have been touched since the cutoff | 67 // Delete any local storage files that have been touched since the cutoff |
| 68 // date that's supplied. | 68 // date that's supplied. |
| 69 void DeleteDataModifiedSince(const base::Time& cutoff, | 69 void DeleteDataModifiedSince(const base::Time& cutoff, |
| 70 const char* url_scheme_to_be_skipped, | 70 const char* url_scheme_to_be_skipped, |
| 71 const std::vector<string16>& protected_origins); | 71 const std::vector<string16>& protected_origins); |
| 72 | 72 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 // True if the destructor should delete its files. | 126 // True if the destructor should delete its files. |
| 127 bool clear_local_state_on_exit_; | 127 bool clear_local_state_on_exit_; |
| 128 | 128 |
| 129 // Path where the profile data is stored. | 129 // Path where the profile data is stored. |
| 130 // TODO(pastarmovj): Keep in mind that unlike indexed db data_path_ variable | 130 // TODO(pastarmovj): Keep in mind that unlike indexed db data_path_ variable |
| 131 // this one still has to point to the upper level dir because of the | 131 // this one still has to point to the upper level dir because of the |
| 132 // MigrateLocalStorageDirectory function. Once this function disappears we can | 132 // MigrateLocalStorageDirectory function. Once this function disappears we can |
| 133 // make it point directly to the dom storage path. | 133 // make it point directly to the dom storage path. |
| 134 FilePath data_path_; | 134 FilePath data_path_; |
| 135 | 135 |
| 136 // All the DOMStorageDispatcherHosts that are attached to us. ONLY USE ON THE | 136 // All the DOMStorageMessageFilters that are attached to us. ONLY USE ON THE |
| 137 // IO THREAD! | 137 // IO THREAD! |
| 138 DispatcherHostSet dispatcher_host_set_; | 138 MessageFilterSet message_filter_set_; |
| 139 | 139 |
| 140 // Maps ids to StorageAreas. We do NOT own these objects. StorageNamespace | 140 // Maps ids to StorageAreas. We do NOT own these objects. StorageNamespace |
| 141 // (which does own them) will notify us when we should remove the entries. | 141 // (which does own them) will notify us when we should remove the entries. |
| 142 typedef std::map<int64, DOMStorageArea*> StorageAreaMap; | 142 typedef std::map<int64, DOMStorageArea*> StorageAreaMap; |
| 143 StorageAreaMap storage_area_map_; | 143 StorageAreaMap storage_area_map_; |
| 144 | 144 |
| 145 // Maps ids to StorageNamespaces. We own these objects. | 145 // Maps ids to StorageNamespaces. We own these objects. |
| 146 typedef std::map<int64, DOMStorageNamespace*> StorageNamespaceMap; | 146 typedef std::map<int64, DOMStorageNamespace*> StorageNamespaceMap; |
| 147 StorageNamespaceMap storage_namespace_map_; | 147 StorageNamespaceMap storage_namespace_map_; |
| 148 | 148 |
| 149 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContext); | 149 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContext); |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ | 152 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ |
| OLD | NEW |