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

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

Issue 2251633002: Use tri-state enum for the existence of Fetch Handler in ServiceWorkerVersion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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_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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_; 391 DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_;
392 if (IsDisabled()) { 392 if (IsDisabled()) {
393 RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); 393 RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT));
394 return; 394 return;
395 } 395 }
396 396
397 ServiceWorkerDatabase::RegistrationData data; 397 ServiceWorkerDatabase::RegistrationData data;
398 data.registration_id = registration->id(); 398 data.registration_id = registration->id();
399 data.scope = registration->pattern(); 399 data.scope = registration->pattern();
400 data.script = version->script_url(); 400 data.script = version->script_url();
401 data.has_fetch_handler = version->has_fetch_handler(); 401 data.has_fetch_handler = version->has_fetch_handler().value();
402 data.version_id = version->version_id(); 402 data.version_id = version->version_id();
403 data.last_update_check = registration->last_update_check(); 403 data.last_update_check = registration->last_update_check();
404 data.is_active = (version == registration->active_version()); 404 data.is_active = (version == registration->active_version());
405 data.foreign_fetch_scopes = version->foreign_fetch_scopes(); 405 data.foreign_fetch_scopes = version->foreign_fetch_scopes();
406 data.foreign_fetch_origins = version->foreign_fetch_origins(); 406 data.foreign_fetch_origins = version->foreign_fetch_origins();
407 407
408 ResourceList resources; 408 ResourceList resources;
409 version->script_cache_map()->GetResources(&resources); 409 version->script_cache_map()->GetResources(&resources);
410 410
411 if (resources.empty()) { 411 if (resources.empty()) {
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 registration->set_last_update_check(data.last_update_check); 1236 registration->set_last_update_check(data.last_update_check);
1237 if (pending_deletions_.find(data.registration_id) != 1237 if (pending_deletions_.find(data.registration_id) !=
1238 pending_deletions_.end()) { 1238 pending_deletions_.end()) {
1239 registration->set_is_deleted(true); 1239 registration->set_is_deleted(true);
1240 } 1240 }
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->set_has_fetch_handler(data.has_fetch_handler);
1246 version->SetStatus(data.is_active ? 1247 version->SetStatus(data.is_active ?
1247 ServiceWorkerVersion::ACTIVATED : ServiceWorkerVersion::INSTALLED); 1248 ServiceWorkerVersion::ACTIVATED : ServiceWorkerVersion::INSTALLED);
1248 version->script_cache_map()->SetResources(resources); 1249 version->script_cache_map()->SetResources(resources);
1249 version->set_foreign_fetch_scopes(data.foreign_fetch_scopes); 1250 version->set_foreign_fetch_scopes(data.foreign_fetch_scopes);
1250 version->set_foreign_fetch_origins(data.foreign_fetch_origins); 1251 version->set_foreign_fetch_origins(data.foreign_fetch_origins);
1251 version->set_has_fetch_handler(data.has_fetch_handler);
1252 } 1252 }
1253 1253
1254 if (version->status() == ServiceWorkerVersion::ACTIVATED) 1254 if (version->status() == ServiceWorkerVersion::ACTIVATED)
1255 registration->SetActiveVersion(version); 1255 registration->SetActiveVersion(version);
1256 else if (version->status() == ServiceWorkerVersion::INSTALLED) 1256 else if (version->status() == ServiceWorkerVersion::INSTALLED)
1257 registration->SetWaitingVersion(version); 1257 registration->SetWaitingVersion(version);
1258 else 1258 else
1259 NOTREACHED(); 1259 NOTREACHED();
1260 1260
1261 return registration; 1261 return registration;
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 callback.Run(SERVICE_WORKER_ERROR_FAILED); 1770 callback.Run(SERVICE_WORKER_ERROR_FAILED);
1771 return; 1771 return;
1772 } 1772 }
1773 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; 1773 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully.";
1774 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( 1774 ServiceWorkerMetrics::RecordDeleteAndStartOverResult(
1775 ServiceWorkerMetrics::DELETE_OK); 1775 ServiceWorkerMetrics::DELETE_OK);
1776 callback.Run(SERVICE_WORKER_OK); 1776 callback.Run(SERVICE_WORKER_OK);
1777 } 1777 }
1778 1778
1779 } // namespace content 1779 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698