Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / browser / cache_storage / cache_storage_dispatcher_host.h
blobb922f234f517bc21aee7b72d312ca19b03ee0a53
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 "content/public/browser/browser_message_filter.h"
10 namespace content {
12 class CacheStorageContextImpl;
13 class CacheStorageListener;
15 // Handles Cache Storage related messages sent to the browser process from
16 // child processes. One host instance exists per child process. All
17 // messages are processed on the IO thread. Currently, all messages are
18 // passed directly to the owned CacheStorageListener instance, which
19 // in turn dispatches calls to the CacheStorageManager owned
20 // by the CacheStorageContextImpl for the entire browsing context.
21 // TODO(jsbell): Merge this with CacheStorageListener crbug.com/439389
22 class CONTENT_EXPORT CacheStorageDispatcherHost : public BrowserMessageFilter {
23 public:
24 CacheStorageDispatcherHost();
26 // Runs on UI thread.
27 void Init(CacheStorageContextImpl* context);
29 // BrowserMessageFilter implementation
30 void OnDestruct() const override;
31 bool OnMessageReceived(const IPC::Message& message) override;
33 private:
34 // Friends to allow OnDestruct() delegation
35 friend class BrowserThread;
36 friend class base::DeleteHelper<CacheStorageDispatcherHost>;
38 ~CacheStorageDispatcherHost() override;
40 // Called by Init() on IO thread.
41 void CreateCacheListener(CacheStorageContextImpl* context);
43 scoped_ptr<CacheStorageListener> cache_listener_;
45 DISALLOW_COPY_AND_ASSIGN(CacheStorageDispatcherHost);
48 } // namespace content
50 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_HOST_H_