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

Unified Diff: content/renderer/service_worker/service_worker_cache_storage_dispatcher.h

Issue 379303002: Content blink::WebServiceWorkerCacheStorage implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self review for style Created 6 years, 5 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: content/renderer/service_worker/service_worker_cache_storage_dispatcher.h
diff --git a/content/renderer/service_worker/service_worker_cache_storage_dispatcher.h b/content/renderer/service_worker/service_worker_cache_storage_dispatcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..ac0191ac26d4051e21511309c02548b5e5dafc04
--- /dev/null
+++ b/content/renderer/service_worker/service_worker_cache_storage_dispatcher.h
@@ -0,0 +1,86 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_DISPATCHER_H_
+#define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_DISPATCHER_H_
+
+#include <vector>
+
+#include "base/id_map.h"
+#include "base/strings/string16.h"
+#include "content/public/renderer/render_process_observer.h"
+#include "third_party/WebKit/public/platform/WebServiceWorkerCacheStorage.h"
+#include "third_party/WebKit/public/platform/WebServiceWorkerCacheStorageError.h"
+
+namespace content {
+
+class ServiceWorkerScriptContext;
+
+// There is one ServiceWorkerCacheStorageDispatcher per
+// ServiceWorkerScriptContext. It starts CacheStorage operations with messages
+// to the browser process and runs callbacks at operation completion.
falken 2014/07/28 04:48:58 nit: extra space after "runs"
gavinp 2014/07/28 04:55:27 Done.
+
+class ServiceWorkerCacheStorageDispatcher
+ : public blink::WebServiceWorkerCacheStorage {
+ public:
+ ServiceWorkerCacheStorageDispatcher(
+ ServiceWorkerScriptContext* script_context);
+ virtual ~ServiceWorkerCacheStorageDispatcher();
+
+ bool OnMessageReceived(const IPC::Message& message);
+
+ // Message handlers for messages from the browser process.
+ void OnCacheStorageCreateSuccess(int request_id, int cache_id);
+ void OnCacheStorageRenameSuccess(int request_id);
+ void OnCacheStorageGetSuccess(int request_id, int cache_id);
+ void OnCacheStorageDeleteSuccess(int request_id);
+ void OnCacheStorageKeysSuccess(int request_id,
+ const std::vector<base::string16>& keys);
+
+ void OnCacheStorageCreateError(
+ int request_id,
+ blink::WebServiceWorkerCacheStorageError reason);
+ void OnCacheStorageRenameError(
+ int request_id,
+ blink::WebServiceWorkerCacheStorageError reason);
+ void OnCacheStorageGetError(int request_id,
+ blink::WebServiceWorkerCacheStorageError reason);
+ void OnCacheStorageDeleteError(
+ int request_id,
+ blink::WebServiceWorkerCacheStorageError reason);
+ void OnCacheStorageKeysError(int request_id,
+ blink::WebServiceWorkerCacheStorageError reason);
+
+ // From WebServiceWorkerCacheStorage:
+ virtual void dispatchCreate(CacheStorageWithCacheCallbacks* callbacks,
+ const blink::WebString& key) OVERRIDE;
+ virtual void dispatchRename(CacheStorageCallbacks* callbacks,
+ const blink::WebString& oldKey,
+ const blink::WebString& newKey) OVERRIDE;
+ virtual void dispatchGet(CacheStorageWithCacheCallbacks* callbacks,
+ const blink::WebString& key) OVERRIDE;
+ virtual void dispatchDelete(CacheStorageCallbacks* callbacks,
+ const blink::WebString& key) OVERRIDE;
+ virtual void dispatchKeys(CacheStorageKeysCallbacks* callbacks) OVERRIDE;
+
+ private:
+ typedef IDMap<CacheStorageCallbacks, IDMapOwnPointer> CallbacksMap;
+ typedef IDMap<CacheStorageWithCacheCallbacks, IDMapOwnPointer>
+ WithCacheCallbacksMap;
+ typedef IDMap<CacheStorageKeysCallbacks, IDMapOwnPointer>
+ KeysCallbacksMap;
+
+ // Not owned. The script context containing this object.
+ ServiceWorkerScriptContext* script_context_;
+
+ WithCacheCallbacksMap create_callbacks_;
+ CallbacksMap rename_callbacks_;
+ WithCacheCallbacksMap get_callbacks_;
+ CallbacksMap delete_callbacks_;
+ KeysCallbacksMap keys_callbacks_;
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_DISPATCHER_H_

Powered by Google App Engine
This is Rietveld 408576698