1 // Copyright (c) 2011 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_WORKER_HOST_WORKER_MESSAGE_FILTER_H_
6 #define CONTENT_BROWSER_WORKER_HOST_WORKER_MESSAGE_FILTER_H_
8 #include "base/callback.h"
9 #include "content/browser/worker_host/worker_storage_partition.h"
10 #include "content/public/browser/browser_message_filter.h"
12 class ResourceDispatcherHost;
13 struct ViewHostMsg_CreateWorker_Params;
16 class MessagePortMessageFilter;
17 class ResourceContext;
19 class WorkerMessageFilter : public BrowserMessageFilter {
21 WorkerMessageFilter(int render_process_id,
22 ResourceContext* resource_context,
23 const WorkerStoragePartition& partition,
24 MessagePortMessageFilter* message_port_filter);
26 // BrowserMessageFilter implementation.
27 virtual void OnChannelClosing() OVERRIDE;
28 virtual bool OnMessageReceived(const IPC::Message& message,
29 bool* message_was_ok) OVERRIDE;
31 int GetNextRoutingID();
32 int render_process_id() const { return render_process_id_; }
34 MessagePortMessageFilter* message_port_message_filter() const {
35 return message_port_message_filter_;
39 virtual ~WorkerMessageFilter();
42 void OnCreateWorker(const ViewHostMsg_CreateWorker_Params& params,
44 void OnLookupSharedWorker(const ViewHostMsg_CreateWorker_Params& params,
48 void OnForwardToWorker(const IPC::Message& message);
49 void OnDocumentDetached(unsigned long long document_id);
50 void OnCreateMessagePort(int* route_id, int* message_port_id);
52 int render_process_id_;
53 ResourceContext* const resource_context_;
54 WorkerStoragePartition partition_;
56 MessagePortMessageFilter* message_port_message_filter_;
57 DISALLOW_IMPLICIT_CONSTRUCTORS(WorkerMessageFilter);
60 } // namespace content
62 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_MESSAGE_FILTER_H_