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

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 nhiroki'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 (auto& controllee : controllee_map_) {
542 const ServiceWorkerProviderHost* const host = controllee.second;
nhiroki 2015/06/12 09:07:47 "const T* const foo" seems not common among our co
horo 2015/06/12 09:23:47 Done.
543 info.clients.insert(
544 std::pair<std::string, ServiceWorkerVersionInfo::ClientInfo>(
545 host->client_uuid(),
546 ServiceWorkerVersionInfo::ClientInfo(
547 host->process_id(), host->route_id(), host->provider_type())));
548 }
541 if (!main_script_http_info_) 549 if (!main_script_http_info_)
542 return info; 550 return info;
543 info.script_response_time = main_script_http_info_->response_time; 551 info.script_response_time = main_script_http_info_->response_time;
544 if (main_script_http_info_->headers) 552 if (main_script_http_info_->headers)
545 main_script_http_info_->headers->GetLastModifiedValue( 553 main_script_http_info_->headers->GetLastModifiedValue(
546 &info.script_last_modified); 554 &info.script_last_modified);
547 return info; 555 return info;
548 } 556 }
549 557
550 void ServiceWorkerVersion::StartWorker(const StatusCallback& callback) { 558 void ServiceWorkerVersion::StartWorker(const StatusCallback& callback) {
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 } 937 }
930 938
931 void ServiceWorkerVersion::AddControllee( 939 void ServiceWorkerVersion::AddControllee(
932 ServiceWorkerProviderHost* provider_host) { 940 ServiceWorkerProviderHost* provider_host) {
933 const std::string& uuid = provider_host->client_uuid(); 941 const std::string& uuid = provider_host->client_uuid();
934 CHECK(!provider_host->client_uuid().empty()); 942 CHECK(!provider_host->client_uuid().empty());
935 DCHECK(!ContainsKey(controllee_map_, uuid)); 943 DCHECK(!ContainsKey(controllee_map_, uuid));
936 controllee_map_[uuid] = provider_host; 944 controllee_map_[uuid] = provider_host;
937 // Keep the worker alive a bit longer right after a new controllee is added. 945 // Keep the worker alive a bit longer right after a new controllee is added.
938 RestartTick(&idle_time_); 946 RestartTick(&idle_time_);
947 FOR_EACH_OBSERVER(Listener, listeners_,
948 OnControlleeAdded(this, provider_host));
939 } 949 }
940 950
941 void ServiceWorkerVersion::RemoveControllee( 951 void ServiceWorkerVersion::RemoveControllee(
942 ServiceWorkerProviderHost* provider_host) { 952 ServiceWorkerProviderHost* provider_host) {
943 const std::string& uuid = provider_host->client_uuid(); 953 const std::string& uuid = provider_host->client_uuid();
944 DCHECK(ContainsKey(controllee_map_, uuid)); 954 DCHECK(ContainsKey(controllee_map_, uuid));
945 controllee_map_.erase(uuid); 955 controllee_map_.erase(uuid);
956 FOR_EACH_OBSERVER(Listener, listeners_,
957 OnControlleeRemoved(this, provider_host));
946 if (HasControllee()) 958 if (HasControllee())
947 return; 959 return;
948 FOR_EACH_OBSERVER(Listener, listeners_, OnNoControllees(this)); 960 FOR_EACH_OBSERVER(Listener, listeners_, OnNoControllees(this));
949 } 961 }
950 962
951 void ServiceWorkerVersion::AddStreamingURLRequestJob( 963 void ServiceWorkerVersion::AddStreamingURLRequestJob(
952 const ServiceWorkerURLRequestJob* request_job) { 964 const ServiceWorkerURLRequestJob* request_job) {
953 DCHECK(streaming_url_request_jobs_.find(request_job) == 965 DCHECK(streaming_url_request_jobs_.find(request_job) ==
954 streaming_url_request_jobs_.end()); 966 streaming_url_request_jobs_.end());
955 streaming_url_request_jobs_.insert(request_job); 967 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; 2051 return SERVICE_WORKER_ERROR_ABORT;
2040 default: 2052 default:
2041 return SERVICE_WORKER_ERROR_NETWORK; 2053 return SERVICE_WORKER_ERROR_NETWORK;
2042 } 2054 }
2043 } 2055 }
2044 2056
2045 return default_code; 2057 return default_code;
2046 } 2058 }
2047 2059
2048 } // namespace content 2060 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698