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

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

Issue 1760673003: Cache API: Pass origin to platform, rather than DatabaseIdentifier (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 6
7 #include "platform/heap/Handle.h" 7 #include "platform/heap/Handle.h"
8 #include "platform/inspector_protocol/Dispatcher.h" 8 #include "platform/inspector_protocol/Dispatcher.h"
9 #include "platform/inspector_protocol/TypeBuilder.h" 9 #include "platform/inspector_protocol/TypeBuilder.h"
10 #include "platform/inspector_protocol/Values.h" 10 #include "platform/inspector_protocol/Values.h"
11 #include "platform/weborigin/DatabaseIdentifier.h" 11 #include "platform/weborigin/DatabaseIdentifier.h"
12 #include "platform/weborigin/KURL.h" 12 #include "platform/weborigin/KURL.h"
13 #include "platform/weborigin/SecurityOrigin.h" 13 #include "platform/weborigin/SecurityOrigin.h"
14 #include "public/platform/Platform.h" 14 #include "public/platform/Platform.h"
15 #include "public/platform/WebPassOwnPtr.h" 15 #include "public/platform/WebPassOwnPtr.h"
16 #include "public/platform/WebSecurityOrigin.h"
16 #include "public/platform/WebString.h" 17 #include "public/platform/WebString.h"
17 #include "public/platform/WebURL.h" 18 #include "public/platform/WebURL.h"
18 #include "public/platform/WebVector.h" 19 #include "public/platform/WebVector.h"
19 #include "public/platform/modules/serviceworker/WebServiceWorkerCache.h" 20 #include "public/platform/modules/serviceworker/WebServiceWorkerCache.h"
20 #include "public/platform/modules/serviceworker/WebServiceWorkerCacheError.h" 21 #include "public/platform/modules/serviceworker/WebServiceWorkerCacheError.h"
21 #include "public/platform/modules/serviceworker/WebServiceWorkerCacheStorage.h" 22 #include "public/platform/modules/serviceworker/WebServiceWorkerCacheStorage.h"
22 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" 23 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h"
23 #include "public/platform/modules/serviceworker/WebServiceWorkerResponse.h" 24 #include "public/platform/modules/serviceworker/WebServiceWorkerResponse.h"
24 #include "wtf/Noncopyable.h" 25 #include "wtf/Noncopyable.h"
25 #include "wtf/OwnPtr.h" 26 #include "wtf/OwnPtr.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 PassOwnPtr<WebServiceWorkerCacheStorage> assertCacheStorage(ErrorString* errorSt ring, const String& securityOrigin) 70 PassOwnPtr<WebServiceWorkerCacheStorage> assertCacheStorage(ErrorString* errorSt ring, const String& securityOrigin)
70 { 71 {
71 RefPtr<SecurityOrigin> secOrigin = SecurityOrigin::createFromString(security Origin); 72 RefPtr<SecurityOrigin> secOrigin = SecurityOrigin::createFromString(security Origin);
72 73
73 // Cache Storage API is restricted to trustworthy origins. 74 // Cache Storage API is restricted to trustworthy origins.
74 if (!secOrigin->isPotentiallyTrustworthy()) { 75 if (!secOrigin->isPotentiallyTrustworthy()) {
75 *errorString = secOrigin->isPotentiallyTrustworthyErrorMessage(); 76 *errorString = secOrigin->isPotentiallyTrustworthyErrorMessage();
76 return nullptr; 77 return nullptr;
77 } 78 }
78 79
79 String identifier = createDatabaseIdentifierFromSecurityOrigin(secOrigin.get ()); 80 OwnPtr<WebServiceWorkerCacheStorage> cache = adoptPtr(Platform::current()->c acheStorage(WebSecurityOrigin(secOrigin)));
80 OwnPtr<WebServiceWorkerCacheStorage> cache = adoptPtr(Platform::current()->c acheStorage(identifier));
81 if (!cache) 81 if (!cache)
82 *errorString = "Could not find cache storage."; 82 *errorString = "Could not find cache storage.";
83 return cache.release(); 83 return cache.release();
84 } 84 }
85 85
86 PassOwnPtr<WebServiceWorkerCacheStorage> assertCacheStorageAndNameForId(ErrorStr ing* errorString, const String& cacheId, String* cacheName) 86 PassOwnPtr<WebServiceWorkerCacheStorage> assertCacheStorageAndNameForId(ErrorStr ing* errorString, const String& cacheId, String* cacheName)
87 { 87 {
88 String securityOrigin; 88 String securityOrigin;
89 if (!parseCacheId(errorString, cacheId, &securityOrigin, cacheName)) { 89 if (!parseCacheId(errorString, cacheId, &securityOrigin, cacheName)) {
90 return nullptr; 90 return nullptr;
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndNameForId( errorString, cacheId, &cacheName); 464 OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndNameForId( errorString, cacheId, &cacheName);
465 if (!cache) { 465 if (!cache) {
466 callback->sendFailure(*errorString); 466 callback->sendFailure(*errorString);
467 return; 467 return;
468 } 468 }
469 cache->dispatchOpen(new GetCacheForDeleteEntry(request, cacheName, callback) , WebString(cacheName)); 469 cache->dispatchOpen(new GetCacheForDeleteEntry(request, cacheName, callback) , WebString(cacheName));
470 } 470 }
471 471
472 472
473 } // namespace blink 473 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698