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

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

Issue 2376403004: Store Origin-Trial tokens to ServiceWorkerDataBase (Closed)
Patch Set: incorporated iclelland's comment Created 4 years, 2 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 data.registration_id = registration->id(); 401 data.registration_id = registration->id();
402 data.scope = registration->pattern(); 402 data.scope = registration->pattern();
403 data.script = version->script_url(); 403 data.script = version->script_url();
404 data.has_fetch_handler = version->fetch_handler_existence() == 404 data.has_fetch_handler = version->fetch_handler_existence() ==
405 ServiceWorkerVersion::FetchHandlerExistence::EXISTS; 405 ServiceWorkerVersion::FetchHandlerExistence::EXISTS;
406 data.version_id = version->version_id(); 406 data.version_id = version->version_id();
407 data.last_update_check = registration->last_update_check(); 407 data.last_update_check = registration->last_update_check();
408 data.is_active = (version == registration->active_version()); 408 data.is_active = (version == registration->active_version());
409 data.foreign_fetch_scopes = version->foreign_fetch_scopes(); 409 data.foreign_fetch_scopes = version->foreign_fetch_scopes();
410 data.foreign_fetch_origins = version->foreign_fetch_origins(); 410 data.foreign_fetch_origins = version->foreign_fetch_origins();
411 if (version->origin_trial_tokens())
412 data.origin_trial_tokens = *version->origin_trial_tokens();
411 413
412 ResourceList resources; 414 ResourceList resources;
413 version->script_cache_map()->GetResources(&resources); 415 version->script_cache_map()->GetResources(&resources);
414 416
415 if (resources.empty()) { 417 if (resources.empty()) {
416 RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_FAILED)); 418 RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_FAILED));
417 return; 419 return;
418 } 420 }
419 421
420 uint64_t resources_total_size_bytes = 0; 422 uint64_t resources_total_size_bytes = 0;
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 registration.get(), data.script, data.version_id, context_); 1255 registration.get(), data.script, data.version_id, context_);
1254 version->set_fetch_handler_existence( 1256 version->set_fetch_handler_existence(
1255 data.has_fetch_handler 1257 data.has_fetch_handler
1256 ? ServiceWorkerVersion::FetchHandlerExistence::EXISTS 1258 ? ServiceWorkerVersion::FetchHandlerExistence::EXISTS
1257 : ServiceWorkerVersion::FetchHandlerExistence::DOES_NOT_EXIST); 1259 : ServiceWorkerVersion::FetchHandlerExistence::DOES_NOT_EXIST);
1258 version->SetStatus(data.is_active ? 1260 version->SetStatus(data.is_active ?
1259 ServiceWorkerVersion::ACTIVATED : ServiceWorkerVersion::INSTALLED); 1261 ServiceWorkerVersion::ACTIVATED : ServiceWorkerVersion::INSTALLED);
1260 version->script_cache_map()->SetResources(resources); 1262 version->script_cache_map()->SetResources(resources);
1261 version->set_foreign_fetch_scopes(data.foreign_fetch_scopes); 1263 version->set_foreign_fetch_scopes(data.foreign_fetch_scopes);
1262 version->set_foreign_fetch_origins(data.foreign_fetch_origins); 1264 version->set_foreign_fetch_origins(data.foreign_fetch_origins);
1265 if (data.origin_trial_tokens)
1266 version->SetValidOriginTrialTokens(*data.origin_trial_tokens);
1263 } 1267 }
1264 1268
1265 if (version->status() == ServiceWorkerVersion::ACTIVATED) 1269 if (version->status() == ServiceWorkerVersion::ACTIVATED)
1266 registration->SetActiveVersion(version); 1270 registration->SetActiveVersion(version);
1267 else if (version->status() == ServiceWorkerVersion::INSTALLED) 1271 else if (version->status() == ServiceWorkerVersion::INSTALLED)
1268 registration->SetWaitingVersion(version); 1272 registration->SetWaitingVersion(version);
1269 else 1273 else
1270 NOTREACHED(); 1274 NOTREACHED();
1271 1275
1272 return registration; 1276 return registration;
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 callback.Run(SERVICE_WORKER_ERROR_FAILED); 1785 callback.Run(SERVICE_WORKER_ERROR_FAILED);
1782 return; 1786 return;
1783 } 1787 }
1784 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; 1788 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully.";
1785 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( 1789 ServiceWorkerMetrics::RecordDeleteAndStartOverResult(
1786 ServiceWorkerMetrics::DELETE_OK); 1790 ServiceWorkerMetrics::DELETE_OK);
1787 callback.Run(SERVICE_WORKER_OK); 1791 callback.Run(SERVICE_WORKER_OK);
1788 } 1792 }
1789 1793
1790 } // namespace content 1794 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698