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

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

Issue 2716583003: Rename Origin.unique() to opaque().
Patch Set: Mac fixes Created 3 years, 9 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 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 Status status = LazyOpen(false); 794 Status status = LazyOpen(false);
795 if (IsNewOrNonexistentDatabase(status)) 795 if (IsNewOrNonexistentDatabase(status))
796 return STATUS_OK; 796 return STATUS_OK;
797 if (status != STATUS_OK) 797 if (status != STATUS_OK)
798 return status; 798 return status;
799 if (!origin.is_valid()) 799 if (!origin.is_valid())
800 return STATUS_ERROR_FAILED; 800 return STATUS_ERROR_FAILED;
801 801
802 leveldb::WriteBatch batch; 802 leveldb::WriteBatch batch;
803 803
804 // Remove |origin| from unique origins if a registration specified by 804 // Remove |origin| from opaque origins if a registration specified by
805 // |registration_id| is the only one for |origin|. 805 // |registration_id| is the only one for |origin|.
806 // TODO(nhiroki): Check the uniqueness by more efficient way. 806 // TODO(nhiroki): Check the uniqueness by more efficient way.
807 std::vector<RegistrationData> registrations; 807 std::vector<RegistrationData> registrations;
808 status = GetRegistrationsForOrigin(origin, &registrations, nullptr); 808 status = GetRegistrationsForOrigin(origin, &registrations, nullptr);
809 if (status != STATUS_OK) 809 if (status != STATUS_OK)
810 return status; 810 return status;
811 811
812 if (registrations.size() == 1 && 812 if (registrations.size() == 1 &&
813 registrations[0].registration_id == registration_id) { 813 registrations[0].registration_id == registration_id) {
814 batch.Delete(CreateUniqueOriginKey(origin)); 814 batch.Delete(CreateUniqueOriginKey(origin));
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 if (IsNewOrNonexistentDatabase(status)) 1038 if (IsNewOrNonexistentDatabase(status))
1039 return STATUS_OK; 1039 return STATUS_OK;
1040 if (status != STATUS_OK) 1040 if (status != STATUS_OK)
1041 return status; 1041 return status;
1042 leveldb::WriteBatch batch; 1042 leveldb::WriteBatch batch;
1043 1043
1044 for (const GURL& origin : origins) { 1044 for (const GURL& origin : origins) {
1045 if (!origin.is_valid()) 1045 if (!origin.is_valid())
1046 return STATUS_ERROR_FAILED; 1046 return STATUS_ERROR_FAILED;
1047 1047
1048 // Delete from the unique origin list. 1048 // Delete from the opaque origin list.
1049 batch.Delete(CreateUniqueOriginKey(origin)); 1049 batch.Delete(CreateUniqueOriginKey(origin));
1050 1050
1051 // Delete from the foreign fetch origin list. 1051 // Delete from the foreign fetch origin list.
1052 batch.Delete(CreateForeignFetchOriginKey(origin)); 1052 batch.Delete(CreateForeignFetchOriginKey(origin));
1053 1053
1054 std::vector<RegistrationData> registrations; 1054 std::vector<RegistrationData> registrations;
1055 status = GetRegistrationsForOrigin(origin, &registrations, nullptr); 1055 status = GetRegistrationsForOrigin(origin, &registrations, nullptr);
1056 if (status != STATUS_OK) 1056 if (status != STATUS_OK)
1057 return status; 1057 return status;
1058 1058
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 !ServiceWorkerUtils::ScopeMatches(scope_url, sub_scope_url)) { 1259 !ServiceWorkerUtils::ScopeMatches(scope_url, sub_scope_url)) {
1260 DLOG(ERROR) << "Foreign fetch scope '" << data.foreign_fetch_scope(i) 1260 DLOG(ERROR) << "Foreign fetch scope '" << data.foreign_fetch_scope(i)
1261 << "' is not valid or does not match Scope URL '" << scope_url 1261 << "' is not valid or does not match Scope URL '" << scope_url
1262 << "'."; 1262 << "'.";
1263 return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED; 1263 return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED;
1264 } 1264 }
1265 out->foreign_fetch_scopes.push_back(sub_scope_url); 1265 out->foreign_fetch_scopes.push_back(sub_scope_url);
1266 } 1266 }
1267 for (int i = 0; i < data.foreign_fetch_origin_size(); ++i) { 1267 for (int i = 0; i < data.foreign_fetch_origin_size(); ++i) {
1268 url::Origin parsed_origin(GURL(data.foreign_fetch_origin(i))); 1268 url::Origin parsed_origin(GURL(data.foreign_fetch_origin(i)));
1269 if (parsed_origin.unique()) { 1269 if (parsed_origin.opaque()) {
1270 DLOG(ERROR) << "Foreign fetch origin '" << data.foreign_fetch_origin(i) 1270 DLOG(ERROR) << "Foreign fetch origin '" << data.foreign_fetch_origin(i)
1271 << "' is not valid."; 1271 << "' is not valid.";
1272 return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED; 1272 return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED;
1273 } 1273 }
1274 out->foreign_fetch_origins.push_back(parsed_origin); 1274 out->foreign_fetch_origins.push_back(parsed_origin);
1275 } 1275 }
1276 if (data.has_origin_trial_tokens()) { 1276 if (data.has_origin_trial_tokens()) {
1277 const ServiceWorkerOriginTrialInfo& info = data.origin_trial_tokens(); 1277 const ServiceWorkerOriginTrialInfo& info = data.origin_trial_tokens();
1278 TrialTokenValidator::FeatureToTokensMap origin_trial_tokens; 1278 TrialTokenValidator::FeatureToTokensMap origin_trial_tokens;
1279 for (int i = 0; i < info.features_size(); ++i) { 1279 for (int i = 0; i < info.features_size(); ++i) {
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 if (status != STATUS_OK) 1720 if (status != STATUS_OK)
1721 Disable(from_here, status); 1721 Disable(from_here, status);
1722 ServiceWorkerMetrics::CountWriteDatabaseResult(status); 1722 ServiceWorkerMetrics::CountWriteDatabaseResult(status);
1723 } 1723 }
1724 1724
1725 bool ServiceWorkerDatabase::IsDatabaseInMemory() const { 1725 bool ServiceWorkerDatabase::IsDatabaseInMemory() const {
1726 return path_.empty(); 1726 return path_.empty();
1727 } 1727 }
1728 1728
1729 } // namespace content 1729 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698