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

Side by Side Diff: content/browser/service_worker/service_worker_version.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_version.h" 5 #include "content/browser/service_worker/service_worker_version.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 const base::Closure& callback) { 531 const base::Closure& callback) {
532 status_change_callbacks_.push_back(callback); 532 status_change_callbacks_.push_back(callback);
533 } 533 }
534 534
535 ServiceWorkerVersionInfo ServiceWorkerVersion::GetInfo() { 535 ServiceWorkerVersionInfo ServiceWorkerVersion::GetInfo() {
536 DCHECK_CURRENTLY_ON(BrowserThread::IO); 536 DCHECK_CURRENTLY_ON(BrowserThread::IO);
537 ServiceWorkerVersionInfo info( 537 ServiceWorkerVersionInfo info(
538 running_status(), status(), script_url(), registration_id(), version_id(), 538 running_status(), status(), script_url(), registration_id(), version_id(),
539 embedded_worker()->process_id(), embedded_worker()->thread_id(), 539 embedded_worker()->process_id(), embedded_worker()->thread_id(),
540 embedded_worker()->worker_devtools_agent_route_id()); 540 embedded_worker()->worker_devtools_agent_route_id());
541 for (const auto& controllee : controllee_map_) {
542 const ServiceWorkerProviderHost* host = controllee.second;
543 info.clients.insert(std::make_pair(
544 host->client_uuid(),
545 ServiceWorkerVersionInfo::ClientInfo(
546 host->process_id(), host->route_id(), host->provider_type())));
547 }
541 if (!main_script_http_info_) 548 if (!main_script_http_info_)
542 return info; 549 return info;
543 info.script_response_time = main_script_http_info_->response_time; 550 info.script_response_time = main_script_http_info_->response_time;
544 if (main_script_http_info_->headers) 551 if (main_script_http_info_->headers)
545 main_script_http_info_->headers->GetLastModifiedValue( 552 main_script_http_info_->headers->GetLastModifiedValue(
546 &info.script_last_modified); 553 &info.script_last_modified);
547 return info; 554 return info;
548 } 555 }
549 556
550 void ServiceWorkerVersion::StartWorker(const StatusCallback& callback) { 557 void ServiceWorkerVersion::StartWorker(const StatusCallback& callback) {
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 } 936 }
930 937
931 void ServiceWorkerVersion::AddControllee( 938 void ServiceWorkerVersion::AddControllee(
932 ServiceWorkerProviderHost* provider_host) { 939 ServiceWorkerProviderHost* provider_host) {
933 const std::string& uuid = provider_host->client_uuid(); 940 const std::string& uuid = provider_host->client_uuid();
934 CHECK(!provider_host->client_uuid().empty()); 941 CHECK(!provider_host->client_uuid().empty());
935 DCHECK(!ContainsKey(controllee_map_, uuid)); 942 DCHECK(!ContainsKey(controllee_map_, uuid));
936 controllee_map_[uuid] = provider_host; 943 controllee_map_[uuid] = provider_host;
937 // Keep the worker alive a bit longer right after a new controllee is added. 944 // Keep the worker alive a bit longer right after a new controllee is added.
938 RestartTick(&idle_time_); 945 RestartTick(&idle_time_);
946 FOR_EACH_OBSERVER(Listener, listeners_,
947 OnControlleeAdded(this, provider_host));
939 } 948 }
940 949
941 void ServiceWorkerVersion::RemoveControllee( 950 void ServiceWorkerVersion::RemoveControllee(
942 ServiceWorkerProviderHost* provider_host) { 951 ServiceWorkerProviderHost* provider_host) {
943 const std::string& uuid = provider_host->client_uuid(); 952 const std::string& uuid = provider_host->client_uuid();
944 DCHECK(ContainsKey(controllee_map_, uuid)); 953 DCHECK(ContainsKey(controllee_map_, uuid));
945 controllee_map_.erase(uuid); 954 controllee_map_.erase(uuid);
955 FOR_EACH_OBSERVER(Listener, listeners_,
956 OnControlleeRemoved(this, provider_host));
946 if (HasControllee()) 957 if (HasControllee())
947 return; 958 return;
948 FOR_EACH_OBSERVER(Listener, listeners_, OnNoControllees(this)); 959 FOR_EACH_OBSERVER(Listener, listeners_, OnNoControllees(this));
949 } 960 }
950 961
951 void ServiceWorkerVersion::AddStreamingURLRequestJob( 962 void ServiceWorkerVersion::AddStreamingURLRequestJob(
952 const ServiceWorkerURLRequestJob* request_job) { 963 const ServiceWorkerURLRequestJob* request_job) {
953 DCHECK(streaming_url_request_jobs_.find(request_job) == 964 DCHECK(streaming_url_request_jobs_.find(request_job) ==
954 streaming_url_request_jobs_.end()); 965 streaming_url_request_jobs_.end());
955 streaming_url_request_jobs_.insert(request_job); 966 streaming_url_request_jobs_.insert(request_job);
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 return SERVICE_WORKER_ERROR_ABORT; 2050 return SERVICE_WORKER_ERROR_ABORT;
2040 default: 2051 default:
2041 return SERVICE_WORKER_ERROR_NETWORK; 2052 return SERVICE_WORKER_ERROR_NETWORK;
2042 } 2053 }
2043 } 2054 }
2044 2055
2045 return default_code; 2056 return default_code;
2046 } 2057 }
2047 2058
2048 } // namespace content 2059 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698