Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: content/browser/service_worker/service_worker_context_core.cc

Issue 1149383004: [3/5 chromium] Shows the clients which are controlled by ServiceWorker in DevTools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporated dcheng's comment Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/service_worker/service_worker_context_core.h" 5 #include "content/browser/service_worker/service_worker_context_core.h"
6 6
7 #include "base/barrier_closure.h" 7 #include "base/barrier_closure.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
15 #include "content/browser/service_worker/embedded_worker_registry.h" 15 #include "content/browser/service_worker/embedded_worker_registry.h"
16 #include "content/browser/service_worker/service_worker_context_observer.h" 16 #include "content/browser/service_worker/service_worker_context_observer.h"
17 #include "content/browser/service_worker/service_worker_context_wrapper.h" 17 #include "content/browser/service_worker/service_worker_context_wrapper.h"
18 #include "content/browser/service_worker/service_worker_database_task_manager.h" 18 #include "content/browser/service_worker/service_worker_database_task_manager.h"
19 #include "content/browser/service_worker/service_worker_info.h" 19 #include "content/browser/service_worker/service_worker_info.h"
20 #include "content/browser/service_worker/service_worker_job_coordinator.h" 20 #include "content/browser/service_worker/service_worker_job_coordinator.h"
21 #include "content/browser/service_worker/service_worker_process_manager.h" 21 #include "content/browser/service_worker/service_worker_process_manager.h"
22 #include "content/browser/service_worker/service_worker_provider_host.h" 22 #include "content/browser/service_worker/service_worker_provider_host.h"
23 #include "content/browser/service_worker/service_worker_register_job.h" 23 #include "content/browser/service_worker/service_worker_register_job.h"
24 #include "content/browser/service_worker/service_worker_registration.h" 24 #include "content/browser/service_worker/service_worker_registration.h"
25 #include "content/browser/service_worker/service_worker_storage.h" 25 #include "content/browser/service_worker/service_worker_storage.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 #include "ipc/ipc_message.h"
27 #include "net/http/http_response_headers.h" 28 #include "net/http/http_response_headers.h"
28 #include "net/http/http_response_info.h" 29 #include "net/http/http_response_info.h"
29 #include "storage/browser/quota/quota_manager_proxy.h" 30 #include "storage/browser/quota/quota_manager_proxy.h"
30 #include "url/gurl.h" 31 #include "url/gurl.h"
31 32
32 namespace content { 33 namespace content {
33 namespace { 34 namespace {
34 35
35 void SuccessCollectorCallback(const base::Closure& done_closure, 36 void SuccessCollectorCallback(const base::Closure& done_closure,
36 bool* overall_success, 37 bool* overall_success,
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 temp->frame_id(), 485 temp->frame_id(),
485 new_provider_id, 486 new_provider_id,
486 temp->provider_type(), 487 temp->provider_type(),
487 temp->dispatcher_host()); 488 temp->dispatcher_host());
488 map->Replace(new_provider_id, transferee.release()); 489 map->Replace(new_provider_id, transferee.release());
489 delete temp; 490 delete temp;
490 } 491 }
491 492
492 void ServiceWorkerContextCore::OnRunningStateChanged( 493 void ServiceWorkerContextCore::OnRunningStateChanged(
493 ServiceWorkerVersion* version) { 494 ServiceWorkerVersion* version) {
494 if (!observer_list_.get()) 495 if (!observer_list_)
495 return; 496 return;
496 observer_list_->Notify(FROM_HERE, 497 observer_list_->Notify(FROM_HERE,
497 &ServiceWorkerContextObserver::OnRunningStateChanged, 498 &ServiceWorkerContextObserver::OnRunningStateChanged,
498 version->version_id(), version->running_status()); 499 version->version_id(), version->running_status());
499 } 500 }
500 501
501 void ServiceWorkerContextCore::OnVersionStateChanged( 502 void ServiceWorkerContextCore::OnVersionStateChanged(
502 ServiceWorkerVersion* version) { 503 ServiceWorkerVersion* version) {
503 if (!observer_list_.get()) 504 if (!observer_list_)
504 return; 505 return;
505 observer_list_->Notify(FROM_HERE, 506 observer_list_->Notify(FROM_HERE,
506 &ServiceWorkerContextObserver::OnVersionStateChanged, 507 &ServiceWorkerContextObserver::OnVersionStateChanged,
507 version->version_id(), version->status()); 508 version->version_id(), version->status());
508 } 509 }
509 510
510 void ServiceWorkerContextCore::OnMainScriptHttpResponseInfoSet( 511 void ServiceWorkerContextCore::OnMainScriptHttpResponseInfoSet(
511 ServiceWorkerVersion* version) { 512 ServiceWorkerVersion* version) {
512 if (!observer_list_.get()) 513 if (!observer_list_)
513 return; 514 return;
514 const net::HttpResponseInfo* info = version->GetMainScriptHttpResponseInfo(); 515 const net::HttpResponseInfo* info = version->GetMainScriptHttpResponseInfo();
515 DCHECK(info); 516 DCHECK(info);
516 base::Time lastModified; 517 base::Time lastModified;
517 if (info->headers) 518 if (info->headers)
518 info->headers->GetLastModifiedValue(&lastModified); 519 info->headers->GetLastModifiedValue(&lastModified);
519 observer_list_->Notify( 520 observer_list_->Notify(
520 FROM_HERE, &ServiceWorkerContextObserver::OnMainScriptHttpResponseInfoSet, 521 FROM_HERE, &ServiceWorkerContextObserver::OnMainScriptHttpResponseInfoSet,
521 version->version_id(), info->response_time, lastModified); 522 version->version_id(), info->response_time, lastModified);
522 } 523 }
523 524
524 void ServiceWorkerContextCore::OnErrorReported( 525 void ServiceWorkerContextCore::OnErrorReported(
525 ServiceWorkerVersion* version, 526 ServiceWorkerVersion* version,
526 const base::string16& error_message, 527 const base::string16& error_message,
527 int line_number, 528 int line_number,
528 int column_number, 529 int column_number,
529 const GURL& source_url) { 530 const GURL& source_url) {
530 if (!observer_list_.get()) 531 if (!observer_list_)
531 return; 532 return;
532 observer_list_->Notify( 533 observer_list_->Notify(
533 FROM_HERE, &ServiceWorkerContextObserver::OnErrorReported, 534 FROM_HERE, &ServiceWorkerContextObserver::OnErrorReported,
534 version->version_id(), version->embedded_worker()->process_id(), 535 version->version_id(), version->embedded_worker()->process_id(),
535 version->embedded_worker()->thread_id(), 536 version->embedded_worker()->thread_id(),
536 ServiceWorkerContextObserver::ErrorInfo(error_message, line_number, 537 ServiceWorkerContextObserver::ErrorInfo(error_message, line_number,
537 column_number, source_url)); 538 column_number, source_url));
538 } 539 }
539 540
540 void ServiceWorkerContextCore::OnReportConsoleMessage( 541 void ServiceWorkerContextCore::OnReportConsoleMessage(
541 ServiceWorkerVersion* version, 542 ServiceWorkerVersion* version,
542 int source_identifier, 543 int source_identifier,
543 int message_level, 544 int message_level,
544 const base::string16& message, 545 const base::string16& message,
545 int line_number, 546 int line_number,
546 const GURL& source_url) { 547 const GURL& source_url) {
547 if (!observer_list_.get()) 548 if (!observer_list_)
548 return; 549 return;
549 observer_list_->Notify( 550 observer_list_->Notify(
550 FROM_HERE, &ServiceWorkerContextObserver::OnReportConsoleMessage, 551 FROM_HERE, &ServiceWorkerContextObserver::OnReportConsoleMessage,
551 version->version_id(), version->embedded_worker()->process_id(), 552 version->version_id(), version->embedded_worker()->process_id(),
552 version->embedded_worker()->thread_id(), 553 version->embedded_worker()->thread_id(),
553 ServiceWorkerContextObserver::ConsoleMessage( 554 ServiceWorkerContextObserver::ConsoleMessage(
554 source_identifier, message_level, message, line_number, source_url)); 555 source_identifier, message_level, message, line_number, source_url));
555 } 556 }
556 557
558 void ServiceWorkerContextCore::OnControlleeAdded(
559 ServiceWorkerVersion* version,
560 ServiceWorkerProviderHost* provider_host) {
561 if (!observer_list_)
562 return;
563 observer_list_->Notify(FROM_HERE,
564 &ServiceWorkerContextObserver::OnControlleeAdded,
565 version->version_id(), provider_host->client_uuid(),
566 provider_host->process_id(), provider_host->route_id(),
567 provider_host->provider_type());
568 }
569
570 void ServiceWorkerContextCore::OnControlleeRemoved(
571 ServiceWorkerVersion* version,
572 ServiceWorkerProviderHost* provider_host) {
573 if (!observer_list_)
574 return;
575 observer_list_->Notify(FROM_HERE,
576 &ServiceWorkerContextObserver::OnControlleeRemoved,
577 version->version_id(), provider_host->client_uuid());
578 }
579
557 ServiceWorkerProcessManager* ServiceWorkerContextCore::process_manager() { 580 ServiceWorkerProcessManager* ServiceWorkerContextCore::process_manager() {
558 return wrapper_->process_manager(); 581 return wrapper_->process_manager();
559 } 582 }
560 583
561 } // namespace content 584 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698