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

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

Issue 1283273002: Service Worker: Change last update check location and HTTP cache bypass rule (2/2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments. Created 5 years, 4 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 <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 ServiceWorkerRegistration* registration, 529 ServiceWorkerRegistration* registration,
530 const GURL& script_url, 530 const GURL& script_url,
531 int64 version_id, 531 int64 version_id,
532 base::WeakPtr<ServiceWorkerContextCore> context) 532 base::WeakPtr<ServiceWorkerContextCore> context)
533 : version_id_(version_id), 533 : version_id_(version_id),
534 registration_id_(registration->id()), 534 registration_id_(registration->id()),
535 script_url_(script_url), 535 script_url_(script_url),
536 scope_(registration->pattern()), 536 scope_(registration->pattern()),
537 context_(context), 537 context_(context),
538 script_cache_map_(this, context), 538 script_cache_map_(this, context),
539 max_age_(base::TimeDelta::FromSeconds(
540 kServiceWorkerScriptMaxCacheAgeInSeconds)),
539 ping_controller_(new PingController(this)), 541 ping_controller_(new PingController(this)),
540 weak_factory_(this) { 542 weak_factory_(this) {
541 DCHECK(context_); 543 DCHECK(context_);
542 DCHECK(registration); 544 DCHECK(registration);
543 context_->AddLiveVersion(this); 545 context_->AddLiveVersion(this);
544 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker(); 546 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker();
545 embedded_worker_->AddListener(this); 547 embedded_worker_->AddListener(this);
546 } 548 }
547 549
548 ServiceWorkerVersion::~ServiceWorkerVersion() { 550 ServiceWorkerVersion::~ServiceWorkerVersion() {
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after
2208 if (!context_) 2210 if (!context_)
2209 return; 2211 return;
2210 if (update_timer_.IsRunning() || !stale_time_.is_null()) 2212 if (update_timer_.IsRunning() || !stale_time_.is_null())
2211 return; 2213 return;
2212 ServiceWorkerRegistration* registration = 2214 ServiceWorkerRegistration* registration =
2213 context_->GetLiveRegistration(registration_id_); 2215 context_->GetLiveRegistration(registration_id_);
2214 if (!registration || registration->active_version() != this) 2216 if (!registration || registration->active_version() != this)
2215 return; 2217 return;
2216 base::TimeDelta time_since_last_check = 2218 base::TimeDelta time_since_last_check =
2217 base::Time::Now() - registration->last_update_check(); 2219 base::Time::Now() - registration->last_update_check();
2218 if (time_since_last_check > 2220 if (time_since_last_check > max_age())
jungkees 2015/08/20 01:52:56 I think this line of codes seems still need the co
2219 base::TimeDelta::FromHours(kServiceWorkerScriptMaxCacheAgeInHours))
2220 RestartTick(&stale_time_); 2221 RestartTick(&stale_time_);
2221 } 2222 }
2222 2223
2223 void ServiceWorkerVersion::FoundRegistrationForUpdate( 2224 void ServiceWorkerVersion::FoundRegistrationForUpdate(
2224 ServiceWorkerStatusCode status, 2225 ServiceWorkerStatusCode status,
2225 const scoped_refptr<ServiceWorkerRegistration>& registration) { 2226 const scoped_refptr<ServiceWorkerRegistration>& registration) {
2226 if (!context_) 2227 if (!context_)
2227 return; 2228 return;
2228 2229
2229 const scoped_refptr<ServiceWorkerVersion> protect = this; 2230 const scoped_refptr<ServiceWorkerVersion> protect = this;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2300 base::string16()); 2301 base::string16());
2301 service_port_dispatcher_.reset(); 2302 service_port_dispatcher_.reset();
2302 } 2303 }
2303 2304
2304 void ServiceWorkerVersion::OnBackgroundSyncDispatcherConnectionError() { 2305 void ServiceWorkerVersion::OnBackgroundSyncDispatcherConnectionError() {
2305 RunIDMapCallbacks(&sync_requests_, SERVICE_WORKER_ERROR_FAILED); 2306 RunIDMapCallbacks(&sync_requests_, SERVICE_WORKER_ERROR_FAILED);
2306 background_sync_dispatcher_.reset(); 2307 background_sync_dispatcher_.reset();
2307 } 2308 }
2308 2309
2309 } // namespace content 2310 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698