Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: chrome/browser/in_process_webkit/dom_storage_context.cc

Issue 5722003: Make DOMStorageDispatcherHost be a message filter (and rename it accordingly)... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: get rid of _DELAY_HANDLE macro Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/in_process_webkit/dom_storage_context.h" 5 #include "chrome/browser/in_process_webkit/dom_storage_context.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 DOMStorageContext::DOMStorageContext(WebKitContext* webkit_context) 66 DOMStorageContext::DOMStorageContext(WebKitContext* webkit_context)
67 : last_storage_area_id_(0), 67 : last_storage_area_id_(0),
68 last_session_storage_namespace_id_on_ui_thread_(kLocalStorageNamespaceId), 68 last_session_storage_namespace_id_on_ui_thread_(kLocalStorageNamespaceId),
69 last_session_storage_namespace_id_on_io_thread_(kLocalStorageNamespaceId), 69 last_session_storage_namespace_id_on_io_thread_(kLocalStorageNamespaceId),
70 clear_local_state_on_exit_(false) { 70 clear_local_state_on_exit_(false) {
71 data_path_ = webkit_context->data_path(); 71 data_path_ = webkit_context->data_path();
72 } 72 }
73 73
74 DOMStorageContext::~DOMStorageContext() { 74 DOMStorageContext::~DOMStorageContext() {
75 // This should not go away until all DOM Storage Dispatcher hosts have gone 75 // This should not go away until all DOM Storage message filters have gone
76 // away. And they remove themselves from this list. 76 // away. And they remove themselves from this list.
77 DCHECK(dispatcher_host_set_.empty()); 77 DCHECK(message_filter_set_.empty());
78 78
79 for (StorageNamespaceMap::iterator iter(storage_namespace_map_.begin()); 79 for (StorageNamespaceMap::iterator iter(storage_namespace_map_.begin());
80 iter != storage_namespace_map_.end(); ++iter) { 80 iter != storage_namespace_map_.end(); ++iter) {
81 delete iter->second; 81 delete iter->second;
82 } 82 }
83 83
84 // Not being on the WEBKIT thread here means we are running in a unit test 84 // Not being on the WEBKIT thread here means we are running in a unit test
85 // where no clean up is needed. 85 // where no clean up is needed.
86 if (clear_local_state_on_exit_ && 86 if (clear_local_state_on_exit_ &&
87 BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)) { 87 BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 StorageNamespaceMap::iterator iter = storage_namespace_map_.find(id); 150 StorageNamespaceMap::iterator iter = storage_namespace_map_.find(id);
151 if (iter != storage_namespace_map_.end()) 151 if (iter != storage_namespace_map_.end())
152 return iter->second; 152 return iter->second;
153 if (!allocation_allowed) 153 if (!allocation_allowed)
154 return NULL; 154 return NULL;
155 if (id == kLocalStorageNamespaceId) 155 if (id == kLocalStorageNamespaceId)
156 return CreateLocalStorage(); 156 return CreateLocalStorage();
157 return CreateSessionStorage(id); 157 return CreateSessionStorage(id);
158 } 158 }
159 159
160 void DOMStorageContext::RegisterDispatcherHost( 160 void DOMStorageContext::RegisterMessageFilter(
161 DOMStorageDispatcherHost* dispatcher_host) { 161 DOMStorageMessageFilter* message_filter) {
162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
163 DCHECK(dispatcher_host_set_.find(dispatcher_host) == 163 DCHECK(message_filter_set_.find(message_filter) ==
164 dispatcher_host_set_.end()); 164 message_filter_set_.end());
165 dispatcher_host_set_.insert(dispatcher_host); 165 message_filter_set_.insert(message_filter);
166 } 166 }
167 167
168 void DOMStorageContext::UnregisterDispatcherHost( 168 void DOMStorageContext::UnregisterMessageFilter(
169 DOMStorageDispatcherHost* dispatcher_host) { 169 DOMStorageMessageFilter* message_filter) {
170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
171 DCHECK(dispatcher_host_set_.find(dispatcher_host) != 171 DCHECK(message_filter_set_.find(message_filter) !=
172 dispatcher_host_set_.end()); 172 message_filter_set_.end());
173 dispatcher_host_set_.erase(dispatcher_host); 173 message_filter_set_.erase(message_filter);
174 } 174 }
175 175
176 const DOMStorageContext::DispatcherHostSet* 176 const DOMStorageContext::MessageFilterSet*
177 DOMStorageContext::GetDispatcherHostSet() const { 177 DOMStorageContext::GetMessageFilterSet() const {
178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
179 return &dispatcher_host_set_; 179 return &message_filter_set_;
180 } 180 }
181 181
182 void DOMStorageContext::PurgeMemory() { 182 void DOMStorageContext::PurgeMemory() {
183 // It is only safe to purge the memory from the LocalStorage namespace, 183 // It is only safe to purge the memory from the LocalStorage namespace,
184 // because it is backed by disk and can be reloaded later. If we purge a 184 // because it is backed by disk and can be reloaded later. If we purge a
185 // SessionStorage namespace, its data will be gone forever, because it isn't 185 // SessionStorage namespace, its data will be gone forever, because it isn't
186 // currently backed by disk. 186 // currently backed by disk.
187 DOMStorageNamespace* local_storage = 187 DOMStorageNamespace* local_storage =
188 GetStorageNamespace(kLocalStorageNamespaceId, false); 188 GetStorageNamespace(kLocalStorageNamespaceId, false);
189 if (local_storage) 189 if (local_storage)
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 296 }
297 297
298 FilePath DOMStorageContext::GetLocalStorageFilePath( 298 FilePath DOMStorageContext::GetLocalStorageFilePath(
299 const string16& origin_id) const { 299 const string16& origin_id) const {
300 FilePath storageDir = data_path_.Append( 300 FilePath storageDir = data_path_.Append(
301 DOMStorageContext::kLocalStorageDirectory); 301 DOMStorageContext::kLocalStorageDirectory);
302 FilePath::StringType id = 302 FilePath::StringType id =
303 webkit_glue::WebStringToFilePathString(origin_id); 303 webkit_glue::WebStringToFilePathString(origin_id);
304 return storageDir.Append(id.append(kLocalStorageExtension)); 304 return storageDir.Append(id.append(kLocalStorageExtension));
305 } 305 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698