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