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

Side by Side Diff: content/renderer/dom_storage/dom_storage_dispatcher.cc

Issue 22297005: Move webkit/{browser,common}/dom_storage into content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/dom_storage/dom_storage_dispatcher.h" 5 #include "content/renderer/dom_storage/dom_storage_dispatcher.h"
6 6
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 9
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "content/common/dom_storage_messages.h" 12 #include "content/common/dom_storage/dom_storage_messages.h"
13 #include "content/common/dom_storage/dom_storage_types.h"
13 #include "content/renderer/dom_storage/dom_storage_cached_area.h" 14 #include "content/renderer/dom_storage/dom_storage_cached_area.h"
14 #include "content/renderer/dom_storage/dom_storage_proxy.h" 15 #include "content/renderer/dom_storage/dom_storage_proxy.h"
15 #include "content/renderer/dom_storage/webstoragearea_impl.h" 16 #include "content/renderer/dom_storage/webstoragearea_impl.h"
16 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" 17 #include "content/renderer/dom_storage/webstoragenamespace_impl.h"
17 #include "content/renderer/render_thread_impl.h" 18 #include "content/renderer/render_thread_impl.h"
18 #include "third_party/WebKit/public/platform/Platform.h" 19 #include "third_party/WebKit/public/platform/Platform.h"
19 #include "third_party/WebKit/public/web/WebKit.h" 20 #include "third_party/WebKit/public/web/WebKit.h"
20 #include "third_party/WebKit/public/web/WebStorageEventDispatcher.h" 21 #include "third_party/WebKit/public/web/WebStorageEventDispatcher.h"
21 #include "webkit/common/dom_storage/dom_storage_types.h"
22
23 using dom_storage::ValuesMap;
24 22
25 namespace content { 23 namespace content {
26 24
27 namespace { 25 namespace {
28 // MessageThrottlingFilter ------------------------------------------- 26 // MessageThrottlingFilter -------------------------------------------
29 // Used to limit the number of ipc messages pending completion so we 27 // Used to limit the number of ipc messages pending completion so we
30 // don't overwhelm the main browser process. When the limit is reached, 28 // don't overwhelm the main browser process. When the limit is reached,
31 // a synchronous message is sent to flush all pending messages thru. 29 // a synchronous message is sent to flush all pending messages thru.
32 // We expect to receive an 'ack' for each message sent. This object 30 // We expect to receive an 'ack' for each message sent. This object
33 // observes receipt of the acks on the IPC thread to decrement a counter. 31 // observes receipt of the acks on the IPC thread to decrement a counter.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // Methods for use by DomStorageDispatcher directly. 100 // Methods for use by DomStorageDispatcher directly.
103 DomStorageCachedArea* OpenCachedArea( 101 DomStorageCachedArea* OpenCachedArea(
104 int64 namespace_id, const GURL& origin); 102 int64 namespace_id, const GURL& origin);
105 void CloseCachedArea(DomStorageCachedArea* area); 103 void CloseCachedArea(DomStorageCachedArea* area);
106 DomStorageCachedArea* LookupCachedArea( 104 DomStorageCachedArea* LookupCachedArea(
107 int64 namespace_id, const GURL& origin); 105 int64 namespace_id, const GURL& origin);
108 void CompleteOnePendingCallback(bool success); 106 void CompleteOnePendingCallback(bool success);
109 void Shutdown(); 107 void Shutdown();
110 108
111 // DomStorageProxy interface for use by DomStorageCachedArea. 109 // DomStorageProxy interface for use by DomStorageCachedArea.
112 virtual void LoadArea(int connection_id, ValuesMap* values, 110 virtual void LoadArea(int connection_id, DOMStorageValuesMap* values,
113 const CompletionCallback& callback) OVERRIDE; 111 const CompletionCallback& callback) OVERRIDE;
114 virtual void SetItem(int connection_id, const string16& key, 112 virtual void SetItem(int connection_id, const string16& key,
115 const string16& value, const GURL& page_url, 113 const string16& value, const GURL& page_url,
116 const CompletionCallback& callback) OVERRIDE; 114 const CompletionCallback& callback) OVERRIDE;
117 virtual void RemoveItem(int connection_id, const string16& key, 115 virtual void RemoveItem(int connection_id, const string16& key,
118 const GURL& page_url, 116 const GURL& page_url,
119 const CompletionCallback& callback) OVERRIDE; 117 const CompletionCallback& callback) OVERRIDE;
120 virtual void ClearArea(int connection_id, 118 virtual void ClearArea(int connection_id,
121 const GURL& page_url, 119 const GURL& page_url,
122 const CompletionCallback& callback) OVERRIDE; 120 const CompletionCallback& callback) OVERRIDE;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 214
217 void DomStorageDispatcher::ProxyImpl::Shutdown() { 215 void DomStorageDispatcher::ProxyImpl::Shutdown() {
218 throttling_filter_->Shutdown(); 216 throttling_filter_->Shutdown();
219 sender_->RemoveFilter(throttling_filter_.get()); 217 sender_->RemoveFilter(throttling_filter_.get());
220 sender_ = NULL; 218 sender_ = NULL;
221 cached_areas_.clear(); 219 cached_areas_.clear();
222 pending_callbacks_.clear(); 220 pending_callbacks_.clear();
223 } 221 }
224 222
225 void DomStorageDispatcher::ProxyImpl::LoadArea( 223 void DomStorageDispatcher::ProxyImpl::LoadArea(
226 int connection_id, ValuesMap* values, 224 int connection_id, DOMStorageValuesMap* values,
227 const CompletionCallback& callback) { 225 const CompletionCallback& callback) {
228 PushPendingCallback(callback); 226 PushPendingCallback(callback);
229 throttling_filter_->SendThrottled(new DOMStorageHostMsg_LoadStorageArea( 227 throttling_filter_->SendThrottled(new DOMStorageHostMsg_LoadStorageArea(
230 connection_id, values)); 228 connection_id, values));
231 } 229 }
232 230
233 void DomStorageDispatcher::ProxyImpl::SetItem( 231 void DomStorageDispatcher::ProxyImpl::SetItem(
234 int connection_id, const string16& key, 232 int connection_id, const string16& key,
235 const string16& value, const GURL& page_url, 233 const string16& value, const GURL& page_url,
236 const CompletionCallback& callback) { 234 const CompletionCallback& callback) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 if (originated_in_process) { 298 if (originated_in_process) {
301 originating_area = WebStorageAreaImpl::FromConnectionId( 299 originating_area = WebStorageAreaImpl::FromConnectionId(
302 params.connection_id); 300 params.connection_id);
303 } else { 301 } else {
304 DomStorageCachedArea* cached_area = proxy_->LookupCachedArea( 302 DomStorageCachedArea* cached_area = proxy_->LookupCachedArea(
305 params.namespace_id, params.origin); 303 params.namespace_id, params.origin);
306 if (cached_area) 304 if (cached_area)
307 cached_area->ApplyMutation(params.key, params.new_value); 305 cached_area->ApplyMutation(params.key, params.new_value);
308 } 306 }
309 307
310 if (params.namespace_id == dom_storage::kLocalStorageNamespaceId) { 308 if (params.namespace_id == kLocalStorageNamespaceId) {
311 WebKit::WebStorageEventDispatcher::dispatchLocalStorageEvent( 309 WebKit::WebStorageEventDispatcher::dispatchLocalStorageEvent(
312 params.key, 310 params.key,
313 params.old_value, 311 params.old_value,
314 params.new_value, 312 params.new_value,
315 params.origin, 313 params.origin,
316 params.page_url, 314 params.page_url,
317 originating_area, 315 originating_area,
318 originated_in_process); 316 originated_in_process);
319 } else { 317 } else {
320 WebStorageNamespaceImpl 318 WebStorageNamespaceImpl
321 session_namespace_for_event_dispatch(params.namespace_id); 319 session_namespace_for_event_dispatch(params.namespace_id);
322 WebKit::WebStorageEventDispatcher::dispatchSessionStorageEvent( 320 WebKit::WebStorageEventDispatcher::dispatchSessionStorageEvent(
323 params.key, 321 params.key,
324 params.old_value, 322 params.old_value,
325 params.new_value, 323 params.new_value,
326 params.origin, 324 params.origin,
327 params.page_url, 325 params.page_url,
328 session_namespace_for_event_dispatch, 326 session_namespace_for_event_dispatch,
329 originating_area, 327 originating_area,
330 originated_in_process); 328 originated_in_process);
331 } 329 }
332 } 330 }
333 331
334 void DomStorageDispatcher::OnAsyncOperationComplete(bool success) { 332 void DomStorageDispatcher::OnAsyncOperationComplete(bool success) {
335 proxy_->CompleteOnePendingCallback(success); 333 proxy_->CompleteOnePendingCallback(success);
336 } 334 }
337 335
338 } // namespace content 336 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698