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

Side by Side Diff: components/password_manager/core/browser/affiliation_backend.cc

Issue 1852093002: components/password_manager: scoped_ptr -> unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and revert an accidental .proto change Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/password_manager/core/browser/affiliation_backend.h" 5 #include "components/password_manager/core/browser/affiliation_backend.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
16 #include "base/time/clock.h" 16 #include "base/time/clock.h"
17 #include "base/time/tick_clock.h" 17 #include "base/time/tick_clock.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "components/password_manager/core/browser/affiliation_database.h" 19 #include "components/password_manager/core/browser/affiliation_database.h"
20 #include "components/password_manager/core/browser/affiliation_fetch_throttler.h " 20 #include "components/password_manager/core/browser/affiliation_fetch_throttler.h "
21 #include "components/password_manager/core/browser/affiliation_fetcher.h" 21 #include "components/password_manager/core/browser/affiliation_fetcher.h"
22 #include "components/password_manager/core/browser/facet_manager.h" 22 #include "components/password_manager/core/browser/facet_manager.h"
23 #include "net/url_request/url_request_context_getter.h" 23 #include "net/url_request/url_request_context_getter.h"
24 24
25 namespace password_manager { 25 namespace password_manager {
26 26
27 AffiliationBackend::AffiliationBackend( 27 AffiliationBackend::AffiliationBackend(
28 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, 28 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter,
29 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 29 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
30 scoped_ptr<base::Clock> time_source, 30 std::unique_ptr<base::Clock> time_source,
31 scoped_ptr<base::TickClock> time_tick_source) 31 std::unique_ptr<base::TickClock> time_tick_source)
32 : request_context_getter_(request_context_getter), 32 : request_context_getter_(request_context_getter),
33 task_runner_(task_runner), 33 task_runner_(task_runner),
34 clock_(std::move(time_source)), 34 clock_(std::move(time_source)),
35 tick_clock_(std::move(time_tick_source)), 35 tick_clock_(std::move(time_tick_source)),
36 construction_time_(clock_->Now()), 36 construction_time_(clock_->Now()),
37 weak_ptr_factory_(this) { 37 weak_ptr_factory_(this) {
38 DCHECK_LT(base::Time(), clock_->Now()); 38 DCHECK_LT(base::Time(), clock_->Now());
39 } 39 }
40 40
41 AffiliationBackend::~AffiliationBackend() { 41 AffiliationBackend::~AffiliationBackend() {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 116
117 // static 117 // static
118 void AffiliationBackend::DeleteCache(const base::FilePath& db_path) { 118 void AffiliationBackend::DeleteCache(const base::FilePath& db_path) {
119 AffiliationDatabase::Delete(db_path); 119 AffiliationDatabase::Delete(db_path);
120 } 120 }
121 121
122 FacetManager* AffiliationBackend::GetOrCreateFacetManager( 122 FacetManager* AffiliationBackend::GetOrCreateFacetManager(
123 const FacetURI& facet_uri) { 123 const FacetURI& facet_uri) {
124 if (!facet_managers_.contains(facet_uri)) { 124 if (!facet_managers_.contains(facet_uri)) {
125 scoped_ptr<FacetManager> new_manager( 125 std::unique_ptr<FacetManager> new_manager(
126 new FacetManager(facet_uri, this, clock_.get())); 126 new FacetManager(facet_uri, this, clock_.get()));
127 facet_managers_.add(facet_uri, std::move(new_manager)); 127 facet_managers_.add(facet_uri, std::move(new_manager));
128 } 128 }
129 return facet_managers_.get(facet_uri); 129 return facet_managers_.get(facet_uri);
130 } 130 }
131 131
132 void AffiliationBackend::DiscardCachedDataIfNoLongerNeeded( 132 void AffiliationBackend::DiscardCachedDataIfNoLongerNeeded(
133 const AffiliatedFacets& affiliated_facets) { 133 const AffiliatedFacets& affiliated_facets) {
134 DCHECK(thread_checker_ && thread_checker_->CalledOnValidThread()); 134 DCHECK(thread_checker_ && thread_checker_->CalledOnValidThread());
135 135
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 base::Time time) { 171 base::Time time) {
172 // TODO(engedy): Avoid spamming the task runner; only ever schedule the first 172 // TODO(engedy): Avoid spamming the task runner; only ever schedule the first
173 // callback. crbug.com/437865. 173 // callback. crbug.com/437865.
174 task_runner_->PostDelayedTask( 174 task_runner_->PostDelayedTask(
175 FROM_HERE, base::Bind(&AffiliationBackend::OnSendNotification, 175 FROM_HERE, base::Bind(&AffiliationBackend::OnSendNotification,
176 weak_ptr_factory_.GetWeakPtr(), facet_uri), 176 weak_ptr_factory_.GetWeakPtr(), facet_uri),
177 time - clock_->Now()); 177 time - clock_->Now());
178 } 178 }
179 179
180 void AffiliationBackend::OnFetchSucceeded( 180 void AffiliationBackend::OnFetchSucceeded(
181 scoped_ptr<AffiliationFetcherDelegate::Result> result) { 181 std::unique_ptr<AffiliationFetcherDelegate::Result> result) {
182 DCHECK(thread_checker_ && thread_checker_->CalledOnValidThread()); 182 DCHECK(thread_checker_ && thread_checker_->CalledOnValidThread());
183 183
184 fetcher_.reset(); 184 fetcher_.reset();
185 throttler_->InformOfNetworkRequestComplete(true); 185 throttler_->InformOfNetworkRequestComplete(true);
186 186
187 for (const AffiliatedFacets& affiliated_facets : *result) { 187 for (const AffiliatedFacets& affiliated_facets : *result) {
188 AffiliatedFacetsWithUpdateTime affiliation; 188 AffiliatedFacetsWithUpdateTime affiliation;
189 affiliation.facets = affiliated_facets; 189 affiliation.facets = affiliated_facets;
190 affiliation.last_update_time = clock_->Now(); 190 affiliation.last_update_time = clock_->Now();
191 191
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } else { 276 } else {
277 base::TimeDelta delay = clock_->Now() - last_request_time_; 277 base::TimeDelta delay = clock_->Now() - last_request_time_;
278 UMA_HISTOGRAM_CUSTOM_TIMES( 278 UMA_HISTOGRAM_CUSTOM_TIMES(
279 "PasswordManager.AffiliationBackend.SubsequentFetchDelay", delay, 279 "PasswordManager.AffiliationBackend.SubsequentFetchDelay", delay,
280 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(3), 50); 280 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(3), 50);
281 } 281 }
282 last_request_time_ = clock_->Now(); 282 last_request_time_ = clock_->Now();
283 } 283 }
284 284
285 void AffiliationBackend::SetThrottlerForTesting( 285 void AffiliationBackend::SetThrottlerForTesting(
286 scoped_ptr<AffiliationFetchThrottler> throttler) { 286 std::unique_ptr<AffiliationFetchThrottler> throttler) {
287 throttler_ = std::move(throttler); 287 throttler_ = std::move(throttler);
288 } 288 }
289 289
290 } // namespace password_manager 290 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698