1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_WEB_SERVICE_WORKER_CACHE_STORAGE_IMPL_H_
6 #define CONTENT_RENDERER_SERVICE_WORKER_WEB_SERVICE_WORKER_CACHE_STORAGE_IMPL_H_
8 #include "content/child/thread_safe_sender.h"
9 #include "third_party/WebKit/public/platform/WebServiceWorkerCache.h"
10 #include "third_party/WebKit/public/platform/WebServiceWorkerCacheError.h"
11 #include "third_party/WebKit/public/platform/WebServiceWorkerCacheStorage.h"
12 #include "third_party/WebKit/public/platform/WebString.h"
16 class CacheStorageDispatcher
;
17 class ThreadSafeSender
;
19 // This corresponds to an instance of the script-facing CacheStorage object.
20 // One exists per script execution context (window, worker) and has an origin
21 // which provides a namespace for the caches. Script calls to the CacheStorage
22 // object are routed through here to the (per-thread) dispatcher then on to
23 // the browser, with the origin added to the call parameters. Cache instances
24 // returned by open() calls are minted by and implemented within the code of
25 // the CacheStorageDispatcher, and include routing information.
26 class WebServiceWorkerCacheStorageImpl
27 : public blink::WebServiceWorkerCacheStorage
{
29 WebServiceWorkerCacheStorageImpl(ThreadSafeSender
* thread_safe_sender
,
31 ~WebServiceWorkerCacheStorageImpl();
33 // From WebServiceWorkerCacheStorage:
34 virtual void dispatchHas(CacheStorageCallbacks
* callbacks
,
35 const blink::WebString
& cacheName
);
36 virtual void dispatchOpen(CacheStorageWithCacheCallbacks
* callbacks
,
37 const blink::WebString
& cacheName
);
38 virtual void dispatchDelete(CacheStorageCallbacks
* callbacks
,
39 const blink::WebString
& cacheName
);
40 virtual void dispatchKeys(CacheStorageKeysCallbacks
* callbacks
);
41 virtual void dispatchMatch(
42 CacheStorageMatchCallbacks
* callbacks
,
43 const blink::WebServiceWorkerRequest
& request
,
44 const blink::WebServiceWorkerCache::QueryParams
& query_params
);
47 // Helper to return the thread-specific dispatcher.
48 CacheStorageDispatcher
* GetDispatcher() const;
50 scoped_refptr
<ThreadSafeSender
> thread_safe_sender_
;
53 DISALLOW_COPY_AND_ASSIGN(WebServiceWorkerCacheStorageImpl
);
56 } // namespace content
58 #endif // CONTENT_RENDERER_SERVICE_WORKER_WEB_SERVICE_WORKER_CACHE_STORAGE_IMPL_H_