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

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

Issue 565843002: ServiceWorker: Move tracking code to count only pages controlled by SW (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/browser/service_worker/service_worker_controllee_request_handl er.h" 5 #include "content/browser/service_worker/service_worker_controllee_request_handl er.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "content/browser/service_worker/service_worker_context_core.h" 8 #include "content/browser/service_worker/service_worker_context_core.h"
9 #include "content/browser/service_worker/service_worker_metrics.h" 9 #include "content/browser/service_worker/service_worker_metrics.h"
10 #include "content/browser/service_worker/service_worker_provider_host.h" 10 #include "content/browser/service_worker/service_worker_provider_host.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 job_->FallbackToNetwork(); 141 job_->FallbackToNetwork();
142 TRACE_EVENT_ASYNC_END1( 142 TRACE_EVENT_ASYNC_END1(
143 "ServiceWorker", 143 "ServiceWorker",
144 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", 144 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource",
145 job_.get(), 145 job_.get(),
146 "Status", status); 146 "Status", status);
147 return; 147 return;
148 } 148 }
149 DCHECK(registration.get()); 149 DCHECK(registration.get());
150 150
151 ServiceWorkerMetrics::CountControlledPageLoad();
152
153 // Initiate activation of a waiting version. 151 // Initiate activation of a waiting version.
154 // Usually a register job initiates activation but that 152 // Usually a register job initiates activation but that
155 // doesn't happen if the browser exits prior to activation 153 // doesn't happen if the browser exits prior to activation
156 // having occurred. This check handles that case. 154 // having occurred. This check handles that case.
157 if (registration->waiting_version()) 155 if (registration->waiting_version())
158 registration->ActivateWaitingVersionWhenReady(); 156 registration->ActivateWaitingVersionWhenReady();
159 157
160 scoped_refptr<ServiceWorkerVersion> active_version = 158 scoped_refptr<ServiceWorkerVersion> active_version =
161 registration->active_version(); 159 registration->active_version();
162 160
(...skipping 21 matching lines...) Expand all
184 TRACE_EVENT_ASYNC_END2( 182 TRACE_EVENT_ASYNC_END2(
185 "ServiceWorker", 183 "ServiceWorker",
186 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", 184 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource",
187 job_.get(), 185 job_.get(),
188 "Status", status, 186 "Status", status,
189 "Info", 187 "Info",
190 "ServiceWorkerVersion is not available, so falling back to network"); 188 "ServiceWorkerVersion is not available, so falling back to network");
191 return; 189 return;
192 } 190 }
193 191
192 ServiceWorkerMetrics::CountControlledPageLoad();
193
194 provider_host_->AssociateRegistration(registration.get()); 194 provider_host_->AssociateRegistration(registration.get());
195 job_->ForwardToServiceWorker(); 195 job_->ForwardToServiceWorker();
196 TRACE_EVENT_ASYNC_END2( 196 TRACE_EVENT_ASYNC_END2(
197 "ServiceWorker", 197 "ServiceWorker",
198 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", 198 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource",
199 job_.get(), 199 job_.get(),
200 "Status", status, 200 "Status", status,
201 "Info", 201 "Info",
202 "Forwarded to the ServiceWorker"); 202 "Forwarded to the ServiceWorker");
203 } 203 }
204 204
205 void ServiceWorkerControlleeRequestHandler::OnVersionStatusChanged( 205 void ServiceWorkerControlleeRequestHandler::OnVersionStatusChanged(
206 ServiceWorkerRegistration* registration, 206 ServiceWorkerRegistration* registration,
207 ServiceWorkerVersion* version) { 207 ServiceWorkerVersion* version) {
208 provider_host_->SetAllowAssociation(true); 208 provider_host_->SetAllowAssociation(true);
209 if (version != registration->active_version() || 209 if (version != registration->active_version() ||
210 version->status() != ServiceWorkerVersion::ACTIVATED) { 210 version->status() != ServiceWorkerVersion::ACTIVATED) {
211 job_->FallbackToNetwork(); 211 job_->FallbackToNetwork();
212 return; 212 return;
213 } 213 }
214
215 ServiceWorkerMetrics::CountControlledPageLoad();
216
214 provider_host_->AssociateRegistration(registration); 217 provider_host_->AssociateRegistration(registration);
215 job_->ForwardToServiceWorker(); 218 job_->ForwardToServiceWorker();
216 } 219 }
217 220
218 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() { 221 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() {
219 DCHECK(job_.get()); 222 DCHECK(job_.get());
220 DCHECK(context_); 223 DCHECK(context_);
221 DCHECK(provider_host_->active_version()); 224 DCHECK(provider_host_->active_version());
222 job_->ForwardToServiceWorker(); 225 job_->ForwardToServiceWorker();
223 } 226 }
224 227
225 } // namespace content 228 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698