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

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

Issue 1547073003: Switch to standard integer types in content/renderer/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
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"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 // ProxyImpl ----------------------------------------------------- 93 // ProxyImpl -----------------------------------------------------
94 // An implementation of the DOMStorageProxy interface in terms of IPC. 94 // An implementation of the DOMStorageProxy interface in terms of IPC.
95 // This class also manages the collection of cached areas and pending 95 // This class also manages the collection of cached areas and pending
96 // operations awaiting completion callbacks. 96 // operations awaiting completion callbacks.
97 class DomStorageDispatcher::ProxyImpl : public DOMStorageProxy { 97 class DomStorageDispatcher::ProxyImpl : public DOMStorageProxy {
98 public: 98 public:
99 explicit ProxyImpl(RenderThreadImpl* sender); 99 explicit ProxyImpl(RenderThreadImpl* sender);
100 100
101 // Methods for use by DomStorageDispatcher directly. 101 // Methods for use by DomStorageDispatcher directly.
102 DOMStorageCachedArea* OpenCachedArea( 102 DOMStorageCachedArea* OpenCachedArea(int64_t namespace_id,
103 int64 namespace_id, const GURL& origin); 103 const GURL& origin);
104 void CloseCachedArea(DOMStorageCachedArea* area); 104 void CloseCachedArea(DOMStorageCachedArea* area);
105 DOMStorageCachedArea* LookupCachedArea( 105 DOMStorageCachedArea* LookupCachedArea(int64_t namespace_id,
106 int64 namespace_id, const GURL& origin); 106 const GURL& origin);
107 void CompleteOnePendingCallback(bool success); 107 void CompleteOnePendingCallback(bool success);
108 void Shutdown(); 108 void Shutdown();
109 109
110 // DOMStorageProxy interface for use by DOMStorageCachedArea. 110 // DOMStorageProxy interface for use by DOMStorageCachedArea.
111 void LoadArea(int connection_id, 111 void LoadArea(int connection_id,
112 DOMStorageValuesMap* values, 112 DOMStorageValuesMap* values,
113 const CompletionCallback& callback) override; 113 const CompletionCallback& callback) override;
114 void SetItem(int connection_id, 114 void SetItem(int connection_id,
115 const base::string16& key, 115 const base::string16& key,
116 const base::string16& value, 116 const base::string16& value,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 149
150 CompletionCallback PopPendingCallback() { 150 CompletionCallback PopPendingCallback() {
151 CompletionCallback callback = pending_callbacks_.front(); 151 CompletionCallback callback = pending_callbacks_.front();
152 pending_callbacks_.pop_front(); 152 pending_callbacks_.pop_front();
153 if (pending_callbacks_.empty()) 153 if (pending_callbacks_.empty())
154 blink::Platform::current()->suddenTerminationChanged(true); 154 blink::Platform::current()->suddenTerminationChanged(true);
155 return callback; 155 return callback;
156 } 156 }
157 157
158 std::string GetCachedAreaKey(int64 namespace_id, const GURL& origin) { 158 std::string GetCachedAreaKey(int64_t namespace_id, const GURL& origin) {
159 return base::Int64ToString(namespace_id) + origin.spec(); 159 return base::Int64ToString(namespace_id) + origin.spec();
160 } 160 }
161 161
162 CachedAreaHolder* GetAreaHolder(const std::string& key) { 162 CachedAreaHolder* GetAreaHolder(const std::string& key) {
163 CachedAreaMap::iterator found = cached_areas_.find(key); 163 CachedAreaMap::iterator found = cached_areas_.find(key);
164 if (found == cached_areas_.end()) 164 if (found == cached_areas_.end())
165 return NULL; 165 return NULL;
166 return &(found->second); 166 return &(found->second);
167 } 167 }
168 168
169 RenderThreadImpl* sender_; 169 RenderThreadImpl* sender_;
170 CachedAreaMap cached_areas_; 170 CachedAreaMap cached_areas_;
171 CallbackList pending_callbacks_; 171 CallbackList pending_callbacks_;
172 scoped_refptr<MessageThrottlingFilter> throttling_filter_; 172 scoped_refptr<MessageThrottlingFilter> throttling_filter_;
173 }; 173 };
174 174
175 DomStorageDispatcher::ProxyImpl::ProxyImpl(RenderThreadImpl* sender) 175 DomStorageDispatcher::ProxyImpl::ProxyImpl(RenderThreadImpl* sender)
176 : sender_(sender), 176 : sender_(sender),
177 throttling_filter_(new MessageThrottlingFilter(sender)) { 177 throttling_filter_(new MessageThrottlingFilter(sender)) {
178 sender_->AddFilter(throttling_filter_.get()); 178 sender_->AddFilter(throttling_filter_.get());
179 } 179 }
180 180
181 DOMStorageCachedArea* DomStorageDispatcher::ProxyImpl::OpenCachedArea( 181 DOMStorageCachedArea* DomStorageDispatcher::ProxyImpl::OpenCachedArea(
182 int64 namespace_id, const GURL& origin) { 182 int64_t namespace_id,
183 const GURL& origin) {
183 std::string key = GetCachedAreaKey(namespace_id, origin); 184 std::string key = GetCachedAreaKey(namespace_id, origin);
184 if (CachedAreaHolder* holder = GetAreaHolder(key)) { 185 if (CachedAreaHolder* holder = GetAreaHolder(key)) {
185 ++(holder->open_count_); 186 ++(holder->open_count_);
186 return holder->area_.get(); 187 return holder->area_.get();
187 } 188 }
188 scoped_refptr<DOMStorageCachedArea> area = 189 scoped_refptr<DOMStorageCachedArea> area =
189 new DOMStorageCachedArea(namespace_id, origin, this); 190 new DOMStorageCachedArea(namespace_id, origin, this);
190 cached_areas_[key] = CachedAreaHolder(area.get(), 1); 191 cached_areas_[key] = CachedAreaHolder(area.get(), 1);
191 return area.get(); 192 return area.get();
192 } 193 }
193 194
194 void DomStorageDispatcher::ProxyImpl::CloseCachedArea( 195 void DomStorageDispatcher::ProxyImpl::CloseCachedArea(
195 DOMStorageCachedArea* area) { 196 DOMStorageCachedArea* area) {
196 std::string key = GetCachedAreaKey(area->namespace_id(), area->origin()); 197 std::string key = GetCachedAreaKey(area->namespace_id(), area->origin());
197 CachedAreaHolder* holder = GetAreaHolder(key); 198 CachedAreaHolder* holder = GetAreaHolder(key);
198 DCHECK(holder); 199 DCHECK(holder);
199 DCHECK_EQ(holder->area_.get(), area); 200 DCHECK_EQ(holder->area_.get(), area);
200 DCHECK_GT(holder->open_count_, 0); 201 DCHECK_GT(holder->open_count_, 0);
201 if (--(holder->open_count_) == 0) { 202 if (--(holder->open_count_) == 0) {
202 cached_areas_.erase(key); 203 cached_areas_.erase(key);
203 } 204 }
204 } 205 }
205 206
206 DOMStorageCachedArea* DomStorageDispatcher::ProxyImpl::LookupCachedArea( 207 DOMStorageCachedArea* DomStorageDispatcher::ProxyImpl::LookupCachedArea(
207 int64 namespace_id, const GURL& origin) { 208 int64_t namespace_id,
209 const GURL& origin) {
208 std::string key = GetCachedAreaKey(namespace_id, origin); 210 std::string key = GetCachedAreaKey(namespace_id, origin);
209 CachedAreaHolder* holder = GetAreaHolder(key); 211 CachedAreaHolder* holder = GetAreaHolder(key);
210 if (!holder) 212 if (!holder)
211 return NULL; 213 return NULL;
212 return holder->area_.get(); 214 return holder->area_.get();
213 } 215 }
214 216
215 void DomStorageDispatcher::ProxyImpl::CompleteOnePendingCallback(bool success) { 217 void DomStorageDispatcher::ProxyImpl::CompleteOnePendingCallback(bool success) {
216 PopPendingCallback().Run(success); 218 PopPendingCallback().Run(success);
217 } 219 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 263
262 DomStorageDispatcher::DomStorageDispatcher() 264 DomStorageDispatcher::DomStorageDispatcher()
263 : proxy_(new ProxyImpl(RenderThreadImpl::current())) { 265 : proxy_(new ProxyImpl(RenderThreadImpl::current())) {
264 } 266 }
265 267
266 DomStorageDispatcher::~DomStorageDispatcher() { 268 DomStorageDispatcher::~DomStorageDispatcher() {
267 proxy_->Shutdown(); 269 proxy_->Shutdown();
268 } 270 }
269 271
270 scoped_refptr<DOMStorageCachedArea> DomStorageDispatcher::OpenCachedArea( 272 scoped_refptr<DOMStorageCachedArea> DomStorageDispatcher::OpenCachedArea(
271 int connection_id, int64 namespace_id, const GURL& origin) { 273 int connection_id,
274 int64_t namespace_id,
275 const GURL& origin) {
272 RenderThreadImpl::current()->Send( 276 RenderThreadImpl::current()->Send(
273 new DOMStorageHostMsg_OpenStorageArea( 277 new DOMStorageHostMsg_OpenStorageArea(
274 connection_id, namespace_id, origin)); 278 connection_id, namespace_id, origin));
275 return proxy_->OpenCachedArea(namespace_id, origin); 279 return proxy_->OpenCachedArea(namespace_id, origin);
276 } 280 }
277 281
278 void DomStorageDispatcher::CloseCachedArea( 282 void DomStorageDispatcher::CloseCachedArea(
279 int connection_id, DOMStorageCachedArea* area) { 283 int connection_id, DOMStorageCachedArea* area) {
280 RenderThreadImpl::current()->Send( 284 RenderThreadImpl::current()->Send(
281 new DOMStorageHostMsg_CloseStorageArea(connection_id)); 285 new DOMStorageHostMsg_CloseStorageArea(connection_id));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 originating_area, 335 originating_area,
332 originated_in_process); 336 originated_in_process);
333 } 337 }
334 } 338 }
335 339
336 void DomStorageDispatcher::OnAsyncOperationComplete(bool success) { 340 void DomStorageDispatcher::OnAsyncOperationComplete(bool success) {
337 proxy_->CompleteOnePendingCallback(success); 341 proxy_->CompleteOnePendingCallback(success);
338 } 342 }
339 343
340 } // namespace content 344 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/dom_storage/dom_storage_dispatcher.h ('k') | content/renderer/dom_storage/webstoragearea_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698