| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 const ServiceWorkerResponse& response) { | 122 const ServiceWorkerResponse& response) { |
| 123 UMA_HISTOGRAM_TIMES( | 123 UMA_HISTOGRAM_TIMES( |
| 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( |
| 133 int request_id, |
| 134 blink::WebServiceWorkerEventResult unused) { |
| 135 // TODO(johnme): Plumb through the result. |
| 136 Send(new ServiceWorkerHostMsg_PushEventFinished( |
| 137 GetRoutingID(), request_id)); |
| 138 } |
| 139 |
| 132 void ServiceWorkerScriptContext::DidHandleSyncEvent(int request_id) { | 140 void ServiceWorkerScriptContext::DidHandleSyncEvent(int request_id) { |
| 133 Send(new ServiceWorkerHostMsg_SyncEventFinished( | 141 Send(new ServiceWorkerHostMsg_SyncEventFinished( |
| 134 GetRoutingID(), request_id)); | 142 GetRoutingID(), request_id)); |
| 135 } | 143 } |
| 136 | 144 |
| 137 void ServiceWorkerScriptContext::GetClientDocuments( | 145 void ServiceWorkerScriptContext::GetClientDocuments( |
| 138 blink::WebServiceWorkerClientsCallbacks* callbacks) { | 146 blink::WebServiceWorkerClientsCallbacks* callbacks) { |
| 139 DCHECK(callbacks); | 147 DCHECK(callbacks); |
| 140 int request_id = pending_clients_callbacks_.Add(callbacks); | 148 int request_id = pending_clients_callbacks_.Add(callbacks); |
| 141 Send(new ServiceWorkerHostMsg_GetClientDocuments( | 149 Send(new ServiceWorkerHostMsg_GetClientDocuments( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 TRACE_EVENT0("ServiceWorker", | 223 TRACE_EVENT0("ServiceWorker", |
| 216 "ServiceWorkerScriptContext::OnSyncEvent"); | 224 "ServiceWorkerScriptContext::OnSyncEvent"); |
| 217 proxy_->dispatchSyncEvent(request_id); | 225 proxy_->dispatchSyncEvent(request_id); |
| 218 } | 226 } |
| 219 | 227 |
| 220 void ServiceWorkerScriptContext::OnPushEvent(int request_id, | 228 void ServiceWorkerScriptContext::OnPushEvent(int request_id, |
| 221 const std::string& data) { | 229 const std::string& data) { |
| 222 TRACE_EVENT0("ServiceWorker", | 230 TRACE_EVENT0("ServiceWorker", |
| 223 "ServiceWorkerScriptContext::OnPushEvent"); | 231 "ServiceWorkerScriptContext::OnPushEvent"); |
| 224 proxy_->dispatchPushEvent(request_id, blink::WebString::fromUTF8(data)); | 232 proxy_->dispatchPushEvent(request_id, blink::WebString::fromUTF8(data)); |
| 225 Send(new ServiceWorkerHostMsg_PushEventFinished( | |
| 226 GetRoutingID(), request_id)); | |
| 227 } | 233 } |
| 228 | 234 |
| 229 void ServiceWorkerScriptContext::OnGeofencingEvent( | 235 void ServiceWorkerScriptContext::OnGeofencingEvent( |
| 230 int request_id, | 236 int request_id, |
| 231 blink::WebGeofencingEventType event_type, | 237 blink::WebGeofencingEventType event_type, |
| 232 const std::string& region_id, | 238 const std::string& region_id, |
| 233 const blink::WebCircularGeofencingRegion& region) { | 239 const blink::WebCircularGeofencingRegion& region) { |
| 234 TRACE_EVENT0("ServiceWorker", | 240 TRACE_EVENT0("ServiceWorker", |
| 235 "ServiceWorkerScriptContext::OnGeofencingEvent"); | 241 "ServiceWorkerScriptContext::OnGeofencingEvent"); |
| 236 proxy_->dispatchGeofencingEvent( | 242 proxy_->dispatchGeofencingEvent( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 return; | 281 return; |
| 276 } | 282 } |
| 277 scoped_ptr<blink::WebServiceWorkerClientsInfo> info( | 283 scoped_ptr<blink::WebServiceWorkerClientsInfo> info( |
| 278 new blink::WebServiceWorkerClientsInfo); | 284 new blink::WebServiceWorkerClientsInfo); |
| 279 info->clientIDs = client_ids; | 285 info->clientIDs = client_ids; |
| 280 callbacks->onSuccess(info.release()); | 286 callbacks->onSuccess(info.release()); |
| 281 pending_clients_callbacks_.Remove(request_id); | 287 pending_clients_callbacks_.Remove(request_id); |
| 282 } | 288 } |
| 283 | 289 |
| 284 } // namespace content | 290 } // namespace content |
| OLD | NEW |