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 "content/browser/frame_host/render_frame_host_delegate.h" | 8 #include "content/browser/frame_host/render_frame_host_delegate.h" |
8 #include "content/browser/frame_host/render_frame_host_impl.h" | 9 #include "content/browser/frame_host/render_frame_host_impl.h" |
9 #include "content/browser/message_port_service.h" | 10 #include "content/browser/message_port_service.h" |
10 #include "content/browser/shared_worker/shared_worker_instance.h" | 11 #include "content/browser/shared_worker/shared_worker_instance.h" |
11 #include "content/browser/shared_worker/shared_worker_message_filter.h" | 12 #include "content/browser/shared_worker/shared_worker_message_filter.h" |
12 #include "content/common/view_messages.h" | 13 #include "content/common/view_messages.h" |
13 #include "content/common/worker_messages.h" | 14 #include "content/common/worker_messages.h" |
14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/content_browser_client.h" | 16 #include "content/public/browser/content_browser_client.h" |
16 #include "content/public/common/content_client.h" | 17 #include "content/public/common/content_client.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 namespace { | 20 namespace { |
20 | 21 |
21 // Notifies RenderViewHost that one or more worker objects crashed. | 22 // Notifies RenderViewHost that one or more worker objects crashed. |
22 void WorkerCrashCallback(int render_process_unique_id, int render_frame_id) { | 23 void WorkerCrashCallback(int render_process_unique_id, int render_frame_id) { |
23 RenderFrameHostImpl* host = | 24 RenderFrameHostImpl* host = |
24 RenderFrameHostImpl::FromID(render_process_unique_id, render_frame_id); | 25 RenderFrameHostImpl::FromID(render_process_unique_id, render_frame_id); |
25 if (host) | 26 if (host) |
26 host->delegate()->WorkerCrashed(host); | 27 host->delegate()->WorkerCrashed(host); |
27 } | 28 } |
28 | 29 |
29 } // namespace | 30 } // namespace |
30 | 31 |
31 SharedWorkerHost::SharedWorkerHost(SharedWorkerInstance* instance) | 32 SharedWorkerHost::SharedWorkerHost(SharedWorkerInstance* instance) |
32 : instance_(instance), | 33 : instance_(instance), |
33 container_render_filter_(NULL), | 34 container_render_filter_(NULL), |
34 worker_route_id_(MSG_ROUTING_NONE) { | 35 worker_route_id_(MSG_ROUTING_NONE), |
| 36 creation_time_(base::TimeTicks::Now()) { |
35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
36 } | 38 } |
37 | 39 |
38 SharedWorkerHost::~SharedWorkerHost() { | 40 SharedWorkerHost::~SharedWorkerHost() { |
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 42 UMA_HISTOGRAM_LONG_TIMES("SharedWorker.TimeToDeleted", |
| 43 base::TimeTicks::Now() - creation_time_); |
40 // If we crashed, tell the RenderViewHosts. | 44 // If we crashed, tell the RenderViewHosts. |
41 if (instance_ && !instance_->load_failed()) { | 45 if (instance_ && !instance_->load_failed()) { |
42 const WorkerDocumentSet::DocumentInfoSet& parents = | 46 const WorkerDocumentSet::DocumentInfoSet& parents = |
43 instance_->worker_document_set()->documents(); | 47 instance_->worker_document_set()->documents(); |
44 for (WorkerDocumentSet::DocumentInfoSet::const_iterator parent_iter = | 48 for (WorkerDocumentSet::DocumentInfoSet::const_iterator parent_iter = |
45 parents.begin(); | 49 parents.begin(); |
46 parent_iter != parents.end(); | 50 parent_iter != parents.end(); |
47 ++parent_iter) { | 51 ++parent_iter) { |
48 BrowserThread::PostTask(BrowserThread::UI, | 52 BrowserThread::PostTask(BrowserThread::UI, |
49 FROM_HERE, | 53 FROM_HERE, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 134 } |
131 | 135 |
132 void SharedWorkerHost::WorkerContextDestroyed() { | 136 void SharedWorkerHost::WorkerContextDestroyed() { |
133 if (!instance_) | 137 if (!instance_) |
134 return; | 138 return; |
135 instance_.reset(); | 139 instance_.reset(); |
136 } | 140 } |
137 | 141 |
138 void SharedWorkerHost::WorkerScriptLoaded() { | 142 void SharedWorkerHost::WorkerScriptLoaded() { |
139 // TODO(horo): implement this. | 143 // TODO(horo): implement this. |
| 144 UMA_HISTOGRAM_TIMES("SharedWorker.TimeToScriptLoaded", |
| 145 base::TimeTicks::Now() - creation_time_); |
140 } | 146 } |
141 | 147 |
142 void SharedWorkerHost::WorkerScriptLoadFailed() { | 148 void SharedWorkerHost::WorkerScriptLoadFailed() { |
| 149 UMA_HISTOGRAM_TIMES("SharedWorker.TimeToScriptLoadFailed", |
| 150 base::TimeTicks::Now() - creation_time_); |
143 if (!instance_) | 151 if (!instance_) |
144 return; | 152 return; |
145 instance_->set_load_failed(true); | 153 instance_->set_load_failed(true); |
146 for (SharedWorkerInstance::FilterList::const_iterator i = | 154 for (SharedWorkerInstance::FilterList::const_iterator i = |
147 instance_->filters().begin(); | 155 instance_->filters().begin(); |
148 i != instance_->filters().end(); ++i) { | 156 i != instance_->filters().end(); ++i) { |
149 i->filter()->Send(new ViewMsg_WorkerScriptLoadFailed(i->route_id())); | 157 i->filter()->Send(new ViewMsg_WorkerScriptLoadFailed(i->route_id())); |
150 } | 158 } |
151 } | 159 } |
152 | 160 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 documents.begin(); | 256 documents.begin(); |
249 doc != documents.end(); | 257 doc != documents.end(); |
250 ++doc) { | 258 ++doc) { |
251 result.push_back( | 259 result.push_back( |
252 std::make_pair(doc->render_process_id(), doc->render_frame_id())); | 260 std::make_pair(doc->render_process_id(), doc->render_frame_id())); |
253 } | 261 } |
254 return result; | 262 return result; |
255 } | 263 } |
256 | 264 |
257 } // namespace content | 265 } // namespace content |
OLD | NEW |