Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / content / browser / worker_host / worker_message_filter.h
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.
4
5 #ifndef CONTENT_BROWSER_WORKER_HOST_WORKER_MESSAGE_FILTER_H_
6 #define CONTENT_BROWSER_WORKER_HOST_WORKER_MESSAGE_FILTER_H_
7
8 #include "base/callback.h"
9 #include "content/browser/worker_host/worker_storage_partition.h"
10 #include "content/public/browser/browser_message_filter.h"
11
12 class ResourceDispatcherHost;
13 struct ViewHostMsg_CreateWorker_Params;
14
15 namespace content {
16 class MessagePortMessageFilter;
17 class ResourceContext;
18
19 class WorkerMessageFilter : public BrowserMessageFilter {
20  public:
21   WorkerMessageFilter(int render_process_id,
22                       ResourceContext* resource_context,
23                       const WorkerStoragePartition& partition,
24                       MessagePortMessageFilter* message_port_filter);
25
26   // BrowserMessageFilter implementation.
27   virtual void OnChannelClosing() OVERRIDE;
28   virtual bool OnMessageReceived(const IPC::Message& message,
29                                  bool* message_was_ok) OVERRIDE;
30
31   int GetNextRoutingID();
32   int render_process_id() const { return render_process_id_; }
33
34   MessagePortMessageFilter* message_port_message_filter() const {
35     return message_port_message_filter_;
36   }
37
38  private:
39   virtual ~WorkerMessageFilter();
40
41   // Message handlers.
42   void OnCreateWorker(const ViewHostMsg_CreateWorker_Params& params,
43                       int* route_id);
44   void OnForwardToWorker(const IPC::Message& message);
45   void OnDocumentDetached(unsigned long long document_id);
46   void OnCreateMessagePort(int* route_id, int* message_port_id);
47
48   int render_process_id_;
49   ResourceContext* const resource_context_;
50   WorkerStoragePartition partition_;
51
52   MessagePortMessageFilter* message_port_message_filter_;
53   DISALLOW_IMPLICIT_CONSTRUCTORS(WorkerMessageFilter);
54 };
55
56 }  // namespace content
57
58 #endif  // CONTENT_BROWSER_WORKER_HOST_WORKER_MESSAGE_FILTER_H_