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

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

Issue 2716583003: Rename Origin.unique() to opaque().
Patch Set: Update new uses post-rebase Created 3 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 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_database.h" 5 #include "content/browser/service_worker/service_worker_database.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 Status status = LazyOpen(false); 793 Status status = LazyOpen(false);
794 if (IsNewOrNonexistentDatabase(status)) 794 if (IsNewOrNonexistentDatabase(status))
795 return STATUS_OK; 795 return STATUS_OK;
796 if (status != STATUS_OK) 796 if (status != STATUS_OK)
797 return status; 797 return status;
798 if (!origin.is_valid()) 798 if (!origin.is_valid())
799 return STATUS_ERROR_FAILED; 799 return STATUS_ERROR_FAILED;
800 800
801 leveldb::WriteBatch batch; 801 leveldb::WriteBatch batch;
802 802
803 // Remove |origin| from unique origins if a registration specified by 803 // Remove |origin| from opaque origins if a registration specified by
804 // |registration_id| is the only one for |origin|. 804 // |registration_id| is the only one for |origin|.
805 // TODO(nhiroki): Check the uniqueness by more efficient way. 805 // TODO(nhiroki): Check the uniqueness by more efficient way.
806 std::vector<RegistrationData> registrations; 806 std::vector<RegistrationData> registrations;
807 status = GetRegistrationsForOrigin(origin, &registrations, nullptr); 807 status = GetRegistrationsForOrigin(origin, &registrations, nullptr);
808 if (status != STATUS_OK) 808 if (status != STATUS_OK)
809 return status; 809 return status;
810 810
811 if (registrations.size() == 1 && 811 if (registrations.size() == 1 &&
812 registrations[0].registration_id == registration_id) { 812 registrations[0].registration_id == registration_id) {
813 batch.Delete(CreateUniqueOriginKey(origin)); 813 batch.Delete(CreateUniqueOriginKey(origin));
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 if (IsNewOrNonexistentDatabase(status)) 1146 if (IsNewOrNonexistentDatabase(status))
1147 return STATUS_OK; 1147 return STATUS_OK;
1148 if (status != STATUS_OK) 1148 if (status != STATUS_OK)
1149 return status; 1149 return status;
1150 leveldb::WriteBatch batch; 1150 leveldb::WriteBatch batch;
1151 1151
1152 for (const GURL& origin : origins) { 1152 for (const GURL& origin : origins) {
1153 if (!origin.is_valid()) 1153 if (!origin.is_valid())
1154 return STATUS_ERROR_FAILED; 1154 return STATUS_ERROR_FAILED;
1155 1155
1156 // Delete from the unique origin list. 1156 // Delete from the opaque origin list.
1157 batch.Delete(CreateUniqueOriginKey(origin)); 1157 batch.Delete(CreateUniqueOriginKey(origin));
1158 1158
1159 // Delete from the foreign fetch origin list. 1159 // Delete from the foreign fetch origin list.
1160 batch.Delete(CreateForeignFetchOriginKey(origin)); 1160 batch.Delete(CreateForeignFetchOriginKey(origin));
1161 1161
1162 std::vector<RegistrationData> registrations; 1162 std::vector<RegistrationData> registrations;
1163 status = GetRegistrationsForOrigin(origin, &registrations, nullptr); 1163 status = GetRegistrationsForOrigin(origin, &registrations, nullptr);
1164 if (status != STATUS_OK) 1164 if (status != STATUS_OK)
1165 return status; 1165 return status;
1166 1166
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 !ServiceWorkerUtils::ScopeMatches(scope_url, sub_scope_url)) { 1363 !ServiceWorkerUtils::ScopeMatches(scope_url, sub_scope_url)) {
1364 DLOG(ERROR) << "Foreign fetch scope '" << data.foreign_fetch_scope(i) 1364 DLOG(ERROR) << "Foreign fetch scope '" << data.foreign_fetch_scope(i)
1365 << "' is not valid or does not match Scope URL '" << scope_url 1365 << "' is not valid or does not match Scope URL '" << scope_url
1366 << "'."; 1366 << "'.";
1367 return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED; 1367 return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED;
1368 } 1368 }
1369 out->foreign_fetch_scopes.push_back(sub_scope_url); 1369 out->foreign_fetch_scopes.push_back(sub_scope_url);
1370 } 1370 }
1371 for (int i = 0; i < data.foreign_fetch_origin_size(); ++i) { 1371 for (int i = 0; i < data.foreign_fetch_origin_size(); ++i) {
1372 url::Origin parsed_origin(GURL(data.foreign_fetch_origin(i))); 1372 url::Origin parsed_origin(GURL(data.foreign_fetch_origin(i)));
1373 if (parsed_origin.unique()) { 1373 if (parsed_origin.opaque()) {
1374 DLOG(ERROR) << "Foreign fetch origin '" << data.foreign_fetch_origin(i) 1374 DLOG(ERROR) << "Foreign fetch origin '" << data.foreign_fetch_origin(i)
1375 << "' is not valid."; 1375 << "' is not valid.";
1376 return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED; 1376 return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED;
1377 } 1377 }
1378 out->foreign_fetch_origins.push_back(parsed_origin); 1378 out->foreign_fetch_origins.push_back(parsed_origin);
1379 } 1379 }
1380 if (data.has_origin_trial_tokens()) { 1380 if (data.has_origin_trial_tokens()) {
1381 const ServiceWorkerOriginTrialInfo& info = data.origin_trial_tokens(); 1381 const ServiceWorkerOriginTrialInfo& info = data.origin_trial_tokens();
1382 TrialTokenValidator::FeatureToTokensMap origin_trial_tokens; 1382 TrialTokenValidator::FeatureToTokensMap origin_trial_tokens;
1383 for (int i = 0; i < info.features_size(); ++i) { 1383 for (int i = 0; i < info.features_size(); ++i) {
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 if (status != STATUS_OK) 1824 if (status != STATUS_OK)
1825 Disable(from_here, status); 1825 Disable(from_here, status);
1826 ServiceWorkerMetrics::CountWriteDatabaseResult(status); 1826 ServiceWorkerMetrics::CountWriteDatabaseResult(status);
1827 } 1827 }
1828 1828
1829 bool ServiceWorkerDatabase::IsDatabaseInMemory() const { 1829 bool ServiceWorkerDatabase::IsDatabaseInMemory() const {
1830 return path_.empty(); 1830 return path_.empty();
1831 } 1831 }
1832 1832
1833 } // namespace content 1833 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698