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"
17 const uint32 kFilteredMessageClasses
[] = {CacheStorageMsgStart
};
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
);
51 void CacheStorageDispatcherHost::CreateCacheListener(
52 CacheStorageContextImpl
* context
) {
53 DCHECK_CURRENTLY_ON(BrowserThread::IO
);
54 cache_listener_
.reset(new ServiceWorkerCacheListener(this, context
));
57 } // namespace content