| Index: Source/modules/serviceworkers/InspectorServiceWorkerCacheAgent.cpp
|
| diff --git a/Source/modules/serviceworkers/InspectorServiceWorkerCacheAgent.cpp b/Source/modules/serviceworkers/InspectorServiceWorkerCacheAgent.cpp
|
| index f05db4438ca3e496554b4c3414bb883a95de6c5d..da61ab7c4255f6a3cc95019d4c101fd5f04a86a2 100644
|
| --- a/Source/modules/serviceworkers/InspectorServiceWorkerCacheAgent.cpp
|
| +++ b/Source/modules/serviceworkers/InspectorServiceWorkerCacheAgent.cpp
|
| @@ -7,11 +7,10 @@
|
|
|
| #include "core/InspectorBackendDispatcher.h"
|
| #include "core/InspectorTypeBuilder.h"
|
| -#include "modules/serviceworkers/ServiceWorkerGlobalScope.h"
|
| -#include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
|
| #include "platform/JSONValues.h"
|
| #include "platform/heap/Handle.h"
|
| #include "platform/weborigin/DatabaseIdentifier.h"
|
| +#include "platform/weborigin/SecurityOrigin.h"
|
| #include "public/platform/Platform.h"
|
| #include "public/platform/WebServiceWorkerCache.h"
|
| #include "public/platform/WebServiceWorkerCacheError.h"
|
| @@ -32,26 +31,25 @@
|
| #include <algorithm>
|
|
|
| using blink::TypeBuilder::Array;
|
| -using blink::TypeBuilder::ServiceWorkerCache::DataEntry;
|
| +using blink::TypeBuilder::CacheStorage::DataEntry;
|
|
|
| -typedef blink::InspectorBackendDispatcher::ServiceWorkerCacheCommandHandler::DeleteCacheCallback DeleteCacheCallback;
|
| -typedef blink::InspectorBackendDispatcher::ServiceWorkerCacheCommandHandler::RequestCacheNamesCallback RequestCacheNamesCallback;
|
| -typedef blink::InspectorBackendDispatcher::ServiceWorkerCacheCommandHandler::RequestEntriesCallback RequestEntriesCallback;
|
| +typedef blink::InspectorBackendDispatcher::CacheStorageCommandHandler::DeleteCacheCallback DeleteCacheCallback;
|
| +typedef blink::InspectorBackendDispatcher::CacheStorageCommandHandler::RequestCacheNamesCallback RequestCacheNamesCallback;
|
| +typedef blink::InspectorBackendDispatcher::CacheStorageCommandHandler::RequestEntriesCallback RequestEntriesCallback;
|
| typedef blink::InspectorBackendDispatcher::CallbackBase RequestCallback;
|
|
|
| namespace blink {
|
|
|
| namespace {
|
|
|
| -PassOwnPtr<WebServiceWorkerCacheStorage> assertCacheStorage(ErrorString* errorString, ServiceWorkerGlobalScope* globalScope)
|
| +PassOwnPtr<WebServiceWorkerCacheStorage> assertCacheStorage(ErrorString* errorString, const String& securityOrigin)
|
| {
|
| - 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;
|
| - }
|
| - return caches.release();
|
| + RefPtr<SecurityOrigin> secOrigin = SecurityOrigin::createFromString(securityOrigin);
|
| + String identifier = createDatabaseIdentifierFromSecurityOrigin(secOrigin.get());
|
| + WebServiceWorkerCacheStorage* cache = Platform::current()->cacheStorage(identifier);
|
| + if (!cache)
|
| + *errorString = "Could not find cache storage.";
|
| + return adoptPtr(cache);
|
| }
|
|
|
| CString serviceWorkerCacheErrorString(WebServiceWorkerCacheError* error)
|
| @@ -216,6 +214,11 @@ public:
|
|
|
| void onSuccess(WebVector<WebServiceWorkerRequest>* requests)
|
| {
|
| + if (requests->isEmpty()) {
|
| + RefPtr<TypeBuilder::Array<DataEntry>> array = TypeBuilder::Array<DataEntry>::create();
|
| + m_callback->sendSuccess(array, false);
|
| + return;
|
| + }
|
| RefPtr<ResponsesAccumulator> accumulator = adoptRef(new ResponsesAccumulator(requests->size(), m_params, m_callback));
|
|
|
| for (size_t i = 0; i < requests->size(); i++) {
|
| @@ -290,9 +293,8 @@ private:
|
|
|
| } // namespace
|
|
|
| -InspectorServiceWorkerCacheAgent::InspectorServiceWorkerCacheAgent(ServiceWorkerGlobalScope* scope)
|
| - : InspectorBaseAgent<blink::InspectorServiceWorkerCacheAgent, InspectorFrontend::ServiceWorkerCache>("ServiceWorkerCache")
|
| - , m_globalScope(scope)
|
| +InspectorServiceWorkerCacheAgent::InspectorServiceWorkerCacheAgent()
|
| + : InspectorBaseAgent<InspectorServiceWorkerCacheAgent, InspectorFrontend::CacheStorage>("CacheStorage")
|
| {
|
| }
|
|
|
| @@ -303,9 +305,9 @@ DEFINE_TRACE(InspectorServiceWorkerCacheAgent)
|
| InspectorBaseAgent::trace(visitor);
|
| }
|
|
|
| -void InspectorServiceWorkerCacheAgent::requestCacheNames(ErrorString* errorString, PassRefPtrWillBeRawPtr<RequestCacheNamesCallback> callback)
|
| +void InspectorServiceWorkerCacheAgent::requestCacheNames(ErrorString* errorString, const String& securityOrigin, PassRefPtrWillBeRawPtr<RequestCacheNamesCallback> callback)
|
| {
|
| - OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorage(errorString, m_globalScope);
|
| + OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorage(errorString, securityOrigin);
|
| if (!cache) {
|
| callback->sendFailure(*errorString);
|
| return;
|
| @@ -313,10 +315,9 @@ void InspectorServiceWorkerCacheAgent::requestCacheNames(ErrorString* errorStrin
|
| cache->dispatchKeys(new RequestCacheNames(callback));
|
| }
|
|
|
| -
|
| -void InspectorServiceWorkerCacheAgent::requestEntries(ErrorString* errorString, const String& cacheName, int skipCount, int pageSize, PassRefPtrWillBeRawPtr<RequestEntriesCallback> callback)
|
| +void InspectorServiceWorkerCacheAgent::requestEntries(ErrorString* errorString, const String& securityOrigin, const String& cacheName, int skipCount, int pageSize, PassRefPtrWillBeRawPtr<RequestEntriesCallback> callback)
|
| {
|
| - OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorage(errorString, m_globalScope);
|
| + OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorage(errorString, securityOrigin);
|
| if (!cache) {
|
| callback->sendFailure(*errorString);
|
| return;
|
| @@ -328,9 +329,9 @@ void InspectorServiceWorkerCacheAgent::requestEntries(ErrorString* errorString,
|
| cache->dispatchOpen(new GetCacheForRequestData(params, callback), WebString(cacheName));
|
| }
|
|
|
| -void InspectorServiceWorkerCacheAgent::deleteCache(ErrorString* errorString, const String& cacheName, PassRefPtrWillBeRawPtr<DeleteCacheCallback> callback)
|
| +void InspectorServiceWorkerCacheAgent::deleteCache(ErrorString* errorString, const String& securityOrigin, const String& cacheName, PassRefPtrWillBeRawPtr<DeleteCacheCallback> callback)
|
| {
|
| - OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorage(errorString, m_globalScope);
|
| + OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorage(errorString, securityOrigin);
|
| if (!cache) {
|
| callback->sendFailure(*errorString);
|
| return;
|
|
|