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 #include "content/browser/shared_worker/shared_worker_host.h" | 5 #include "content/browser/shared_worker/shared_worker_host.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "content/browser/devtools/shared_worker_devtools_manager.h" | 8 #include "content/browser/devtools/shared_worker_devtools_manager.h" |
9 #include "content/browser/message_port_message_filter.h" | 9 #include "content/browser/message_port_message_filter.h" |
10 #include "content/browser/message_port_service.h" | 10 #include "content/browser/message_port_service.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 int render_frame_id) { | 123 int render_frame_id) { |
124 // Walk all instances and remove all the documents in the frame from their | 124 // Walk all instances and remove all the documents in the frame from their |
125 // document set. | 125 // document set. |
126 worker_document_set_->RemoveRenderFrame(render_process_id, render_frame_id); | 126 worker_document_set_->RemoveRenderFrame(render_process_id, render_frame_id); |
127 if (worker_document_set_->IsEmpty()) { | 127 if (worker_document_set_->IsEmpty()) { |
128 // This worker has no more associated documents - shut it down. | 128 // This worker has no more associated documents - shut it down. |
129 TerminateWorker(); | 129 TerminateWorker(); |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
| 133 void SharedWorkerHost::CountFeature(uint32_t feature) { |
| 134 if (!use_counter_.insert(feature).second) |
| 135 return; |
| 136 for (const auto& filter_info : filters_) { |
| 137 filter_info.filter()->Send(new ViewMsg_CountFeatureOnSharedWorker( |
| 138 filter_info.route_id(), feature)); |
| 139 } |
| 140 } |
| 141 |
133 void SharedWorkerHost::WorkerContextClosed() { | 142 void SharedWorkerHost::WorkerContextClosed() { |
134 // Set the closed flag - this will stop any further messages from | 143 // Set the closed flag - this will stop any further messages from |
135 // being sent to the worker (messages can still be sent from the worker, | 144 // being sent to the worker (messages can still be sent from the worker, |
136 // for exception reporting, etc). | 145 // for exception reporting, etc). |
137 closed_ = true; | 146 closed_ = true; |
138 if (!termination_message_sent_) | 147 if (!termination_message_sent_) |
139 NotifyWorkerDestroyed(worker_process_id_, worker_route_id_); | 148 NotifyWorkerDestroyed(worker_process_id_, worker_route_id_); |
140 } | 149 } |
141 | 150 |
| 151 void SharedWorkerHost::WorkerContextDestroyed() { |
| 152 for (const auto& filter_info : filters_) { |
| 153 filter_info.filter()->Send( |
| 154 new ViewMsg_WorkerDestroyed(filter_info.route_id())); |
| 155 } |
| 156 } |
| 157 |
142 void SharedWorkerHost::WorkerReadyForInspection() { | 158 void SharedWorkerHost::WorkerReadyForInspection() { |
143 NotifyWorkerReadyForInspection(worker_process_id_, worker_route_id_); | 159 NotifyWorkerReadyForInspection(worker_process_id_, worker_route_id_); |
144 } | 160 } |
145 | 161 |
146 void SharedWorkerHost::WorkerScriptLoaded() { | 162 void SharedWorkerHost::WorkerScriptLoaded() { |
147 UMA_HISTOGRAM_TIMES("SharedWorker.TimeToScriptLoaded", | 163 UMA_HISTOGRAM_TIMES("SharedWorker.TimeToScriptLoaded", |
148 base::TimeTicks::Now() - creation_time_); | 164 base::TimeTicks::Now() - creation_time_); |
149 } | 165 } |
150 | 166 |
151 void SharedWorkerHost::WorkerScriptLoadFailed() { | 167 void SharedWorkerHost::WorkerScriptLoadFailed() { |
152 UMA_HISTOGRAM_TIMES("SharedWorker.TimeToScriptLoadFailed", | 168 UMA_HISTOGRAM_TIMES("SharedWorker.TimeToScriptLoadFailed", |
153 base::TimeTicks::Now() - creation_time_); | 169 base::TimeTicks::Now() - creation_time_); |
154 for (const FilterInfo& info : filters_) | 170 for (const FilterInfo& info : filters_) |
155 info.filter()->Send(new ViewMsg_WorkerScriptLoadFailed(info.route_id())); | 171 info.filter()->Send(new ViewMsg_WorkerScriptLoadFailed(info.route_id())); |
156 } | 172 } |
157 | 173 |
158 void SharedWorkerHost::WorkerConnected(int message_port_id) { | 174 void SharedWorkerHost::WorkerConnected(int message_port_id) { |
159 for (const FilterInfo& info : filters_) { | 175 for (const FilterInfo& info : filters_) { |
160 if (info.message_port_id() != message_port_id) | 176 if (info.message_port_id() != message_port_id) |
161 continue; | 177 continue; |
162 info.filter()->Send(new ViewMsg_WorkerConnected(info.route_id())); | 178 info.filter()->Send( |
| 179 new ViewMsg_WorkerConnected(info.route_id(), use_counter_)); |
163 return; | 180 return; |
164 } | 181 } |
165 } | 182 } |
166 | 183 |
167 void SharedWorkerHost::AllowFileSystem( | 184 void SharedWorkerHost::AllowFileSystem( |
168 const GURL& url, | 185 const GURL& url, |
169 std::unique_ptr<IPC::Message> reply_msg) { | 186 std::unique_ptr<IPC::Message> reply_msg) { |
170 GetContentClient()->browser()->AllowWorkerFileSystem( | 187 GetContentClient()->browser()->AllowWorkerFileSystem( |
171 url, | 188 url, |
172 instance_->resource_context(), | 189 instance_->resource_context(), |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 return; | 288 return; |
272 } | 289 } |
273 } | 290 } |
274 } | 291 } |
275 | 292 |
276 bool SharedWorkerHost::Send(IPC::Message* message) { | 293 bool SharedWorkerHost::Send(IPC::Message* message) { |
277 return worker_render_filter_->Send(message); | 294 return worker_render_filter_->Send(message); |
278 } | 295 } |
279 | 296 |
280 } // namespace content | 297 } // namespace content |
OLD | NEW |