OLD | NEW |
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" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 typedef std::map<std::string, CachedAreaHolder> CachedAreaMap; | 135 typedef std::map<std::string, CachedAreaHolder> CachedAreaMap; |
136 typedef std::list<CompletionCallback> CallbackList; | 136 typedef std::list<CompletionCallback> CallbackList; |
137 | 137 |
138 virtual ~ProxyImpl() { | 138 virtual ~ProxyImpl() { |
139 } | 139 } |
140 | 140 |
141 // Sudden termination is disabled when there are callbacks pending | 141 // Sudden termination is disabled when there are callbacks pending |
142 // to more reliably commit changes during shutdown. | 142 // to more reliably commit changes during shutdown. |
143 void PushPendingCallback(const CompletionCallback& callback) { | 143 void PushPendingCallback(const CompletionCallback& callback) { |
144 if (pending_callbacks_.empty()) | 144 if (pending_callbacks_.empty()) |
145 WebKit::Platform::current()->suddenTerminationChanged(false); | 145 blink::Platform::current()->suddenTerminationChanged(false); |
146 pending_callbacks_.push_back(callback); | 146 pending_callbacks_.push_back(callback); |
147 } | 147 } |
148 | 148 |
149 CompletionCallback PopPendingCallback() { | 149 CompletionCallback PopPendingCallback() { |
150 CompletionCallback callback = pending_callbacks_.front(); | 150 CompletionCallback callback = pending_callbacks_.front(); |
151 pending_callbacks_.pop_front(); | 151 pending_callbacks_.pop_front(); |
152 if (pending_callbacks_.empty()) | 152 if (pending_callbacks_.empty()) |
153 WebKit::Platform::current()->suddenTerminationChanged(true); | 153 blink::Platform::current()->suddenTerminationChanged(true); |
154 return callback; | 154 return callback; |
155 } | 155 } |
156 | 156 |
157 std::string GetCachedAreaKey(int64 namespace_id, const GURL& origin) { | 157 std::string GetCachedAreaKey(int64 namespace_id, const GURL& origin) { |
158 return base::Int64ToString(namespace_id) + origin.spec(); | 158 return base::Int64ToString(namespace_id) + origin.spec(); |
159 } | 159 } |
160 | 160 |
161 CachedAreaHolder* GetAreaHolder(const std::string& key) { | 161 CachedAreaHolder* GetAreaHolder(const std::string& key) { |
162 CachedAreaMap::iterator found = cached_areas_.find(key); | 162 CachedAreaMap::iterator found = cached_areas_.find(key); |
163 if (found == cached_areas_.end()) | 163 if (found == cached_areas_.end()) |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 originating_area = WebStorageAreaImpl::FromConnectionId( | 309 originating_area = WebStorageAreaImpl::FromConnectionId( |
310 params.connection_id); | 310 params.connection_id); |
311 } else { | 311 } else { |
312 DOMStorageCachedArea* cached_area = proxy_->LookupCachedArea( | 312 DOMStorageCachedArea* cached_area = proxy_->LookupCachedArea( |
313 params.namespace_id, params.origin); | 313 params.namespace_id, params.origin); |
314 if (cached_area) | 314 if (cached_area) |
315 cached_area->ApplyMutation(params.key, params.new_value); | 315 cached_area->ApplyMutation(params.key, params.new_value); |
316 } | 316 } |
317 | 317 |
318 if (params.namespace_id == kLocalStorageNamespaceId) { | 318 if (params.namespace_id == kLocalStorageNamespaceId) { |
319 WebKit::WebStorageEventDispatcher::dispatchLocalStorageEvent( | 319 blink::WebStorageEventDispatcher::dispatchLocalStorageEvent( |
320 params.key, | 320 params.key, |
321 params.old_value, | 321 params.old_value, |
322 params.new_value, | 322 params.new_value, |
323 params.origin, | 323 params.origin, |
324 params.page_url, | 324 params.page_url, |
325 originating_area, | 325 originating_area, |
326 originated_in_process); | 326 originated_in_process); |
327 } else { | 327 } else { |
328 WebStorageNamespaceImpl | 328 WebStorageNamespaceImpl |
329 session_namespace_for_event_dispatch(params.namespace_id); | 329 session_namespace_for_event_dispatch(params.namespace_id); |
330 WebKit::WebStorageEventDispatcher::dispatchSessionStorageEvent( | 330 blink::WebStorageEventDispatcher::dispatchSessionStorageEvent( |
331 params.key, | 331 params.key, |
332 params.old_value, | 332 params.old_value, |
333 params.new_value, | 333 params.new_value, |
334 params.origin, | 334 params.origin, |
335 params.page_url, | 335 params.page_url, |
336 session_namespace_for_event_dispatch, | 336 session_namespace_for_event_dispatch, |
337 originating_area, | 337 originating_area, |
338 originated_in_process); | 338 originated_in_process); |
339 } | 339 } |
340 } | 340 } |
341 | 341 |
342 void DomStorageDispatcher::OnAsyncOperationComplete(bool success) { | 342 void DomStorageDispatcher::OnAsyncOperationComplete(bool success) { |
343 proxy_->CompleteOnePendingCallback(success); | 343 proxy_->CompleteOnePendingCallback(success); |
344 } | 344 } |
345 | 345 |
346 } // namespace content | 346 } // namespace content |
OLD | NEW |