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/renderer/service_worker/service_worker_script_context.h" | 5 #include "content/renderer/service_worker/service_worker_script_context.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "content/child/thread_safe_sender.h" | 10 #include "content/child/thread_safe_sender.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 "ServiceWorker.FetchEventExecutionTime", | 124 "ServiceWorker.FetchEventExecutionTime", |
125 base::TimeTicks::Now() - fetch_start_timings_[request_id]); | 125 base::TimeTicks::Now() - fetch_start_timings_[request_id]); |
126 fetch_start_timings_.erase(request_id); | 126 fetch_start_timings_.erase(request_id); |
127 | 127 |
128 Send(new ServiceWorkerHostMsg_FetchEventFinished( | 128 Send(new ServiceWorkerHostMsg_FetchEventFinished( |
129 GetRoutingID(), request_id, result, response)); | 129 GetRoutingID(), request_id, result, response)); |
130 } | 130 } |
131 | 131 |
132 void ServiceWorkerScriptContext::DidHandlePushEvent( | 132 void ServiceWorkerScriptContext::DidHandlePushEvent( |
133 int request_id, | 133 int request_id, |
134 blink::WebServiceWorkerEventResult unused) { | 134 blink::WebServiceWorkerEventResult result) { |
135 // TODO(johnme): Plumb through the result. | 135 // TODO(johnme): Plumb through the result. |
| 136 if (result == blink::WebServiceWorkerEventResultCompleted) { |
| 137 UMA_HISTOGRAM_TIMES( |
| 138 "ServiceWorker.PushEventExecutionTime", |
| 139 base::TimeTicks::Now() - push_start_timings_[request_id]); |
| 140 } |
| 141 push_start_timings_.erase(request_id); |
| 142 |
136 Send(new ServiceWorkerHostMsg_PushEventFinished( | 143 Send(new ServiceWorkerHostMsg_PushEventFinished( |
137 GetRoutingID(), request_id)); | 144 GetRoutingID(), request_id)); |
138 } | 145 } |
139 | 146 |
140 void ServiceWorkerScriptContext::DidHandleSyncEvent(int request_id) { | 147 void ServiceWorkerScriptContext::DidHandleSyncEvent(int request_id) { |
141 Send(new ServiceWorkerHostMsg_SyncEventFinished( | 148 Send(new ServiceWorkerHostMsg_SyncEventFinished( |
142 GetRoutingID(), request_id)); | 149 GetRoutingID(), request_id)); |
143 } | 150 } |
144 | 151 |
145 void ServiceWorkerScriptContext::GetClientDocuments( | 152 void ServiceWorkerScriptContext::GetClientDocuments( |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 void ServiceWorkerScriptContext::OnSyncEvent(int request_id) { | 229 void ServiceWorkerScriptContext::OnSyncEvent(int request_id) { |
223 TRACE_EVENT0("ServiceWorker", | 230 TRACE_EVENT0("ServiceWorker", |
224 "ServiceWorkerScriptContext::OnSyncEvent"); | 231 "ServiceWorkerScriptContext::OnSyncEvent"); |
225 proxy_->dispatchSyncEvent(request_id); | 232 proxy_->dispatchSyncEvent(request_id); |
226 } | 233 } |
227 | 234 |
228 void ServiceWorkerScriptContext::OnPushEvent(int request_id, | 235 void ServiceWorkerScriptContext::OnPushEvent(int request_id, |
229 const std::string& data) { | 236 const std::string& data) { |
230 TRACE_EVENT0("ServiceWorker", | 237 TRACE_EVENT0("ServiceWorker", |
231 "ServiceWorkerScriptContext::OnPushEvent"); | 238 "ServiceWorkerScriptContext::OnPushEvent"); |
| 239 push_start_timings_[request_id] = base::TimeTicks::Now(); |
232 proxy_->dispatchPushEvent(request_id, blink::WebString::fromUTF8(data)); | 240 proxy_->dispatchPushEvent(request_id, blink::WebString::fromUTF8(data)); |
233 } | 241 } |
234 | 242 |
235 void ServiceWorkerScriptContext::OnGeofencingEvent( | 243 void ServiceWorkerScriptContext::OnGeofencingEvent( |
236 int request_id, | 244 int request_id, |
237 blink::WebGeofencingEventType event_type, | 245 blink::WebGeofencingEventType event_type, |
238 const std::string& region_id, | 246 const std::string& region_id, |
239 const blink::WebCircularGeofencingRegion& region) { | 247 const blink::WebCircularGeofencingRegion& region) { |
240 TRACE_EVENT0("ServiceWorker", | 248 TRACE_EVENT0("ServiceWorker", |
241 "ServiceWorkerScriptContext::OnGeofencingEvent"); | 249 "ServiceWorkerScriptContext::OnGeofencingEvent"); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 return; | 289 return; |
282 } | 290 } |
283 scoped_ptr<blink::WebServiceWorkerClientsInfo> info( | 291 scoped_ptr<blink::WebServiceWorkerClientsInfo> info( |
284 new blink::WebServiceWorkerClientsInfo); | 292 new blink::WebServiceWorkerClientsInfo); |
285 info->clientIDs = client_ids; | 293 info->clientIDs = client_ids; |
286 callbacks->onSuccess(info.release()); | 294 callbacks->onSuccess(info.release()); |
287 pending_clients_callbacks_.Remove(request_id); | 295 pending_clients_callbacks_.Remove(request_id); |
288 } | 296 } |
289 | 297 |
290 } // namespace content | 298 } // namespace content |
OLD | NEW |