Simplify ChildProcessLauncher
[chromium-blink-merge.git] / content / browser / service_worker / cache_storage_dispatcher_host.cc
blobdb258329c6af5303631e016983a5b59996889257
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 #include "content/browser/service_worker/cache_storage_dispatcher_host.h"
7 #include "base/logging.h"
8 #include "content/browser/service_worker/cache_storage_context_impl.h"
9 #include "content/browser/service_worker/service_worker_cache_listener.h"
10 #include "content/common/service_worker/cache_storage_messages.h"
11 #include "content/public/browser/content_browser_client.h"
13 namespace content {
15 namespace {
17 const uint32 kFilteredMessageClasses[] = {CacheStorageMsgStart};
19 } // namespace
21 CacheStorageDispatcherHost::CacheStorageDispatcherHost()
22 : BrowserMessageFilter(kFilteredMessageClasses,
23 arraysize(kFilteredMessageClasses)) {
26 CacheStorageDispatcherHost::~CacheStorageDispatcherHost() {
29 void CacheStorageDispatcherHost::Init(CacheStorageContextImpl* context) {
30 DCHECK_CURRENTLY_ON(BrowserThread::UI);
31 BrowserThread::PostTask(
32 BrowserThread::IO, FROM_HERE,
33 base::Bind(&CacheStorageDispatcherHost::CreateCacheListener, this,
34 make_scoped_refptr(context)));
37 void CacheStorageDispatcherHost::OnDestruct() const {
38 BrowserThread::DeleteOnIOThread::Destruct(this);
41 bool CacheStorageDispatcherHost::OnMessageReceived(
42 const IPC::Message& message) {
43 DCHECK_CURRENTLY_ON(BrowserThread::IO);
44 DCHECK(cache_listener_);
45 bool handled = cache_listener_->OnMessageReceived(message);
46 if (!handled)
47 BadMessageReceived();
48 return handled;
51 void CacheStorageDispatcherHost::CreateCacheListener(
52 CacheStorageContextImpl* context) {
53 DCHECK_CURRENTLY_ON(BrowserThread::IO);
54 cache_listener_.reset(new ServiceWorkerCacheListener(this, context));
57 } // namespace content