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

Side by Side Diff: third_party/WebKit/Source/modules/cachestorage/InspectorCacheStorageAgent.cpp

Issue 1983783002: Remove OwnPtr::release() calls in modules/ (part 1). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "modules/cachestorage/InspectorCacheStorageAgent.h" 5 #include "modules/cachestorage/InspectorCacheStorageAgent.h"
6 #include "platform/heap/Handle.h" 6 #include "platform/heap/Handle.h"
7 #include "platform/inspector_protocol/Dispatcher.h" 7 #include "platform/inspector_protocol/Dispatcher.h"
8 #include "platform/inspector_protocol/TypeBuilder.h" 8 #include "platform/inspector_protocol/TypeBuilder.h"
9 #include "platform/inspector_protocol/Values.h" 9 #include "platform/inspector_protocol/Values.h"
10 #include "platform/weborigin/KURL.h" 10 #include "platform/weborigin/KURL.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 // Cache Storage API is restricted to trustworthy origins. 72 // Cache Storage API is restricted to trustworthy origins.
73 if (!secOrigin->isPotentiallyTrustworthy()) { 73 if (!secOrigin->isPotentiallyTrustworthy()) {
74 *errorString = secOrigin->isPotentiallyTrustworthyErrorMessage(); 74 *errorString = secOrigin->isPotentiallyTrustworthyErrorMessage();
75 return nullptr; 75 return nullptr;
76 } 76 }
77 77
78 OwnPtr<WebServiceWorkerCacheStorage> cache = adoptPtr(Platform::current()->c acheStorage(WebSecurityOrigin(secOrigin))); 78 OwnPtr<WebServiceWorkerCacheStorage> cache = adoptPtr(Platform::current()->c acheStorage(WebSecurityOrigin(secOrigin)));
79 if (!cache) 79 if (!cache)
80 *errorString = "Could not find cache storage."; 80 *errorString = "Could not find cache storage.";
81 return cache.release(); 81 return cache;
82 } 82 }
83 83
84 PassOwnPtr<WebServiceWorkerCacheStorage> assertCacheStorageAndNameForId(ErrorStr ing* errorString, const String& cacheId, String* cacheName) 84 PassOwnPtr<WebServiceWorkerCacheStorage> assertCacheStorageAndNameForId(ErrorStr ing* errorString, const String& cacheId, String* cacheName)
85 { 85 {
86 String securityOrigin; 86 String securityOrigin;
87 if (!parseCacheId(errorString, cacheId, &securityOrigin, cacheName)) { 87 if (!parseCacheId(errorString, cacheId, &securityOrigin, cacheName)) {
88 return nullptr; 88 return nullptr;
89 } 89 }
90 return assertCacheStorage(errorString, securityOrigin); 90 return assertCacheStorage(errorString, securityOrigin);
91 } 91 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 void onSuccess(const WebVector<WebString>& caches) override 124 void onSuccess(const WebVector<WebString>& caches) override
125 { 125 {
126 OwnPtr<Array<Cache>> array = Array<Cache>::create(); 126 OwnPtr<Array<Cache>> array = Array<Cache>::create();
127 for (size_t i = 0; i < caches.size(); i++) { 127 for (size_t i = 0; i < caches.size(); i++) {
128 String name = String(caches[i]); 128 String name = String(caches[i]);
129 OwnPtr<Cache> entry = Cache::create() 129 OwnPtr<Cache> entry = Cache::create()
130 .setSecurityOrigin(m_securityOrigin) 130 .setSecurityOrigin(m_securityOrigin)
131 .setCacheName(name) 131 .setCacheName(name)
132 .setCacheId(buildCacheId(m_securityOrigin, name)).build(); 132 .setCacheId(buildCacheId(m_securityOrigin, name)).build();
133 array->addItem(entry.release()); 133 array->addItem(std::move(entry));
134 } 134 }
135 m_callback->sendSuccess(array.release()); 135 m_callback->sendSuccess(std::move(array));
136 } 136 }
137 137
138 void onError(WebServiceWorkerCacheError error) override 138 void onError(WebServiceWorkerCacheError error) override
139 { 139 {
140 m_callback->sendFailure(String::format("Error requesting cache names: %s ", serviceWorkerCacheErrorString(error).data())); 140 m_callback->sendFailure(String::format("Error requesting cache names: %s ", serviceWorkerCacheErrorString(error).data()));
141 } 141 }
142 142
143 private: 143 private:
144 String m_securityOrigin; 144 String m_securityOrigin;
145 OwnPtr<RequestCacheNamesCallback> m_callback; 145 OwnPtr<RequestCacheNamesCallback> m_callback;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 bool hasMore = false; 194 bool hasMore = false;
195 if (static_cast<size_t>(m_params.pageSize) < m_responses.size()) { 195 if (static_cast<size_t>(m_params.pageSize) < m_responses.size()) {
196 m_responses.remove(m_params.pageSize, m_responses.size() - m_params. pageSize); 196 m_responses.remove(m_params.pageSize, m_responses.size() - m_params. pageSize);
197 hasMore = true; 197 hasMore = true;
198 } 198 }
199 OwnPtr<Array<DataEntry>> array = Array<DataEntry>::create(); 199 OwnPtr<Array<DataEntry>> array = Array<DataEntry>::create();
200 for (const auto& requestResponse : m_responses) { 200 for (const auto& requestResponse : m_responses) {
201 OwnPtr<DataEntry> entry = DataEntry::create() 201 OwnPtr<DataEntry> entry = DataEntry::create()
202 .setRequest(requestResponse.request) 202 .setRequest(requestResponse.request)
203 .setResponse(requestResponse.response).build(); 203 .setResponse(requestResponse.response).build();
204 array->addItem(entry.release()); 204 array->addItem(std::move(entry));
205 } 205 }
206 m_callback->sendSuccess(array.release(), hasMore); 206 m_callback->sendSuccess(std::move(array), hasMore);
207 } 207 }
208 208
209 void sendFailure(const String& error) 209 void sendFailure(const String& error)
210 { 210 {
211 m_callback->sendFailure(error); 211 m_callback->sendFailure(error);
212 } 212 }
213 213
214 private: 214 private:
215 DataRequestParams m_params; 215 DataRequestParams m_params;
216 int m_numResponsesLeft; 216 int m_numResponsesLeft;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 , m_callback(std::move(callback)) 256 , m_callback(std::move(callback))
257 { 257 {
258 } 258 }
259 ~GetCacheKeysForRequestData() override { } 259 ~GetCacheKeysForRequestData() override { }
260 260
261 WebServiceWorkerCache* cache() { return m_cache.get(); } 261 WebServiceWorkerCache* cache() { return m_cache.get(); }
262 void onSuccess(const WebVector<WebServiceWorkerRequest>& requests) override 262 void onSuccess(const WebVector<WebServiceWorkerRequest>& requests) override
263 { 263 {
264 if (requests.isEmpty()) { 264 if (requests.isEmpty()) {
265 OwnPtr<Array<DataEntry>> array = Array<DataEntry>::create(); 265 OwnPtr<Array<DataEntry>> array = Array<DataEntry>::create();
266 m_callback->sendSuccess(array.release(), false); 266 m_callback->sendSuccess(std::move(array), false);
267 return; 267 return;
268 } 268 }
269 RefPtr<ResponsesAccumulator> accumulator = adoptRef(new ResponsesAccumul ator(requests.size(), m_params, m_callback.release())); 269 RefPtr<ResponsesAccumulator> accumulator = adoptRef(new ResponsesAccumul ator(requests.size(), m_params, std::move(m_callback)));
270 270
271 for (size_t i = 0; i < requests.size(); i++) { 271 for (size_t i = 0; i < requests.size(); i++) {
272 const auto& request = requests[i]; 272 const auto& request = requests[i];
273 auto* cacheRequest = new GetCacheResponsesForRequestData(m_params, r equest, accumulator); 273 auto* cacheRequest = new GetCacheResponsesForRequestData(m_params, r equest, accumulator);
274 m_cache->dispatchMatch(cacheRequest, request, WebServiceWorkerCache: :QueryParams()); 274 m_cache->dispatchMatch(cacheRequest, request, WebServiceWorkerCache: :QueryParams());
275 } 275 }
276 } 276 }
277 277
278 void onError(WebServiceWorkerCacheError error) override 278 void onError(WebServiceWorkerCacheError error) override
279 { 279 {
(...skipping 13 matching lines...) Expand all
293 public: 293 public:
294 GetCacheForRequestData(const DataRequestParams& params, PassOwnPtr<RequestEn triesCallback> callback) 294 GetCacheForRequestData(const DataRequestParams& params, PassOwnPtr<RequestEn triesCallback> callback)
295 : m_params(params) 295 : m_params(params)
296 , m_callback(std::move(callback)) 296 , m_callback(std::move(callback))
297 { 297 {
298 } 298 }
299 ~GetCacheForRequestData() override { } 299 ~GetCacheForRequestData() override { }
300 300
301 void onSuccess(std::unique_ptr<WebServiceWorkerCache> cache) override 301 void onSuccess(std::unique_ptr<WebServiceWorkerCache> cache) override
302 { 302 {
303 auto* cacheRequest = new GetCacheKeysForRequestData(m_params, adoptPtr(c ache.release()), m_callback.release()); 303 auto* cacheRequest = new GetCacheKeysForRequestData(m_params, adoptPtr(c ache.release()), std::move(m_callback));
304 cacheRequest->cache()->dispatchKeys(cacheRequest, nullptr, WebServiceWor kerCache::QueryParams()); 304 cacheRequest->cache()->dispatchKeys(cacheRequest, nullptr, WebServiceWor kerCache::QueryParams());
305 } 305 }
306 306
307 void onError(WebServiceWorkerCacheError error) override 307 void onError(WebServiceWorkerCacheError error) override
308 { 308 {
309 m_callback->sendFailure(String::format("Error requesting cache %s: %s", m_params.cacheName.utf8().data(), serviceWorkerCacheErrorString(error).data())); 309 m_callback->sendFailure(String::format("Error requesting cache %s: %s", m_params.cacheName.utf8().data(), serviceWorkerCacheErrorString(error).data()));
310 } 310 }
311 311
312 private: 312 private:
313 DataRequestParams m_params; 313 DataRequestParams m_params;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 GetCacheForDeleteEntry(const String& requestSpec, const String& cacheName, P assOwnPtr<DeleteEntryCallback> callback) 370 GetCacheForDeleteEntry(const String& requestSpec, const String& cacheName, P assOwnPtr<DeleteEntryCallback> callback)
371 : m_requestSpec(requestSpec) 371 : m_requestSpec(requestSpec)
372 , m_cacheName(cacheName) 372 , m_cacheName(cacheName)
373 , m_callback(std::move(callback)) 373 , m_callback(std::move(callback))
374 { 374 {
375 } 375 }
376 ~GetCacheForDeleteEntry() override { } 376 ~GetCacheForDeleteEntry() override { }
377 377
378 void onSuccess(std::unique_ptr<WebServiceWorkerCache> cache) override 378 void onSuccess(std::unique_ptr<WebServiceWorkerCache> cache) override
379 { 379 {
380 auto* deleteRequest = new DeleteCacheEntry(m_callback.release()); 380 auto* deleteRequest = new DeleteCacheEntry(std::move(m_callback));
381 BatchOperation deleteOperation; 381 BatchOperation deleteOperation;
382 deleteOperation.operationType = WebServiceWorkerCache::OperationTypeDele te; 382 deleteOperation.operationType = WebServiceWorkerCache::OperationTypeDele te;
383 deleteOperation.request.setURL(KURL(ParsedURLString, m_requestSpec)); 383 deleteOperation.request.setURL(KURL(ParsedURLString, m_requestSpec));
384 Vector<BatchOperation> operations; 384 Vector<BatchOperation> operations;
385 operations.append(deleteOperation); 385 operations.append(deleteOperation);
386 cache.release()->dispatchBatch(deleteRequest, WebVector<BatchOperation>( operations)); 386 cache.release()->dispatchBatch(deleteRequest, WebVector<BatchOperation>( operations));
387 } 387 }
388 388
389 void onError(WebServiceWorkerCacheError error) override 389 void onError(WebServiceWorkerCacheError error) override
390 { 390 {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndNameForId( errorString, cacheId, &cacheName); 462 OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndNameForId( errorString, cacheId, &cacheName);
463 if (!cache) { 463 if (!cache) {
464 callback->sendFailure(*errorString); 464 callback->sendFailure(*errorString);
465 return; 465 return;
466 } 466 }
467 cache->dispatchOpen(new GetCacheForDeleteEntry(request, cacheName, std::move (callback)), WebString(cacheName)); 467 cache->dispatchOpen(new GetCacheForDeleteEntry(request, cacheName, std::move (callback)), WebString(cacheName));
468 } 468 }
469 469
470 470
471 } // namespace blink 471 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698