Add ICU message format support
[chromium-blink-merge.git] / content / browser / cache_storage / cache_storage_dispatcher_host.h
blob8691a9cfde9034bcb2a352dae824b7a8739f1509
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_BROWSER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_HOST_H_
8 #include <list>
10 #include "content/browser/cache_storage/cache_storage.h"
11 #include "content/public/browser/browser_message_filter.h"
13 namespace content {
15 class CacheStorageContextImpl;
17 // Handles Cache Storage related messages sent to the browser process from
18 // child processes. One host instance exists per child process. All
19 // messages are processed on the IO thread.
20 class CONTENT_EXPORT CacheStorageDispatcherHost : public BrowserMessageFilter {
21 public:
22 CacheStorageDispatcherHost();
24 // Runs on UI thread.
25 void Init(CacheStorageContextImpl* context);
27 // BrowserMessageFilter implementation
28 void OnDestruct() const override;
29 bool OnMessageReceived(const IPC::Message& message) override;
31 private:
32 // Friends to allow OnDestruct() delegation
33 friend class BrowserThread;
34 friend class base::DeleteHelper<CacheStorageDispatcherHost>;
36 typedef int32_t CacheID; // TODO(jkarlin): Bump to 64 bit.
37 typedef std::map<CacheID, scoped_refptr<CacheStorageCache>> IDToCacheMap;
38 typedef std::map<std::string, std::list<storage::BlobDataHandle>>
39 UUIDToBlobDataHandleList;
41 ~CacheStorageDispatcherHost() override;
43 // Called by Init() on IO thread.
44 void CreateCacheListener(CacheStorageContextImpl* context);
46 // The message receiver functions for the CacheStorage API:
47 void OnCacheStorageHas(int thread_id,
48 int request_id,
49 const GURL& origin,
50 const base::string16& cache_name);
51 void OnCacheStorageOpen(int thread_id,
52 int request_id,
53 const GURL& origin,
54 const base::string16& cache_name);
55 void OnCacheStorageDelete(int thread_id,
56 int request_id,
57 const GURL& origin,
58 const base::string16& cache_name);
59 void OnCacheStorageKeys(int thread_id, int request_id, const GURL& origin);
60 void OnCacheStorageMatch(int thread_id,
61 int request_id,
62 const GURL& origin,
63 const ServiceWorkerFetchRequest& request,
64 const CacheStorageCacheQueryParams& match_params);
66 // The message receiver functions for the Cache API:
67 void OnCacheMatch(int thread_id,
68 int request_id,
69 int cache_id,
70 const ServiceWorkerFetchRequest& request,
71 const CacheStorageCacheQueryParams& match_params);
72 void OnCacheKeys(int thread_id,
73 int request_id,
74 int cache_id,
75 const ServiceWorkerFetchRequest& request,
76 const CacheStorageCacheQueryParams& match_params);
77 void OnCacheBatch(int thread_id,
78 int request_id,
79 int cache_id,
80 const std::vector<CacheStorageBatchOperation>& operations);
81 void OnCacheClosed(int cache_id);
82 void OnBlobDataHandled(const std::string& uuid);
84 // CacheStorageManager callbacks
85 void OnCacheStorageHasCallback(int thread_id,
86 int request_id,
87 bool has_cache,
88 CacheStorageError error);
89 void OnCacheStorageOpenCallback(int thread_id,
90 int request_id,
91 const scoped_refptr<CacheStorageCache>& cache,
92 CacheStorageError error);
93 void OnCacheStorageDeleteCallback(int thread_id,
94 int request_id,
95 bool deleted,
96 CacheStorageError error);
97 void OnCacheStorageKeysCallback(int thread_id,
98 int request_id,
99 const std::vector<std::string>& strings,
100 CacheStorageError error);
101 void OnCacheStorageMatchCallback(
102 int thread_id,
103 int request_id,
104 CacheStorageError error,
105 scoped_ptr<ServiceWorkerResponse> response,
106 scoped_ptr<storage::BlobDataHandle> blob_data_handle);
108 // Cache callbacks.
109 void OnCacheMatchCallback(
110 int thread_id,
111 int request_id,
112 const scoped_refptr<CacheStorageCache>& cache,
113 CacheStorageError error,
114 scoped_ptr<ServiceWorkerResponse> response,
115 scoped_ptr<storage::BlobDataHandle> blob_data_handle);
116 void OnCacheMatchAll(int thread_id,
117 int request_id,
118 int cache_id,
119 const ServiceWorkerFetchRequest& request,
120 const CacheStorageCacheQueryParams& match_params);
121 void OnCacheKeysCallback(int thread_id,
122 int request_id,
123 const scoped_refptr<CacheStorageCache>& cache,
124 CacheStorageError error,
125 scoped_ptr<CacheStorageCache::Requests> requests);
126 void OnCacheBatchCallback(int thread_id,
127 int request_id,
128 const scoped_refptr<CacheStorageCache>& cache,
129 CacheStorageError error);
131 // Hangs onto a scoped_refptr for the cache if it isn't already doing so.
132 // Returns a unique cache_id. Call DropCacheReference when the client is done
133 // with this cache.
134 CacheID StoreCacheReference(const scoped_refptr<CacheStorageCache>& cache);
135 void DropCacheReference(CacheID cache_id);
137 // Stores blob handles while waiting for acknowledgement of receipt from the
138 // renderer.
139 void StoreBlobDataHandle(
140 scoped_ptr<storage::BlobDataHandle> blob_data_handle);
141 void DropBlobDataHandle(std::string uuid);
143 IDToCacheMap id_to_cache_map_;
144 CacheID next_cache_id_ = 0;
146 UUIDToBlobDataHandleList blob_handle_store_;
148 scoped_refptr<CacheStorageContextImpl> context_;
150 DISALLOW_COPY_AND_ASSIGN(CacheStorageDispatcherHost);
153 } // namespace content
155 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_HOST_H_