OLD | NEW |
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_service.h" | 5 #include "components/password_manager/core/browser/affiliation_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
13 #include "base/time/default_clock.h" | 13 #include "base/time/default_clock.h" |
| 14 #include "base/time/default_tick_clock.h" |
14 #include "components/password_manager/core/browser/affiliation_backend.h" | 15 #include "components/password_manager/core/browser/affiliation_backend.h" |
15 #include "net/url_request/url_request_context_getter.h" | 16 #include "net/url_request/url_request_context_getter.h" |
16 | 17 |
17 namespace password_manager { | 18 namespace password_manager { |
18 | 19 |
19 AffiliationService::AffiliationService( | 20 AffiliationService::AffiliationService( |
20 scoped_refptr<base::SingleThreadTaskRunner> backend_task_runner) | 21 scoped_refptr<base::SingleThreadTaskRunner> backend_task_runner) |
21 : backend_(nullptr), | 22 : backend_(nullptr), |
22 backend_task_runner_(backend_task_runner), | 23 backend_task_runner_(backend_task_runner), |
23 weak_ptr_factory_(this) { | 24 weak_ptr_factory_(this) { |
24 } | 25 } |
25 | 26 |
26 AffiliationService::~AffiliationService() { | 27 AffiliationService::~AffiliationService() { |
27 DCHECK(thread_checker_.CalledOnValidThread()); | 28 DCHECK(thread_checker_.CalledOnValidThread()); |
28 if (backend_) { | 29 if (backend_) { |
29 backend_task_runner_->DeleteSoon(FROM_HERE, backend_); | 30 backend_task_runner_->DeleteSoon(FROM_HERE, backend_); |
30 backend_ = nullptr; | 31 backend_ = nullptr; |
31 } | 32 } |
32 } | 33 } |
33 | 34 |
34 void AffiliationService::Initialize( | 35 void AffiliationService::Initialize( |
35 net::URLRequestContextGetter* request_context_getter, | 36 net::URLRequestContextGetter* request_context_getter, |
36 const base::FilePath& db_path) { | 37 const base::FilePath& db_path) { |
37 DCHECK(thread_checker_.CalledOnValidThread()); | 38 DCHECK(thread_checker_.CalledOnValidThread()); |
38 DCHECK(!backend_); | 39 DCHECK(!backend_); |
39 backend_ = new AffiliationBackend(request_context_getter, | 40 backend_ = |
40 make_scoped_ptr(new base::DefaultClock)); | 41 new AffiliationBackend(request_context_getter, backend_task_runner_, |
| 42 make_scoped_ptr(new base::DefaultClock), |
| 43 make_scoped_ptr(new base::DefaultTickClock)); |
| 44 |
| 45 scoped_ptr<base::TickClock> tick_clock(new base::DefaultTickClock); |
41 backend_task_runner_->PostTask( | 46 backend_task_runner_->PostTask( |
42 FROM_HERE, base::Bind(&AffiliationBackend::Initialize, | 47 FROM_HERE, base::Bind(&AffiliationBackend::Initialize, |
43 base::Unretained(backend_), db_path)); | 48 base::Unretained(backend_), db_path)); |
44 } | 49 } |
45 | 50 |
46 void AffiliationService::GetAffiliations( | 51 void AffiliationService::GetAffiliations( |
47 const FacetURI& facet_uri, | 52 const FacetURI& facet_uri, |
48 bool cached_only, | 53 bool cached_only, |
49 const ResultCallback& result_callback) { | 54 const ResultCallback& result_callback) { |
50 DCHECK(thread_checker_.CalledOnValidThread()); | 55 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 27 matching lines...) Expand all Loading... |
78 | 83 |
79 void AffiliationService::TrimCache() { | 84 void AffiliationService::TrimCache() { |
80 DCHECK(thread_checker_.CalledOnValidThread()); | 85 DCHECK(thread_checker_.CalledOnValidThread()); |
81 DCHECK(backend_); | 86 DCHECK(backend_); |
82 backend_task_runner_->PostTask( | 87 backend_task_runner_->PostTask( |
83 FROM_HERE, | 88 FROM_HERE, |
84 base::Bind(&AffiliationBackend::TrimCache, base::Unretained(backend_))); | 89 base::Bind(&AffiliationBackend::TrimCache, base::Unretained(backend_))); |
85 } | 90 } |
86 | 91 |
87 } // namespace password_manager | 92 } // namespace password_manager |
OLD | NEW |