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

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

Issue 2002883002: ServiceWorker: Store the existence of fetch event handler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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_storage.h" 5 #include "content/browser/service_worker/service_worker_storage.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_; 392 DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_;
393 if (IsDisabled()) { 393 if (IsDisabled()) {
394 RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); 394 RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT));
395 return; 395 return;
396 } 396 }
397 397
398 ServiceWorkerDatabase::RegistrationData data; 398 ServiceWorkerDatabase::RegistrationData data;
399 data.registration_id = registration->id(); 399 data.registration_id = registration->id();
400 data.scope = registration->pattern(); 400 data.scope = registration->pattern();
401 data.script = version->script_url(); 401 data.script = version->script_url();
402 data.has_fetch_handler = true; 402 data.has_fetch_handler = version->has_fetch_handler();
403 data.version_id = version->version_id(); 403 data.version_id = version->version_id();
404 data.last_update_check = registration->last_update_check(); 404 data.last_update_check = registration->last_update_check();
405 data.is_active = (version == registration->active_version()); 405 data.is_active = (version == registration->active_version());
406 data.foreign_fetch_scopes = version->foreign_fetch_scopes(); 406 data.foreign_fetch_scopes = version->foreign_fetch_scopes();
407 data.foreign_fetch_origins = version->foreign_fetch_origins(); 407 data.foreign_fetch_origins = version->foreign_fetch_origins();
408 408
409 ResourceList resources; 409 ResourceList resources;
410 version->script_cache_map()->GetResources(&resources); 410 version->script_cache_map()->GetResources(&resources);
411 411
412 if (resources.empty()) { 412 if (resources.empty()) {
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 scoped_refptr<ServiceWorkerVersion> version = 1241 scoped_refptr<ServiceWorkerVersion> version =
1242 context_->GetLiveVersion(data.version_id); 1242 context_->GetLiveVersion(data.version_id);
1243 if (!version) { 1243 if (!version) {
1244 version = new ServiceWorkerVersion( 1244 version = new ServiceWorkerVersion(
1245 registration.get(), data.script, data.version_id, context_); 1245 registration.get(), data.script, data.version_id, context_);
1246 version->SetStatus(data.is_active ? 1246 version->SetStatus(data.is_active ?
1247 ServiceWorkerVersion::ACTIVATED : ServiceWorkerVersion::INSTALLED); 1247 ServiceWorkerVersion::ACTIVATED : ServiceWorkerVersion::INSTALLED);
1248 version->script_cache_map()->SetResources(resources); 1248 version->script_cache_map()->SetResources(resources);
1249 version->set_foreign_fetch_scopes(data.foreign_fetch_scopes); 1249 version->set_foreign_fetch_scopes(data.foreign_fetch_scopes);
1250 version->set_foreign_fetch_origins(data.foreign_fetch_origins); 1250 version->set_foreign_fetch_origins(data.foreign_fetch_origins);
1251 version->set_has_fetch_handler(data.has_fetch_handler);
1251 } 1252 }
1252 1253
1253 if (version->status() == ServiceWorkerVersion::ACTIVATED) 1254 if (version->status() == ServiceWorkerVersion::ACTIVATED)
1254 registration->SetActiveVersion(version); 1255 registration->SetActiveVersion(version);
1255 else if (version->status() == ServiceWorkerVersion::INSTALLED) 1256 else if (version->status() == ServiceWorkerVersion::INSTALLED)
1256 registration->SetWaitingVersion(version); 1257 registration->SetWaitingVersion(version);
1257 else 1258 else
1258 NOTREACHED(); 1259 NOTREACHED();
1259 1260
1260 return registration; 1261 return registration;
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 callback.Run(SERVICE_WORKER_ERROR_FAILED); 1770 callback.Run(SERVICE_WORKER_ERROR_FAILED);
1770 return; 1771 return;
1771 } 1772 }
1772 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; 1773 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully.";
1773 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( 1774 ServiceWorkerMetrics::RecordDeleteAndStartOverResult(
1774 ServiceWorkerMetrics::DELETE_OK); 1775 ServiceWorkerMetrics::DELETE_OK);
1775 callback.Run(SERVICE_WORKER_OK); 1776 callback.Run(SERVICE_WORKER_OK);
1776 } 1777 }
1777 1778
1778 } // namespace content 1779 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_register_job.cc ('k') | content/browser/service_worker/service_worker_version.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698