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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 // dispatchMessageEvent is expected to execute onmessage function | 309 // dispatchMessageEvent is expected to execute onmessage function |
310 // synchronously. | 310 // synchronously. |
311 base::TimeTicks before = base::TimeTicks::Now(); | 311 base::TimeTicks before = base::TimeTicks::Now(); |
312 proxy_->dispatchMessageEvent(message, ports); | 312 proxy_->dispatchMessageEvent(message, ports); |
313 UMA_HISTOGRAM_TIMES( | 313 UMA_HISTOGRAM_TIMES( |
314 "ServiceWorker.MessageEventExecutionTime", | 314 "ServiceWorker.MessageEventExecutionTime", |
315 base::TimeTicks::Now() - before); | 315 base::TimeTicks::Now() - before); |
316 } | 316 } |
317 | 317 |
318 void ServiceWorkerScriptContext::OnDidGetClientDocuments( | 318 void ServiceWorkerScriptContext::OnDidGetClientDocuments( |
319 int request_id, const std::vector<int>& client_ids) { | 319 int request_id, const std::vector<ServiceWorkerClientInfo>& clients) { |
320 TRACE_EVENT0("ServiceWorker", | 320 TRACE_EVENT0("ServiceWorker", |
321 "ServiceWorkerScriptContext::OnDidGetClientDocuments"); | 321 "ServiceWorkerScriptContext::OnDidGetClientDocuments"); |
322 blink::WebServiceWorkerClientsCallbacks* callbacks = | 322 blink::WebServiceWorkerClientsCallbacks* callbacks = |
323 pending_clients_callbacks_.Lookup(request_id); | 323 pending_clients_callbacks_.Lookup(request_id); |
324 if (!callbacks) { | 324 if (!callbacks) { |
325 NOTREACHED() << "Got stray response: " << request_id; | 325 NOTREACHED() << "Got stray response: " << request_id; |
326 return; | 326 return; |
327 } | 327 } |
328 scoped_ptr<blink::WebServiceWorkerClientsInfo> info( | 328 scoped_ptr<blink::WebServiceWorkerClientsInfo> info( |
329 new blink::WebServiceWorkerClientsInfo); | 329 new blink::WebServiceWorkerClientsInfo); |
330 info->clientIDs = client_ids; | 330 blink::WebVector<blink::WebServiceWorkerClientInfo> convertedClients( |
| 331 clients.size()); |
| 332 for (size_t i = 0; i < clients.size(); ++i) { |
| 333 convertedClients[i].clientID = clients[i].client_id; |
| 334 convertedClients[i].visibilityState = |
| 335 blink::WebString::fromUTF8(clients[i].visibility_state); |
| 336 convertedClients[i].isFocused = clients[i].is_focused; |
| 337 convertedClients[i].url = clients[i].url; |
| 338 convertedClients[i].frameType = |
| 339 static_cast<blink::WebURLRequest::FrameType>(clients[i].frame_type); |
| 340 } |
| 341 info->clients.swap(convertedClients); |
331 callbacks->onSuccess(info.release()); | 342 callbacks->onSuccess(info.release()); |
332 pending_clients_callbacks_.Remove(request_id); | 343 pending_clients_callbacks_.Remove(request_id); |
333 } | 344 } |
334 | 345 |
335 void ServiceWorkerScriptContext::OnFocusClientResponse(int request_id, | 346 void ServiceWorkerScriptContext::OnFocusClientResponse(int request_id, |
336 bool result) { | 347 bool result) { |
337 TRACE_EVENT0("ServiceWorker", | 348 TRACE_EVENT0("ServiceWorker", |
338 "ServiceWorkerScriptContext::OnFocusClientResponse"); | 349 "ServiceWorkerScriptContext::OnFocusClientResponse"); |
339 blink::WebServiceWorkerClientFocusCallback* callback = | 350 blink::WebServiceWorkerClientFocusCallback* callback = |
340 pending_focus_client_callbacks_.Lookup(request_id); | 351 pending_focus_client_callbacks_.Lookup(request_id); |
341 if (!callback) { | 352 if (!callback) { |
342 NOTREACHED() << "Got stray response: " << request_id; | 353 NOTREACHED() << "Got stray response: " << request_id; |
343 return; | 354 return; |
344 } | 355 } |
345 callback->onSuccess(&result); | 356 callback->onSuccess(&result); |
346 pending_focus_client_callbacks_.Remove(request_id); | 357 pending_focus_client_callbacks_.Remove(request_id); |
347 } | 358 } |
348 | 359 |
349 } // namespace content | 360 } // namespace content |
OLD | NEW |