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 "content/browser/worker_host/worker_storage_partition.h" | 8 #include "content/browser/worker_host/worker_storage_partition.h" |
9 #include "content/common/content_export.h" | |
10 #include "content/public/browser/browser_message_filter.h" | 9 #include "content/public/browser/browser_message_filter.h" |
11 | 10 |
12 class GURL; | 11 class GURL; |
13 struct ViewHostMsg_CreateWorker_Params; | 12 struct ViewHostMsg_CreateWorker_Params; |
14 | 13 |
15 namespace content { | 14 namespace content { |
16 class MessagePortMessageFilter; | 15 class MessagePortMessageFilter; |
17 class ResourceContext; | 16 class ResourceContext; |
18 | 17 |
19 // If "enable-embedded-shared-worker" is set this class will be used instead of | 18 // If "enable-embedded-shared-worker" is set this class will be used instead of |
20 // WorkerMessageFilter. | 19 // WorkerMessageFilter. |
21 class CONTENT_EXPORT SharedWorkerMessageFilter : public BrowserMessageFilter { | 20 class SharedWorkerMessageFilter : public BrowserMessageFilter { |
22 public: | 21 public: |
23 SharedWorkerMessageFilter(int render_process_id, | 22 SharedWorkerMessageFilter(int render_process_id, |
24 ResourceContext* resource_context, | 23 ResourceContext* resource_context, |
25 const WorkerStoragePartition& partition, | 24 const WorkerStoragePartition& partition, |
26 MessagePortMessageFilter* message_port_filter); | 25 MessagePortMessageFilter* message_port_filter); |
27 | 26 |
28 // BrowserMessageFilter implementation. | 27 // BrowserMessageFilter implementation. |
29 virtual void OnChannelClosing() OVERRIDE; | 28 virtual void OnChannelClosing() OVERRIDE; |
30 virtual bool OnMessageReceived(const IPC::Message& message, | 29 virtual bool OnMessageReceived(const IPC::Message& message, |
31 bool* message_was_ok) OVERRIDE; | 30 bool* message_was_ok) OVERRIDE; |
32 | 31 |
33 int GetNextRoutingID(); | 32 int GetNextRoutingID(); |
34 int render_process_id() const { return render_process_id_; } | 33 int render_process_id() const { return render_process_id_; } |
35 | 34 |
36 MessagePortMessageFilter* message_port_message_filter() const { | 35 MessagePortMessageFilter* message_port_message_filter() const { |
37 return message_port_message_filter_; | 36 return message_port_message_filter_; |
38 } | 37 } |
39 | 38 |
40 protected: | 39 private: |
41 // This is protected, so we can define sub classes for testing. | |
42 virtual ~SharedWorkerMessageFilter(); | 40 virtual ~SharedWorkerMessageFilter(); |
43 | 41 |
44 private: | |
45 // Message handlers. | 42 // Message handlers. |
46 void OnCreateWorker(const ViewHostMsg_CreateWorker_Params& params, | 43 void OnCreateWorker(const ViewHostMsg_CreateWorker_Params& params, |
47 int* route_id); | 44 int* route_id); |
48 void OnForwardToWorker(const IPC::Message& message); | 45 void OnForwardToWorker(const IPC::Message& message); |
49 void OnDocumentDetached(unsigned long long document_id); | 46 void OnDocumentDetached(unsigned long long document_id); |
50 void OnWorkerContextClosed(int worker_route_id); | 47 void OnWorkerContextClosed(int worker_route_id); |
51 void OnWorkerContextDestroyed(int worker_route_id); | 48 void OnWorkerContextDestroyed(int worker_route_id); |
52 void OnWorkerScriptLoaded(int worker_route_id); | 49 void OnWorkerScriptLoaded(int worker_route_id); |
53 void OnWorkerScriptLoadFailed(int worker_route_id); | 50 void OnWorkerScriptLoadFailed(int worker_route_id); |
54 void OnWorkerConnected(int message_port_id, int worker_route_id); | 51 void OnWorkerConnected(int message_port_id, int worker_route_id); |
(...skipping 15 matching lines...) Expand all Loading... |
70 ResourceContext* const resource_context_; | 67 ResourceContext* const resource_context_; |
71 const WorkerStoragePartition partition_; | 68 const WorkerStoragePartition partition_; |
72 MessagePortMessageFilter* const message_port_message_filter_; | 69 MessagePortMessageFilter* const message_port_message_filter_; |
73 | 70 |
74 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedWorkerMessageFilter); | 71 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedWorkerMessageFilter); |
75 }; | 72 }; |
76 | 73 |
77 } // namespace content | 74 } // namespace content |
78 | 75 |
79 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_MESSAGE_FILTER_H_ | 76 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_MESSAGE_FILTER_H_ |
OLD | NEW |