| 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.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "content/browser/devtools/embedded_worker_devtools_manager.h" | 8 #include "content/browser/devtools/embedded_worker_devtools_manager.h" |
| 9 #include "content/browser/frame_host/render_frame_host_delegate.h" | 9 #include "content/browser/frame_host/render_frame_host_delegate.h" |
| 10 #include "content/browser/frame_host/render_frame_host_impl.h" | 10 #include "content/browser/frame_host/render_frame_host_impl.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 FROM_HERE, | 38 FROM_HERE, |
| 39 base::Bind(NotifyWorkerReadyForInspection, | 39 base::Bind(NotifyWorkerReadyForInspection, |
| 40 worker_process_id, | 40 worker_process_id, |
| 41 worker_route_id)); | 41 worker_route_id)); |
| 42 return; | 42 return; |
| 43 } | 43 } |
| 44 EmbeddedWorkerDevToolsManager::GetInstance()->WorkerReadyForInspection( | 44 EmbeddedWorkerDevToolsManager::GetInstance()->WorkerReadyForInspection( |
| 45 worker_process_id, worker_route_id); | 45 worker_process_id, worker_route_id); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void NotifyWorkerContextStarted(int worker_process_id, int worker_route_id) { | |
| 49 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | |
| 50 BrowserThread::PostTask( | |
| 51 BrowserThread::UI, | |
| 52 FROM_HERE, | |
| 53 base::Bind( | |
| 54 NotifyWorkerContextStarted, worker_process_id, worker_route_id)); | |
| 55 return; | |
| 56 } | |
| 57 EmbeddedWorkerDevToolsManager::GetInstance()->WorkerContextStarted( | |
| 58 worker_process_id, worker_route_id); | |
| 59 } | |
| 60 | |
| 61 void NotifyWorkerDestroyed(int worker_process_id, int worker_route_id) { | 48 void NotifyWorkerDestroyed(int worker_process_id, int worker_route_id) { |
| 62 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 49 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 63 BrowserThread::PostTask( | 50 BrowserThread::PostTask( |
| 64 BrowserThread::UI, | 51 BrowserThread::UI, |
| 65 FROM_HERE, | 52 FROM_HERE, |
| 66 base::Bind(NotifyWorkerDestroyed, worker_process_id, worker_route_id)); | 53 base::Bind(NotifyWorkerDestroyed, worker_process_id, worker_route_id)); |
| 67 return; | 54 return; |
| 68 } | 55 } |
| 69 EmbeddedWorkerDevToolsManager::GetInstance()->WorkerDestroyed( | 56 EmbeddedWorkerDevToolsManager::GetInstance()->WorkerDestroyed( |
| 70 worker_process_id, worker_route_id); | 57 worker_process_id, worker_route_id); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 worker_document_set_ = NULL; | 176 worker_document_set_ = NULL; |
| 190 } | 177 } |
| 191 | 178 |
| 192 void SharedWorkerHost::WorkerReadyForInspection() { | 179 void SharedWorkerHost::WorkerReadyForInspection() { |
| 193 NotifyWorkerReadyForInspection(worker_process_id_, worker_route_id_); | 180 NotifyWorkerReadyForInspection(worker_process_id_, worker_route_id_); |
| 194 } | 181 } |
| 195 | 182 |
| 196 void SharedWorkerHost::WorkerScriptLoaded() { | 183 void SharedWorkerHost::WorkerScriptLoaded() { |
| 197 UMA_HISTOGRAM_TIMES("SharedWorker.TimeToScriptLoaded", | 184 UMA_HISTOGRAM_TIMES("SharedWorker.TimeToScriptLoaded", |
| 198 base::TimeTicks::Now() - creation_time_); | 185 base::TimeTicks::Now() - creation_time_); |
| 199 NotifyWorkerContextStarted(worker_process_id_, worker_route_id_); | |
| 200 } | 186 } |
| 201 | 187 |
| 202 void SharedWorkerHost::WorkerScriptLoadFailed() { | 188 void SharedWorkerHost::WorkerScriptLoadFailed() { |
| 203 UMA_HISTOGRAM_TIMES("SharedWorker.TimeToScriptLoadFailed", | 189 UMA_HISTOGRAM_TIMES("SharedWorker.TimeToScriptLoadFailed", |
| 204 base::TimeTicks::Now() - creation_time_); | 190 base::TimeTicks::Now() - creation_time_); |
| 205 if (!instance_) | 191 if (!instance_) |
| 206 return; | 192 return; |
| 207 load_failed_ = true; | 193 load_failed_ = true; |
| 208 for (FilterList::const_iterator i = filters_.begin(); i != filters_.end(); | 194 for (FilterList::const_iterator i = filters_.begin(); i != filters_.end(); |
| 209 ++i) { | 195 ++i) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 int message_port_id) { | 346 int message_port_id) { |
| 361 for (FilterList::iterator i = filters_.begin(); i != filters_.end(); ++i) { | 347 for (FilterList::iterator i = filters_.begin(); i != filters_.end(); ++i) { |
| 362 if (i->filter() == filter && i->route_id() == route_id) { | 348 if (i->filter() == filter && i->route_id() == route_id) { |
| 363 i->set_message_port_id(message_port_id); | 349 i->set_message_port_id(message_port_id); |
| 364 return; | 350 return; |
| 365 } | 351 } |
| 366 } | 352 } |
| 367 } | 353 } |
| 368 | 354 |
| 369 } // namespace content | 355 } // namespace content |
| OLD | NEW |