| Index: Source/modules/serviceworkers/InspectorServiceWorkerCacheAgent.cpp
|
| diff --git a/Source/modules/serviceworkers/InspectorServiceWorkerCacheAgent.cpp b/Source/modules/serviceworkers/InspectorServiceWorkerCacheAgent.cpp
|
| index 2053ef0851afdc657b92c34630dd9801887888ce..f05db4438ca3e496554b4c3414bb883a95de6c5d 100644
|
| --- a/Source/modules/serviceworkers/InspectorServiceWorkerCacheAgent.cpp
|
| +++ b/Source/modules/serviceworkers/InspectorServiceWorkerCacheAgent.cpp
|
| @@ -11,6 +11,8 @@
|
| #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
|
| #include "platform/JSONValues.h"
|
| #include "platform/heap/Handle.h"
|
| +#include "platform/weborigin/DatabaseIdentifier.h"
|
| +#include "public/platform/Platform.h"
|
| #include "public/platform/WebServiceWorkerCache.h"
|
| #include "public/platform/WebServiceWorkerCacheError.h"
|
| #include "public/platform/WebServiceWorkerCacheStorage.h"
|
| @@ -41,19 +43,15 @@ namespace blink {
|
|
|
| namespace {
|
|
|
| -WebServiceWorkerCacheStorage* assertCacheStorage(ErrorString* errorString, ServiceWorkerGlobalScope* globalScope)
|
| +PassOwnPtr<WebServiceWorkerCacheStorage> assertCacheStorage(ErrorString* errorString, ServiceWorkerGlobalScope* globalScope)
|
| {
|
| - ServiceWorkerGlobalScopeClient* client = ServiceWorkerGlobalScopeClient::from(globalScope);
|
| - if (!client) {
|
| - *errorString = "Could not find service worker global scope.";
|
| + String identifier = createDatabaseIdentifierFromSecurityOrigin(globalScope->securityOrigin());
|
| + OwnPtr<WebServiceWorkerCacheStorage> caches = adoptPtr(Platform::current()->cacheStorage(identifier));
|
| + if (!caches) {
|
| + *errorString = "Cache Storage not available in global scope.";
|
| return nullptr;
|
| }
|
| - WebServiceWorkerCacheStorage* cache = client->cacheStorage();
|
| - if (!cache) {
|
| - *errorString = "Cache not available on service worker global client.";
|
| - return nullptr;
|
| - }
|
| - return cache;
|
| + return caches.release();
|
| }
|
|
|
| CString serviceWorkerCacheErrorString(WebServiceWorkerCacheError* error)
|
| @@ -307,7 +305,7 @@ DEFINE_TRACE(InspectorServiceWorkerCacheAgent)
|
|
|
| void InspectorServiceWorkerCacheAgent::requestCacheNames(ErrorString* errorString, PassRefPtrWillBeRawPtr<RequestCacheNamesCallback> callback)
|
| {
|
| - WebServiceWorkerCacheStorage* cache = assertCacheStorage(errorString, m_globalScope);
|
| + OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorage(errorString, m_globalScope);
|
| if (!cache) {
|
| callback->sendFailure(*errorString);
|
| return;
|
| @@ -318,7 +316,7 @@ void InspectorServiceWorkerCacheAgent::requestCacheNames(ErrorString* errorStrin
|
|
|
| void InspectorServiceWorkerCacheAgent::requestEntries(ErrorString* errorString, const String& cacheName, int skipCount, int pageSize, PassRefPtrWillBeRawPtr<RequestEntriesCallback> callback)
|
| {
|
| - WebServiceWorkerCacheStorage* cache = assertCacheStorage(errorString, m_globalScope);
|
| + OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorage(errorString, m_globalScope);
|
| if (!cache) {
|
| callback->sendFailure(*errorString);
|
| return;
|
| @@ -332,7 +330,7 @@ void InspectorServiceWorkerCacheAgent::requestEntries(ErrorString* errorString,
|
|
|
| void InspectorServiceWorkerCacheAgent::deleteCache(ErrorString* errorString, const String& cacheName, PassRefPtrWillBeRawPtr<DeleteCacheCallback> callback)
|
| {
|
| - WebServiceWorkerCacheStorage* cache = assertCacheStorage(errorString, m_globalScope);
|
| + OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorage(errorString, m_globalScope);
|
| if (!cache) {
|
| callback->sendFailure(*errorString);
|
| return;
|
|
|