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

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

Issue 2480293004: Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode. (Closed)
Patch Set: Make changes requested by danakj, fix a few more headers Created 4 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
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/CacheStorage.h" 5 #include "modules/cachestorage/CacheStorage.h"
6 6
7 #include "bindings/core/v8/ScriptPromiseResolver.h" 7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
10 #include "core/dom/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
11 #include "core/inspector/ConsoleMessage.h" 11 #include "core/inspector/ConsoleMessage.h"
12 #include "modules/cachestorage/CacheStorageError.h" 12 #include "modules/cachestorage/CacheStorageError.h"
13 #include "modules/fetch/Request.h" 13 #include "modules/fetch/Request.h"
14 #include "modules/fetch/Response.h" 14 #include "modules/fetch/Response.h"
15 #include "public/platform/modules/serviceworker/WebServiceWorkerCacheError.h" 15 #include "public/platform/modules/serviceworker/WebServiceWorkerCacheError.h"
16 #include "public/platform/modules/serviceworker/WebServiceWorkerCacheStorage.h" 16 #include "public/platform/modules/serviceworker/WebServiceWorkerCacheStorage.h"
17 #include "wtf/PtrUtil.h" 17 #include "wtf/PtrUtil.h"
18 #include <memory> 18 #include <memory>
19 #include <utility>
19 20
20 namespace blink { 21 namespace blink {
21 22
22 namespace { 23 namespace {
23 24
24 DOMException* createNoImplementationException() { 25 DOMException* createNoImplementationException() {
25 return DOMException::create(NotSupportedError, 26 return DOMException::create(NotSupportedError,
26 "No CacheStorage implementation provided."); 27 "No CacheStorage implementation provided.");
27 } 28 }
28 29
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 231
231 ScriptPromise CacheStorage::open(ScriptState* scriptState, 232 ScriptPromise CacheStorage::open(ScriptState* scriptState,
232 const String& cacheName, 233 const String& cacheName,
233 ExceptionState& exceptionState) { 234 ExceptionState& exceptionState) {
234 if (!commonChecks(scriptState, exceptionState)) 235 if (!commonChecks(scriptState, exceptionState))
235 return ScriptPromise(); 236 return ScriptPromise();
236 237
237 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 238 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
238 const ScriptPromise promise = resolver->promise(); 239 const ScriptPromise promise = resolver->promise();
239 240
240 if (m_webCacheStorage) 241 if (m_webCacheStorage) {
241 m_webCacheStorage->dispatchOpen( 242 m_webCacheStorage->dispatchOpen(
242 new WithCacheCallbacks(cacheName, this, resolver), cacheName); 243 WTF::makeUnique<WithCacheCallbacks>(cacheName, this, resolver),
243 else 244 cacheName);
245 } else {
244 resolver->reject(createNoImplementationException()); 246 resolver->reject(createNoImplementationException());
247 }
245 248
246 return promise; 249 return promise;
247 } 250 }
248 251
249 ScriptPromise CacheStorage::has(ScriptState* scriptState, 252 ScriptPromise CacheStorage::has(ScriptState* scriptState,
250 const String& cacheName, 253 const String& cacheName,
251 ExceptionState& exceptionState) { 254 ExceptionState& exceptionState) {
252 if (!commonChecks(scriptState, exceptionState)) 255 if (!commonChecks(scriptState, exceptionState))
253 return ScriptPromise(); 256 return ScriptPromise();
254 257
255 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 258 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
256 const ScriptPromise promise = resolver->promise(); 259 const ScriptPromise promise = resolver->promise();
257 260
258 if (m_webCacheStorage) 261 if (m_webCacheStorage) {
259 m_webCacheStorage->dispatchHas(new Callbacks(resolver), cacheName); 262 m_webCacheStorage->dispatchHas(WTF::makeUnique<Callbacks>(resolver),
260 else 263 cacheName);
264 } else {
261 resolver->reject(createNoImplementationException()); 265 resolver->reject(createNoImplementationException());
266 }
262 267
263 return promise; 268 return promise;
264 } 269 }
265 270
266 ScriptPromise CacheStorage::deleteFunction(ScriptState* scriptState, 271 ScriptPromise CacheStorage::deleteFunction(ScriptState* scriptState,
267 const String& cacheName, 272 const String& cacheName,
268 ExceptionState& exceptionState) { 273 ExceptionState& exceptionState) {
269 if (!commonChecks(scriptState, exceptionState)) 274 if (!commonChecks(scriptState, exceptionState))
270 return ScriptPromise(); 275 return ScriptPromise();
271 276
272 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 277 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
273 const ScriptPromise promise = resolver->promise(); 278 const ScriptPromise promise = resolver->promise();
274 279
275 if (m_webCacheStorage) 280 if (m_webCacheStorage) {
276 m_webCacheStorage->dispatchDelete( 281 m_webCacheStorage->dispatchDelete(
277 new DeleteCallbacks(cacheName, this, resolver), cacheName); 282 WTF::makeUnique<DeleteCallbacks>(cacheName, this, resolver), cacheName);
278 else 283 } else {
279 resolver->reject(createNoImplementationException()); 284 resolver->reject(createNoImplementationException());
285 }
280 286
281 return promise; 287 return promise;
282 } 288 }
283 289
284 ScriptPromise CacheStorage::keys(ScriptState* scriptState, 290 ScriptPromise CacheStorage::keys(ScriptState* scriptState,
285 ExceptionState& exceptionState) { 291 ExceptionState& exceptionState) {
286 if (!commonChecks(scriptState, exceptionState)) 292 if (!commonChecks(scriptState, exceptionState))
287 return ScriptPromise(); 293 return ScriptPromise();
288 294
289 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 295 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
290 const ScriptPromise promise = resolver->promise(); 296 const ScriptPromise promise = resolver->promise();
291 297
292 if (m_webCacheStorage) 298 if (m_webCacheStorage)
293 m_webCacheStorage->dispatchKeys(new KeysCallbacks(resolver)); 299 m_webCacheStorage->dispatchKeys(WTF::makeUnique<KeysCallbacks>(resolver));
294 else 300 else
295 resolver->reject(createNoImplementationException()); 301 resolver->reject(createNoImplementationException());
296 302
297 return promise; 303 return promise;
298 } 304 }
299 305
300 ScriptPromise CacheStorage::match(ScriptState* scriptState, 306 ScriptPromise CacheStorage::match(ScriptState* scriptState,
301 const RequestInfo& request, 307 const RequestInfo& request,
302 const CacheQueryOptions& options, 308 const CacheQueryOptions& options,
303 ExceptionState& exceptionState) { 309 ExceptionState& exceptionState) {
(...skipping 18 matching lines...) Expand all
322 328
323 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 329 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
324 const ScriptPromise promise = resolver->promise(); 330 const ScriptPromise promise = resolver->promise();
325 331
326 if (request->method() != HTTPNames::GET && !options.ignoreMethod()) { 332 if (request->method() != HTTPNames::GET && !options.ignoreMethod()) {
327 resolver->resolve(); 333 resolver->resolve();
328 return promise; 334 return promise;
329 } 335 }
330 336
331 if (m_webCacheStorage) 337 if (m_webCacheStorage)
332 m_webCacheStorage->dispatchMatch(new MatchCallbacks(resolver), webRequest, 338 m_webCacheStorage->dispatchMatch(WTF::makeUnique<MatchCallbacks>(resolver),
339 webRequest,
333 Cache::toWebQueryParams(options)); 340 Cache::toWebQueryParams(options));
334 else 341 else
335 resolver->reject(createNoImplementationException()); 342 resolver->reject(createNoImplementationException());
336 343
337 return promise; 344 return promise;
338 } 345 }
339 346
340 CacheStorage::CacheStorage( 347 CacheStorage::CacheStorage(
341 GlobalFetch::ScopedFetcher* fetcher, 348 GlobalFetch::ScopedFetcher* fetcher,
342 std::unique_ptr<WebServiceWorkerCacheStorage> webCacheStorage) 349 std::unique_ptr<WebServiceWorkerCacheStorage> webCacheStorage)
343 : m_scopedFetcher(fetcher), m_webCacheStorage(std::move(webCacheStorage)) {} 350 : m_scopedFetcher(fetcher), m_webCacheStorage(std::move(webCacheStorage)) {}
344 351
345 CacheStorage::~CacheStorage() {} 352 CacheStorage::~CacheStorage() {}
346 353
347 void CacheStorage::dispose() { 354 void CacheStorage::dispose() {
348 m_webCacheStorage.reset(); 355 m_webCacheStorage.reset();
349 } 356 }
350 357
351 DEFINE_TRACE(CacheStorage) { 358 DEFINE_TRACE(CacheStorage) {
352 visitor->trace(m_scopedFetcher); 359 visitor->trace(m_scopedFetcher);
353 } 360 }
354 361
355 } // namespace blink 362 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/cachestorage/Cache.cpp ('k') | third_party/WebKit/Source/modules/cachestorage/CacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698