OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_MESSAGE_FILTER_H_ | 5 #ifndef CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_MESSAGE_FILTER_H_ |
6 #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_MESSAGE_FILTER_H_ | 6 #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_MESSAGE_FILTER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "content/browser/shared_worker/worker_storage_partition.h" | 9 #include "content/browser/shared_worker/worker_storage_partition.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
11 #include "content/public/browser/browser_message_filter.h" | 11 #include "content/public/browser/browser_message_filter.h" |
12 | 12 |
13 class GURL; | 13 class GURL; |
14 struct ViewHostMsg_CreateWorker_Params; | 14 struct ViewHostMsg_CreateWorker_Params; |
15 struct ViewHostMsg_CreateWorker_Reply; | 15 struct ViewHostMsg_CreateWorker_Reply; |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 class MessagePortMessageFilter; | |
19 class ResourceContext; | 18 class ResourceContext; |
20 | 19 |
21 // Handles SharedWorker related IPC messages for one renderer process by | 20 // Handles SharedWorker related IPC messages for one renderer process by |
22 // forwarding them to the SharedWorkerServiceImpl singleton. | 21 // forwarding them to the SharedWorkerServiceImpl singleton. |
23 class CONTENT_EXPORT SharedWorkerMessageFilter : public BrowserMessageFilter { | 22 class CONTENT_EXPORT SharedWorkerMessageFilter : public BrowserMessageFilter { |
24 public: | 23 public: |
24 typedef base::Callback<int(void)> NextRoutingIDCallback; | |
kinuko
2017/02/08 09:45:06
nit: using NextRoutingIDCallback = base::Callback<
| |
25 | |
25 SharedWorkerMessageFilter(int render_process_id, | 26 SharedWorkerMessageFilter(int render_process_id, |
26 ResourceContext* resource_context, | 27 ResourceContext* resource_context, |
27 const WorkerStoragePartition& partition, | 28 const WorkerStoragePartition& partition, |
28 MessagePortMessageFilter* message_port_filter); | 29 const NextRoutingIDCallback& callback); |
29 | 30 |
30 // BrowserMessageFilter implementation. | 31 // BrowserMessageFilter implementation. |
31 void OnChannelClosing() override; | 32 void OnChannelClosing() override; |
32 bool OnMessageReceived(const IPC::Message& message) override; | 33 bool OnMessageReceived(const IPC::Message& message) override; |
33 | 34 |
34 int GetNextRoutingID(); | 35 int GetNextRoutingID(); |
35 int render_process_id() const { return render_process_id_; } | 36 int render_process_id() const { return render_process_id_; } |
36 | 37 |
37 MessagePortMessageFilter* message_port_message_filter() const { | |
38 return message_port_message_filter_; | |
39 } | |
40 | |
41 protected: | 38 protected: |
42 // This is protected, so we can define sub classes for testing. | 39 // This is protected, so we can define sub classes for testing. |
43 ~SharedWorkerMessageFilter() override; | 40 ~SharedWorkerMessageFilter() override; |
44 | 41 |
45 private: | 42 private: |
46 // Message handlers. | 43 // Message handlers. |
47 void OnCreateWorker(const ViewHostMsg_CreateWorker_Params& params, | 44 void OnCreateWorker(const ViewHostMsg_CreateWorker_Params& params, |
48 ViewHostMsg_CreateWorker_Reply* reply); | 45 ViewHostMsg_CreateWorker_Reply* reply); |
49 void OnRequestFileSystemAccess(int worker_route_id, | 46 void OnRequestFileSystemAccess(int worker_route_id, |
50 const GURL& url, | 47 const GURL& url, |
51 IPC::Message* reply_msg); | 48 IPC::Message* reply_msg); |
52 void OnAllowIndexedDB(int worker_route_id, | 49 void OnAllowIndexedDB(int worker_route_id, |
53 const GURL& url, | 50 const GURL& url, |
54 const base::string16& name, | 51 const base::string16& name, |
55 bool* result); | 52 bool* result); |
56 | 53 |
57 const int render_process_id_; | 54 const int render_process_id_; |
58 ResourceContext* const resource_context_; | 55 ResourceContext* const resource_context_; |
59 const WorkerStoragePartition partition_; | 56 const WorkerStoragePartition partition_; |
60 MessagePortMessageFilter* const message_port_message_filter_; | 57 NextRoutingIDCallback next_routing_id_callback_; |
61 | 58 |
62 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedWorkerMessageFilter); | 59 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedWorkerMessageFilter); |
63 }; | 60 }; |
64 | 61 |
65 } // namespace content | 62 } // namespace content |
66 | 63 |
67 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_MESSAGE_FILTER_H_ | 64 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_MESSAGE_FILTER_H_ |
OLD | NEW |