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

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

Issue 868253005: AffiliationBackend: Implement the better part of on-demand fetching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tidy up NULL time related issues. Created 5 years, 10 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_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/location.h" 10 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h" 12 #include "base/thread_task_runner_handle.h"
13 #include "base/time/default_clock.h"
12 #include "components/password_manager/core/browser/affiliation_backend.h" 14 #include "components/password_manager/core/browser/affiliation_backend.h"
15 #include "net/url_request/url_request_context_getter.h"
13 16
14 namespace password_manager { 17 namespace password_manager {
15 18
16 AffiliationService::AffiliationService( 19 AffiliationService::AffiliationService(
17 scoped_refptr<base::SingleThreadTaskRunner> backend_task_runner) 20 scoped_refptr<base::SingleThreadTaskRunner> backend_task_runner)
18 : backend_(nullptr), 21 : backend_(nullptr),
19 backend_task_runner_(backend_task_runner), 22 backend_task_runner_(backend_task_runner),
20 weak_ptr_factory_(this) { 23 weak_ptr_factory_(this) {
21 } 24 }
22 25
23 AffiliationService::~AffiliationService() { 26 AffiliationService::~AffiliationService() {
24 DCHECK(thread_checker_.CalledOnValidThread()); 27 DCHECK(thread_checker_.CalledOnValidThread());
25 if (backend_) { 28 if (backend_) {
26 backend_task_runner_->DeleteSoon(FROM_HERE, backend_); 29 backend_task_runner_->DeleteSoon(FROM_HERE, backend_);
27 backend_ = nullptr; 30 backend_ = nullptr;
28 } 31 }
29 } 32 }
30 33
31 void AffiliationService::Initialize() { 34 void AffiliationService::Initialize(
35 net::URLRequestContextGetter* request_context_getter,
36 const base::FilePath& db_path) {
32 DCHECK(thread_checker_.CalledOnValidThread()); 37 DCHECK(thread_checker_.CalledOnValidThread());
33 DCHECK(!backend_); 38 DCHECK(!backend_);
34 backend_ = new AffiliationBackend(); 39 backend_ = new AffiliationBackend(request_context_getter,
40 make_scoped_ptr(new base::DefaultClock));
35 backend_task_runner_->PostTask( 41 backend_task_runner_->PostTask(
36 FROM_HERE, 42 FROM_HERE, base::Bind(&AffiliationBackend::Initialize,
37 base::Bind(&AffiliationBackend::Initialize, base::Unretained(backend_))); 43 base::Unretained(backend_), db_path));
38 } 44 }
39 45
40 void AffiliationService::GetAffiliations( 46 void AffiliationService::GetAffiliations(
41 const FacetURI& facet_uri, 47 const FacetURI& facet_uri,
42 bool cached_only, 48 bool cached_only,
43 const ResultCallback& result_callback) { 49 const ResultCallback& result_callback) {
44 DCHECK(thread_checker_.CalledOnValidThread()); 50 DCHECK(thread_checker_.CalledOnValidThread());
45 DCHECK(backend_); 51 DCHECK(backend_);
46 backend_task_runner_->PostTask( 52 backend_task_runner_->PostTask(
47 FROM_HERE, 53 FROM_HERE,
(...skipping 28 matching lines...) Expand all
76 82
77 void AffiliationService::TrimCache() { 83 void AffiliationService::TrimCache() {
78 DCHECK(thread_checker_.CalledOnValidThread()); 84 DCHECK(thread_checker_.CalledOnValidThread());
79 DCHECK(backend_); 85 DCHECK(backend_);
80 backend_task_runner_->PostTask( 86 backend_task_runner_->PostTask(
81 FROM_HERE, 87 FROM_HERE,
82 base::Bind(&AffiliationBackend::TrimCache, base::Unretained(backend_))); 88 base::Bind(&AffiliationBackend::TrimCache, base::Unretained(backend_)));
83 } 89 }
84 90
85 } // namespace password_manager 91 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698