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

Side by Side Diff: chrome/browser/webdata/web_data_service.cc

Issue 15734014: Split token-related methods from WebDataService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DEPs again Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/webdata/web_data_service.h" 5 #include "chrome/browser/webdata/web_data_service.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "chrome/browser/search_engines/template_url.h" 8 #include "chrome/browser/search_engines/template_url.h"
9 #include "chrome/browser/webdata/keyword_table.h" 9 #include "chrome/browser/webdata/keyword_table.h"
10 #include "chrome/browser/webdata/logins_table.h" 10 #include "chrome/browser/webdata/logins_table.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 Bind(&WebDataService::RemoveWebAppImpl, this, app_url)); 106 Bind(&WebDataService::RemoveWebAppImpl, this, app_url));
107 } 107 }
108 108
109 WebDataServiceBase::Handle WebDataService::GetWebAppImages( 109 WebDataServiceBase::Handle WebDataService::GetWebAppImages(
110 const GURL& app_url, WebDataServiceConsumer* consumer) { 110 const GURL& app_url, WebDataServiceConsumer* consumer) {
111 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, 111 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE,
112 Bind(&WebDataService::GetWebAppImagesImpl, this, app_url), consumer); 112 Bind(&WebDataService::GetWebAppImagesImpl, this, app_url), consumer);
113 } 113 }
114 114
115 //////////////////////////////////////////////////////////////////////////////// 115 ////////////////////////////////////////////////////////////////////////////////
116 //
117 // Token Service
118 //
119 ////////////////////////////////////////////////////////////////////////////////
120
121 void WebDataService::SetTokenForService(const std::string& service,
122 const std::string& token) {
123 wdbs_->ScheduleDBTask(FROM_HERE,
124 Bind(&WebDataService::SetTokenForServiceImpl, this, service, token));
125 }
126
127 void WebDataService::RemoveAllTokens() {
128 wdbs_->ScheduleDBTask(FROM_HERE,
129 Bind(&WebDataService::RemoveAllTokensImpl, this));
130 }
131
132 // Null on failure. Success is WDResult<std::string>
133 WebDataServiceBase::Handle WebDataService::GetAllTokens(
134 WebDataServiceConsumer* consumer) {
135 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE,
136 Bind(&WebDataService::GetAllTokensImpl, this), consumer);
137 }
138
139 ////////////////////////////////////////////////////////////////////////////////
140 116
141 WebDataService::WebDataService() 117 WebDataService::WebDataService()
142 : WebDataServiceBase(NULL, ProfileErrorCallback()) { 118 : WebDataServiceBase(NULL, ProfileErrorCallback()) {
143 } 119 }
144 120
145 WebDataService::~WebDataService() { 121 WebDataService::~WebDataService() {
146 } 122 }
147 123
148 //////////////////////////////////////////////////////////////////////////////// 124 ////////////////////////////////////////////////////////////////////////////////
149 // 125 //
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 205
230 scoped_ptr<WDTypedResult> WebDataService::GetWebAppImagesImpl( 206 scoped_ptr<WDTypedResult> WebDataService::GetWebAppImagesImpl(
231 const GURL& app_url, WebDatabase* db) { 207 const GURL& app_url, WebDatabase* db) {
232 WDAppImagesResult result; 208 WDAppImagesResult result;
233 result.has_all_images = 209 result.has_all_images =
234 WebAppsTable::FromWebDatabase(db)->GetWebAppHasAllImages(app_url); 210 WebAppsTable::FromWebDatabase(db)->GetWebAppHasAllImages(app_url);
235 WebAppsTable::FromWebDatabase(db)->GetWebAppImages(app_url, &result.images); 211 WebAppsTable::FromWebDatabase(db)->GetWebAppImages(app_url, &result.images);
236 return scoped_ptr<WDTypedResult>( 212 return scoped_ptr<WDTypedResult>(
237 new WDResult<WDAppImagesResult>(WEB_APP_IMAGES, result)); 213 new WDResult<WDAppImagesResult>(WEB_APP_IMAGES, result));
238 } 214 }
239
240 ////////////////////////////////////////////////////////////////////////////////
241 //
242 // Token Service implementation.
243 //
244 ////////////////////////////////////////////////////////////////////////////////
245
246 WebDatabase::State WebDataService::RemoveAllTokensImpl(WebDatabase* db) {
247 if (TokenServiceTable::FromWebDatabase(db)->RemoveAllTokens()) {
248 return WebDatabase::COMMIT_NEEDED;
249 }
250 return WebDatabase::COMMIT_NOT_NEEDED;
251 }
252
253 WebDatabase::State WebDataService::SetTokenForServiceImpl(
254 const std::string& service, const std::string& token, WebDatabase* db) {
255 if (TokenServiceTable::FromWebDatabase(db)->SetTokenForService(service,
256 token)) {
257 return WebDatabase::COMMIT_NEEDED;
258 }
259 return WebDatabase::COMMIT_NOT_NEEDED;
260 }
261
262 scoped_ptr<WDTypedResult> WebDataService::GetAllTokensImpl(WebDatabase* db) {
263 std::map<std::string, std::string> map;
264 TokenServiceTable::FromWebDatabase(db)->GetAllTokens(&map);
265 return scoped_ptr<WDTypedResult>(
266 new WDResult<std::map<std::string, std::string> >(TOKEN_RESULT, map));
267 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_data_service.h ('k') | chrome/browser/webdata/web_data_service_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698