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

Unified Diff: Source/modules/serviceworkers/InspectorServiceWorkerCacheAgent.cpp

Issue 1029423004: Cache Storage: Add Platform API to retrieve CacheStorage for origin (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
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);
kinuko 2015/03/25 03:57:23 Oh ok- so we create and delete the storage interfa
michaeln 2015/03/25 18:52:24 This is ok. If we ever decide to have per-origin o
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;

Powered by Google App Engine
This is Rietveld 408576698