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

Side by Side Diff: chrome/browser/budget_service/budget_manager.cc

Issue 2385533002: Replace usage of GURL(origin.Serialize()) with origin.GetURL() (Closed)
Patch Set: sync to #424762 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/budget_service/budget_manager.h" 5 #include "chrome/browser/budget_service/budget_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 case blink::mojom::BudgetOperationType::INVALID_OPERATION: 62 case blink::mojom::BudgetOperationType::INVALID_OPERATION:
63 return SiteEngagementScore::kMaxPoints + 1; 63 return SiteEngagementScore::kMaxPoints + 1;
64 // No default case. 64 // No default case.
65 } 65 }
66 NOTREACHED(); 66 NOTREACHED();
67 return SiteEngagementScore::kMaxPoints + 1.0; 67 return SiteEngagementScore::kMaxPoints + 1.0;
68 } 68 }
69 69
70 void BudgetManager::GetBudget(const url::Origin& origin, 70 void BudgetManager::GetBudget(const url::Origin& origin,
71 const GetBudgetCallback& callback) { 71 const GetBudgetCallback& callback) {
72 if (origin.unique() || !content::IsOriginSecure(GURL(origin.Serialize()))) { 72 if (origin.unique() || !content::IsOriginSecure(origin.GetURL())) {
73 callback.Run(blink::mojom::BudgetServiceErrorType::NOT_SUPPORTED, 73 callback.Run(blink::mojom::BudgetServiceErrorType::NOT_SUPPORTED,
74 mojo::Array<blink::mojom::BudgetStatePtr>()); 74 mojo::Array<blink::mojom::BudgetStatePtr>());
75 return; 75 return;
76 } 76 }
77 db_.GetBudgetDetails(origin, callback); 77 db_.GetBudgetDetails(origin, callback);
78 } 78 }
79 79
80 void BudgetManager::Reserve(const url::Origin& origin, 80 void BudgetManager::Reserve(const url::Origin& origin,
81 blink::mojom::BudgetOperationType type, 81 blink::mojom::BudgetOperationType type,
82 const ReserveCallback& callback) { 82 const ReserveCallback& callback) {
83 if (origin.unique() || !content::IsOriginSecure(GURL(origin.Serialize()))) { 83 if (origin.unique() || !content::IsOriginSecure(origin.GetURL())) {
84 callback.Run(blink::mojom::BudgetServiceErrorType::NOT_SUPPORTED, 84 callback.Run(blink::mojom::BudgetServiceErrorType::NOT_SUPPORTED,
85 false /* success */); 85 false /* success */);
86 return; 86 return;
87 } 87 }
88 db_.SpendBudget(origin, GetCost(type), 88 db_.SpendBudget(origin, GetCost(type),
89 base::Bind(&BudgetManager::DidReserve, 89 base::Bind(&BudgetManager::DidReserve,
90 weak_ptr_factory_.GetWeakPtr(), origin, callback)); 90 weak_ptr_factory_.GetWeakPtr(), origin, callback));
91 } 91 }
92 92
93 void BudgetManager::Consume(const url::Origin& origin, 93 void BudgetManager::Consume(const url::Origin& origin,
94 blink::mojom::BudgetOperationType type, 94 blink::mojom::BudgetOperationType type,
95 const ConsumeCallback& callback) { 95 const ConsumeCallback& callback) {
96 if (origin.unique() || !content::IsOriginSecure(GURL(origin.Serialize()))) { 96 if (origin.unique() || !content::IsOriginSecure(origin.GetURL())) {
97 callback.Run(false /* success */); 97 callback.Run(false /* success */);
98 return; 98 return;
99 } 99 }
100 100
101 bool found_reservation = false; 101 bool found_reservation = false;
102 102
103 // First, see if there is a reservation already. 103 // First, see if there is a reservation already.
104 auto count = reservation_map_.find(origin); 104 auto count = reservation_map_.find(origin);
105 if (count != reservation_map_.end()) { 105 if (count != reservation_map_.end()) {
106 if (count->second == 1) 106 if (count->second == 1)
(...skipping 30 matching lines...) Expand all
137 void BudgetManager::DidReserve(const url::Origin& origin, 137 void BudgetManager::DidReserve(const url::Origin& origin,
138 const ReserveCallback& callback, 138 const ReserveCallback& callback,
139 blink::mojom::BudgetServiceErrorType error, 139 blink::mojom::BudgetServiceErrorType error,
140 bool success) { 140 bool success) {
141 // If the call succeeded, write the new reservation into the map. 141 // If the call succeeded, write the new reservation into the map.
142 if (success && error == blink::mojom::BudgetServiceErrorType::NONE) 142 if (success && error == blink::mojom::BudgetServiceErrorType::NONE)
143 reservation_map_[origin]++; 143 reservation_map_[origin]++;
144 144
145 callback.Run(error, success); 145 callback.Run(error, success);
146 } 146 }
OLDNEW
« no previous file with comments | « chrome/browser/budget_service/budget_database.cc ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698