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

Side by Side Diff: components/signin/core/browser/webdata/token_web_data.cc

Issue 1144153004: components: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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 "components/signin/core/browser/webdata/token_web_data.h" 5 #include "components/signin/core/browser/webdata/token_web_data.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted_delete_on_message_loop.h" 8 #include "base/memory/ref_counted_delete_on_message_loop.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "components/signin/core/browser/webdata/token_service_table.h" 11 #include "components/signin/core/browser/webdata/token_service_table.h"
12 #include "components/webdata/common/web_database_service.h" 12 #include "components/webdata/common/web_database_service.h"
13 13
14 using base::Bind; 14 using base::Bind;
15 using base::Time; 15 using base::Time;
16 16
17 class TokenWebDataBackend 17 class TokenWebDataBackend
18 : public base::RefCountedDeleteOnMessageLoop<TokenWebDataBackend> { 18 : public base::RefCountedDeleteOnMessageLoop<TokenWebDataBackend> {
19 19
20 public: 20 public:
21 TokenWebDataBackend(scoped_refptr<base::MessageLoopProxy> db_thread) 21 TokenWebDataBackend(scoped_refptr<base::SingleThreadTaskRunner> db_thread)
22 : base::RefCountedDeleteOnMessageLoop<TokenWebDataBackend>(db_thread) { 22 : base::RefCountedDeleteOnMessageLoop<TokenWebDataBackend>(db_thread) {}
23 }
24 23
25 WebDatabase::State RemoveAllTokens(WebDatabase* db) { 24 WebDatabase::State RemoveAllTokens(WebDatabase* db) {
26 if (TokenServiceTable::FromWebDatabase(db)->RemoveAllTokens()) { 25 if (TokenServiceTable::FromWebDatabase(db)->RemoveAllTokens()) {
27 return WebDatabase::COMMIT_NEEDED; 26 return WebDatabase::COMMIT_NEEDED;
28 } 27 }
29 return WebDatabase::COMMIT_NOT_NEEDED; 28 return WebDatabase::COMMIT_NOT_NEEDED;
30 } 29 }
31 30
32 WebDatabase::State RemoveTokenForService( 31 WebDatabase::State RemoveTokenForService(
33 const std::string& service, WebDatabase* db) { 32 const std::string& service, WebDatabase* db) {
(...skipping 22 matching lines...) Expand all
56 55
57 protected: 56 protected:
58 virtual ~TokenWebDataBackend() { 57 virtual ~TokenWebDataBackend() {
59 } 58 }
60 59
61 private: 60 private:
62 friend class base::RefCountedDeleteOnMessageLoop<TokenWebDataBackend>; 61 friend class base::RefCountedDeleteOnMessageLoop<TokenWebDataBackend>;
63 friend class base::DeleteHelper<TokenWebDataBackend>; 62 friend class base::DeleteHelper<TokenWebDataBackend>;
64 }; 63 };
65 64
66 TokenWebData::TokenWebData(scoped_refptr<WebDatabaseService> wdbs, 65 TokenWebData::TokenWebData(
67 scoped_refptr<base::MessageLoopProxy> ui_thread, 66 scoped_refptr<WebDatabaseService> wdbs,
68 scoped_refptr<base::MessageLoopProxy> db_thread, 67 scoped_refptr<base::SingleThreadTaskRunner> ui_thread,
69 const ProfileErrorCallback& callback) 68 scoped_refptr<base::SingleThreadTaskRunner> db_thread,
69 const ProfileErrorCallback& callback)
70 : WebDataServiceBase(wdbs, callback, ui_thread), 70 : WebDataServiceBase(wdbs, callback, ui_thread),
71 token_backend_(new TokenWebDataBackend(db_thread)) { 71 token_backend_(new TokenWebDataBackend(db_thread)) {
72 } 72 }
73 73
74 void TokenWebData::SetTokenForService(const std::string& service, 74 void TokenWebData::SetTokenForService(const std::string& service,
75 const std::string& token) { 75 const std::string& token) {
76 wdbs_->ScheduleDBTask(FROM_HERE, 76 wdbs_->ScheduleDBTask(FROM_HERE,
77 Bind(&TokenWebDataBackend::SetTokenForService, token_backend_, 77 Bind(&TokenWebDataBackend::SetTokenForService, token_backend_,
78 service, token)); 78 service, token));
79 } 79 }
80 80
81 void TokenWebData::RemoveAllTokens() { 81 void TokenWebData::RemoveAllTokens() {
82 wdbs_->ScheduleDBTask(FROM_HERE, 82 wdbs_->ScheduleDBTask(FROM_HERE,
83 Bind(&TokenWebDataBackend::RemoveAllTokens, token_backend_)); 83 Bind(&TokenWebDataBackend::RemoveAllTokens, token_backend_));
84 } 84 }
85 85
86 void TokenWebData::RemoveTokenForService(const std::string& service) { 86 void TokenWebData::RemoveTokenForService(const std::string& service) {
87 wdbs_->ScheduleDBTask(FROM_HERE, 87 wdbs_->ScheduleDBTask(FROM_HERE,
88 Bind(&TokenWebDataBackend::RemoveTokenForService, token_backend_, 88 Bind(&TokenWebDataBackend::RemoveTokenForService, token_backend_,
89 service)); 89 service));
90 } 90 }
91 91
92 // Null on failure. Success is WDResult<std::string> 92 // Null on failure. Success is WDResult<std::string>
93 WebDataServiceBase::Handle TokenWebData::GetAllTokens( 93 WebDataServiceBase::Handle TokenWebData::GetAllTokens(
94 WebDataServiceConsumer* consumer) { 94 WebDataServiceConsumer* consumer) {
95 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, 95 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE,
96 Bind(&TokenWebDataBackend::GetAllTokens, token_backend_), consumer); 96 Bind(&TokenWebDataBackend::GetAllTokens, token_backend_), consumer);
97 } 97 }
98 98
99 TokenWebData::TokenWebData(scoped_refptr<base::MessageLoopProxy> ui_thread, 99 TokenWebData::TokenWebData(
100 scoped_refptr<base::MessageLoopProxy> db_thread) 100 scoped_refptr<base::SingleThreadTaskRunner> ui_thread,
101 scoped_refptr<base::SingleThreadTaskRunner> db_thread)
101 : WebDataServiceBase(NULL, ProfileErrorCallback(), ui_thread), 102 : WebDataServiceBase(NULL, ProfileErrorCallback(), ui_thread),
102 token_backend_(new TokenWebDataBackend(db_thread)) { 103 token_backend_(new TokenWebDataBackend(db_thread)) {
103 } 104 }
104 105
105 TokenWebData::~TokenWebData() { 106 TokenWebData::~TokenWebData() {
106 } 107 }
OLDNEW
« no previous file with comments | « components/signin/core/browser/webdata/token_web_data.h ('k') | components/suggestions/suggestions_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698