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_HOST_H_ | 5 #ifndef CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_HOST_H_ |
6 #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_HOST_H_ | 6 #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_HOST_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 } | 21 } |
22 | 22 |
23 namespace content { | 23 namespace content { |
24 class SharedWorkerMessageFilter; | 24 class SharedWorkerMessageFilter; |
25 class SharedWorkerInstance; | 25 class SharedWorkerInstance; |
26 | 26 |
27 // The SharedWorkerHost is the interface that represents the browser side of | 27 // The SharedWorkerHost is the interface that represents the browser side of |
28 // the browser <-> worker communication channel. | 28 // the browser <-> worker communication channel. |
29 class SharedWorkerHost { | 29 class SharedWorkerHost { |
30 public: | 30 public: |
31 SharedWorkerHost(SharedWorkerInstance* instance, | 31 explicit SharedWorkerHost(SharedWorkerInstance* instance); |
32 SharedWorkerMessageFilter* filter); | |
33 ~SharedWorkerHost(); | 32 ~SharedWorkerHost(); |
34 | 33 |
35 // Sends |message| to the SharedWorker. | 34 // Sends |message| to the SharedWorker. |
36 bool Send(IPC::Message* message); | 35 bool Send(IPC::Message* message); |
37 | 36 |
38 // Starts the SharedWorker in the renderer process which is associated with | 37 // Starts the SharedWorker in the renderer process which is associated with |
39 // |filter_|. | 38 // |filter|. |
40 void Start(bool pause_on_start); | 39 void Init(SharedWorkerMessageFilter* filter); |
41 | 40 |
42 // Returns true iff the given message from a renderer process was forwarded to | 41 // Returns true iff the given message from a renderer process was forwarded to |
43 // the worker. | 42 // the worker. |
44 bool FilterMessage(const IPC::Message& message, | 43 bool FilterMessage(const IPC::Message& message, |
45 SharedWorkerMessageFilter* filter); | 44 SharedWorkerMessageFilter* filter); |
46 | 45 |
47 // Handles the shutdown of the filter. If the worker has no other client, | 46 // Handles the shutdown of the filter. If the worker has no other client, |
48 // sends TerminateWorkerContext message to shut it down. | 47 // sends TerminateWorkerContext message to shut it down. |
49 void FilterShutdown(SharedWorkerMessageFilter* filter); | 48 void FilterShutdown(SharedWorkerMessageFilter* filter); |
50 | 49 |
(...skipping 22 matching lines...) Expand all Loading... |
73 | 72 |
74 void AddFilter(SharedWorkerMessageFilter* filter, int route_id); | 73 void AddFilter(SharedWorkerMessageFilter* filter, int route_id); |
75 | 74 |
76 SharedWorkerInstance* instance() { return instance_.get(); } | 75 SharedWorkerInstance* instance() { return instance_.get(); } |
77 WorkerDocumentSet* worker_document_set() const { | 76 WorkerDocumentSet* worker_document_set() const { |
78 return worker_document_set_.get(); | 77 return worker_document_set_.get(); |
79 } | 78 } |
80 SharedWorkerMessageFilter* container_render_filter() const { | 79 SharedWorkerMessageFilter* container_render_filter() const { |
81 return container_render_filter_; | 80 return container_render_filter_; |
82 } | 81 } |
83 int process_id() const { return worker_process_id_; } | 82 int process_id() const { |
| 83 return container_render_filter_->render_process_id(); |
| 84 } |
84 int worker_route_id() const { return worker_route_id_; } | 85 int worker_route_id() const { return worker_route_id_; } |
85 bool load_failed() const { return load_failed_; } | 86 bool load_failed() const { return load_failed_; } |
86 bool closed() const { return closed_; } | 87 bool closed() const { return closed_; } |
87 | 88 |
88 private: | 89 private: |
89 // Unique identifier for a worker client. | 90 // Unique identifier for a worker client. |
90 class FilterInfo { | 91 class FilterInfo { |
91 public: | 92 public: |
92 FilterInfo(SharedWorkerMessageFilter* filter, int route_id) | 93 FilterInfo(SharedWorkerMessageFilter* filter, int route_id) |
93 : filter_(filter), route_id_(route_id), message_port_id_(0) {} | 94 : filter_(filter), route_id_(route_id), message_port_id_(0) {} |
(...skipping 21 matching lines...) Expand all Loading... |
115 void RemoveFilters(SharedWorkerMessageFilter* filter); | 116 void RemoveFilters(SharedWorkerMessageFilter* filter); |
116 bool HasFilter(SharedWorkerMessageFilter* filter, int route_id) const; | 117 bool HasFilter(SharedWorkerMessageFilter* filter, int route_id) const; |
117 void SetMessagePortID(SharedWorkerMessageFilter* filter, | 118 void SetMessagePortID(SharedWorkerMessageFilter* filter, |
118 int route_id, | 119 int route_id, |
119 int message_port_id); | 120 int message_port_id); |
120 | 121 |
121 scoped_ptr<SharedWorkerInstance> instance_; | 122 scoped_ptr<SharedWorkerInstance> instance_; |
122 scoped_refptr<WorkerDocumentSet> worker_document_set_; | 123 scoped_refptr<WorkerDocumentSet> worker_document_set_; |
123 FilterList filters_; | 124 FilterList filters_; |
124 SharedWorkerMessageFilter* container_render_filter_; | 125 SharedWorkerMessageFilter* container_render_filter_; |
125 int worker_process_id_; | |
126 int worker_route_id_; | 126 int worker_route_id_; |
127 bool load_failed_; | 127 bool load_failed_; |
128 bool closed_; | 128 bool closed_; |
129 const base::TimeTicks creation_time_; | 129 const base::TimeTicks creation_time_; |
130 DISALLOW_COPY_AND_ASSIGN(SharedWorkerHost); | 130 DISALLOW_COPY_AND_ASSIGN(SharedWorkerHost); |
131 }; | 131 }; |
132 } // namespace content | 132 } // namespace content |
133 | 133 |
134 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_HOST_H_ | 134 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_HOST_H_ |
OLD | NEW |