OLD | NEW |
---|---|
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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 | 77 |
78 WDKeywordsResult::~WDKeywordsResult() {} | 78 WDKeywordsResult::~WDKeywordsResult() {} |
79 | 79 |
80 WebDataService::WebDataService() | 80 WebDataService::WebDataService() |
81 : is_running_(false), | 81 : is_running_(false), |
82 db_(NULL), | 82 db_(NULL), |
83 autocomplete_syncable_service_(NULL), | 83 autocomplete_syncable_service_(NULL), |
84 autofill_profile_syncable_service_(NULL), | 84 autofill_profile_syncable_service_(NULL), |
85 failed_init_(false), | 85 failed_init_(false), |
86 should_commit_(false), | 86 should_commit_(false), |
87 next_request_handle_(1), | |
88 main_loop_(MessageLoop::current()) { | 87 main_loop_(MessageLoop::current()) { |
89 // WebDataService requires DB thread if instantiated. | 88 // WebDataService requires DB thread if instantiated. |
90 // Set WebDataServiceFactory::GetInstance()->SetTestingFactory(&profile, NULL) | 89 // Set WebDataServiceFactory::GetInstance()->SetTestingFactory(&profile, NULL) |
91 // if you do not want to instantiate WebDataService in your test. | 90 // if you do not want to instantiate WebDataService in your test. |
92 DCHECK(BrowserThread::IsWellKnownThread(BrowserThread::DB)); | 91 DCHECK(BrowserThread::IsWellKnownThread(BrowserThread::DB)); |
92 | |
93 wdr_mgr_.reset(new WebDataRequestManager()); | |
93 } | 94 } |
94 | 95 |
95 // static | 96 // static |
96 void WebDataService::NotifyOfMultipleAutofillChanges( | 97 void WebDataService::NotifyOfMultipleAutofillChanges( |
97 WebDataService* web_data_service) { | 98 WebDataService* web_data_service) { |
98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
99 | 100 |
100 if (!web_data_service) | 101 if (!web_data_service) |
101 return; | 102 return; |
102 | 103 |
(...skipping 17 matching lines...) Expand all Loading... | |
120 | 121 |
121 bool WebDataService::IsRunning() const { | 122 bool WebDataService::IsRunning() const { |
122 return is_running_; | 123 return is_running_; |
123 } | 124 } |
124 | 125 |
125 void WebDataService::UnloadDatabase() { | 126 void WebDataService::UnloadDatabase() { |
126 ScheduleTask(FROM_HERE, Bind(&WebDataService::ShutdownDatabase, this)); | 127 ScheduleTask(FROM_HERE, Bind(&WebDataService::ShutdownDatabase, this)); |
127 } | 128 } |
128 | 129 |
129 void WebDataService::CancelRequest(Handle h) { | 130 void WebDataService::CancelRequest(Handle h) { |
130 base::AutoLock l(pending_lock_); | 131 wdr_mgr_->CancelRequest(h); |
131 RequestMap::iterator i = pending_requests_.find(h); | |
132 if (i == pending_requests_.end()) { | |
133 NOTREACHED() << "Canceling a nonexistent web data service request"; | |
134 return; | |
135 } | |
136 i->second->Cancel(); | |
137 } | 132 } |
138 | 133 |
139 content::NotificationSource WebDataService::GetNotificationSource() { | 134 content::NotificationSource WebDataService::GetNotificationSource() { |
140 return content::Source<WebDataService>(this); | 135 return content::Source<WebDataService>(this); |
141 } | 136 } |
142 | 137 |
143 bool WebDataService::IsDatabaseLoaded() { | 138 bool WebDataService::IsDatabaseLoaded() { |
144 return db_ != NULL; | 139 return db_ != NULL; |
145 } | 140 } |
146 | 141 |
147 WebDatabase* WebDataService::GetDatabase() { | 142 WebDatabase* WebDataService::GetDatabase() { |
148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
149 return db_; | 144 return db_; |
150 } | 145 } |
151 | 146 |
152 ////////////////////////////////////////////////////////////////////////////// | 147 ////////////////////////////////////////////////////////////////////////////// |
153 // | 148 // |
154 // Keywords. | 149 // Keywords. |
155 // | 150 // |
156 ////////////////////////////////////////////////////////////////////////////// | 151 ////////////////////////////////////////////////////////////////////////////// |
157 | 152 |
158 void WebDataService::AddKeyword(const TemplateURLData& data) { | 153 void WebDataService::AddKeyword(const TemplateURLData& data) { |
159 GenericRequest<TemplateURLData>* request = | 154 GenericRequest<TemplateURLData>* request = |
160 new GenericRequest<TemplateURLData>(this, GetNextRequestHandle(), NULL, | 155 new GenericRequest<TemplateURLData>( |
161 data); | 156 this, wdr_mgr_->GetNextRequestHandle(), NULL, data); |
162 RegisterRequest(request); | 157 wdr_mgr_->RegisterRequest(request); |
dhollowa
2013/01/04 01:34:50
The common pattern here is:
(1) new GenericReque
Cait (Slow)
2013/01/04 22:59:29
Done.
| |
163 ScheduleTask(FROM_HERE, Bind(&WebDataService::AddKeywordImpl, this, request)); | 158 ScheduleTask(FROM_HERE, Bind(&WebDataService::AddKeywordImpl, this, request)); |
164 } | 159 } |
165 | 160 |
166 void WebDataService::RemoveKeyword(TemplateURLID id) { | 161 void WebDataService::RemoveKeyword(TemplateURLID id) { |
167 GenericRequest<TemplateURLID>* request = | 162 GenericRequest<TemplateURLID>* request = |
168 new GenericRequest<TemplateURLID>(this, GetNextRequestHandle(), NULL, id); | 163 new GenericRequest<TemplateURLID>( |
169 RegisterRequest(request); | 164 this, wdr_mgr_->GetNextRequestHandle(), NULL, id); |
165 wdr_mgr_->RegisterRequest(request); | |
170 ScheduleTask(FROM_HERE, | 166 ScheduleTask(FROM_HERE, |
171 Bind(&WebDataService::RemoveKeywordImpl, this, request)); | 167 Bind(&WebDataService::RemoveKeywordImpl, this, request)); |
172 } | 168 } |
173 | 169 |
174 void WebDataService::UpdateKeyword(const TemplateURLData& data) { | 170 void WebDataService::UpdateKeyword(const TemplateURLData& data) { |
175 GenericRequest<TemplateURLData>* request = | 171 GenericRequest<TemplateURLData>* request = |
176 new GenericRequest<TemplateURLData>(this, GetNextRequestHandle(), NULL, | 172 new GenericRequest<TemplateURLData>( |
177 data); | 173 this, wdr_mgr_->GetNextRequestHandle(), NULL, data); |
178 RegisterRequest(request); | 174 wdr_mgr_->RegisterRequest(request); |
179 ScheduleTask(FROM_HERE, | 175 ScheduleTask(FROM_HERE, |
180 Bind(&WebDataService::UpdateKeywordImpl, this, request)); | 176 Bind(&WebDataService::UpdateKeywordImpl, this, request)); |
181 } | 177 } |
182 | 178 |
183 WebDataService::Handle WebDataService::GetKeywords( | 179 WebDataService::Handle WebDataService::GetKeywords( |
184 WebDataServiceConsumer* consumer) { | 180 WebDataServiceConsumer* consumer) { |
185 WebDataRequest* request = | 181 WebDataRequest* request = |
186 new WebDataRequest(this, GetNextRequestHandle(), consumer); | 182 new WebDataRequest(this, wdr_mgr_->GetNextRequestHandle(), consumer); |
187 RegisterRequest(request); | 183 wdr_mgr_->RegisterRequest(request); |
188 ScheduleTask(FROM_HERE, | 184 ScheduleTask(FROM_HERE, |
189 Bind(&WebDataService::GetKeywordsImpl, this, request)); | 185 Bind(&WebDataService::GetKeywordsImpl, this, request)); |
190 return request->GetHandle(); | 186 return request->GetHandle(); |
191 } | 187 } |
192 | 188 |
193 void WebDataService::SetDefaultSearchProvider(const TemplateURL* url) { | 189 void WebDataService::SetDefaultSearchProvider(const TemplateURL* url) { |
194 GenericRequest<TemplateURLID>* request = new GenericRequest<TemplateURLID>( | 190 GenericRequest<TemplateURLID>* request = new GenericRequest<TemplateURLID>( |
195 this, GetNextRequestHandle(), NULL, url ? url->id() : 0); | 191 this, wdr_mgr_->GetNextRequestHandle(), NULL, url ? url->id() : 0); |
196 RegisterRequest(request); | 192 wdr_mgr_->RegisterRequest(request); |
197 ScheduleTask(FROM_HERE, Bind(&WebDataService::SetDefaultSearchProviderImpl, | 193 ScheduleTask(FROM_HERE, Bind(&WebDataService::SetDefaultSearchProviderImpl, |
198 this, request)); | 194 this, request)); |
199 } | 195 } |
200 | 196 |
201 void WebDataService::SetBuiltinKeywordVersion(int version) { | 197 void WebDataService::SetBuiltinKeywordVersion(int version) { |
202 GenericRequest<int>* request = | 198 GenericRequest<int>* request = new GenericRequest<int>( |
203 new GenericRequest<int>(this, GetNextRequestHandle(), NULL, version); | 199 this, wdr_mgr_->GetNextRequestHandle(), NULL, version); |
204 RegisterRequest(request); | 200 wdr_mgr_->RegisterRequest(request); |
205 ScheduleTask(FROM_HERE, Bind(&WebDataService::SetBuiltinKeywordVersionImpl, | 201 ScheduleTask(FROM_HERE, Bind(&WebDataService::SetBuiltinKeywordVersionImpl, |
206 this, request)); | 202 this, request)); |
207 } | 203 } |
208 | 204 |
209 ////////////////////////////////////////////////////////////////////////////// | 205 ////////////////////////////////////////////////////////////////////////////// |
210 // | 206 // |
211 // Web Apps | 207 // Web Apps |
212 // | 208 // |
213 ////////////////////////////////////////////////////////////////////////////// | 209 ////////////////////////////////////////////////////////////////////////////// |
214 | 210 |
215 void WebDataService::SetWebAppImage(const GURL& app_url, | 211 void WebDataService::SetWebAppImage(const GURL& app_url, |
216 const SkBitmap& image) { | 212 const SkBitmap& image) { |
217 GenericRequest2<GURL, SkBitmap>* request = | 213 GenericRequest2<GURL, SkBitmap>* request = |
218 new GenericRequest2<GURL, SkBitmap>(this, GetNextRequestHandle(), | 214 new GenericRequest2<GURL, SkBitmap>( |
219 NULL, app_url, image); | 215 this, wdr_mgr_->GetNextRequestHandle(), NULL, app_url, image); |
220 RegisterRequest(request); | 216 wdr_mgr_->RegisterRequest(request); |
221 ScheduleTask(FROM_HERE, | 217 ScheduleTask(FROM_HERE, |
222 Bind(&WebDataService::SetWebAppImageImpl, this, request)); | 218 Bind(&WebDataService::SetWebAppImageImpl, this, request)); |
223 } | 219 } |
224 | 220 |
225 void WebDataService::SetWebAppHasAllImages(const GURL& app_url, | 221 void WebDataService::SetWebAppHasAllImages(const GURL& app_url, |
226 bool has_all_images) { | 222 bool has_all_images) { |
227 GenericRequest2<GURL, bool>* request = | 223 GenericRequest2<GURL, bool>* request = |
228 new GenericRequest2<GURL, bool>(this, GetNextRequestHandle(), | 224 new GenericRequest2<GURL, bool>( |
229 NULL, app_url, has_all_images); | 225 this, wdr_mgr_->GetNextRequestHandle(), NULL, app_url, |
230 RegisterRequest(request); | 226 has_all_images); |
227 wdr_mgr_->RegisterRequest(request); | |
231 ScheduleTask(FROM_HERE, | 228 ScheduleTask(FROM_HERE, |
232 Bind(&WebDataService::SetWebAppHasAllImagesImpl, this, request)); | 229 Bind(&WebDataService::SetWebAppHasAllImagesImpl, this, request)); |
233 } | 230 } |
234 | 231 |
235 void WebDataService::RemoveWebApp(const GURL& app_url) { | 232 void WebDataService::RemoveWebApp(const GURL& app_url) { |
236 GenericRequest<GURL>* request = | 233 GenericRequest<GURL>* request = |
237 new GenericRequest<GURL>(this, GetNextRequestHandle(), NULL, app_url); | 234 new GenericRequest<GURL>( |
238 RegisterRequest(request); | 235 this, wdr_mgr_->GetNextRequestHandle(), NULL, app_url); |
236 wdr_mgr_->RegisterRequest(request); | |
239 ScheduleTask(FROM_HERE, | 237 ScheduleTask(FROM_HERE, |
240 Bind(&WebDataService::RemoveWebAppImpl, this, request)); | 238 Bind(&WebDataService::RemoveWebAppImpl, this, request)); |
241 } | 239 } |
242 | 240 |
243 WebDataService::Handle WebDataService::GetWebAppImages( | 241 WebDataService::Handle WebDataService::GetWebAppImages( |
244 const GURL& app_url, | 242 const GURL& app_url, |
245 WebDataServiceConsumer* consumer) { | 243 WebDataServiceConsumer* consumer) { |
246 GenericRequest<GURL>* request = | 244 GenericRequest<GURL>* request = |
247 new GenericRequest<GURL>(this, GetNextRequestHandle(), consumer, app_url); | 245 new GenericRequest<GURL>( |
248 RegisterRequest(request); | 246 this, wdr_mgr_->GetNextRequestHandle(), consumer, app_url); |
247 wdr_mgr_->RegisterRequest(request); | |
249 ScheduleTask(FROM_HERE, | 248 ScheduleTask(FROM_HERE, |
250 Bind(&WebDataService::GetWebAppImagesImpl, this, request)); | 249 Bind(&WebDataService::GetWebAppImagesImpl, this, request)); |
251 return request->GetHandle(); | 250 return request->GetHandle(); |
252 } | 251 } |
253 | 252 |
254 ////////////////////////////////////////////////////////////////////////////// | 253 ////////////////////////////////////////////////////////////////////////////// |
255 // | 254 // |
256 // Web Intents. | 255 // Web Intents. |
257 // | 256 // |
258 ////////////////////////////////////////////////////////////////////////////// | 257 ////////////////////////////////////////////////////////////////////////////// |
259 | 258 |
260 void WebDataService::AddWebIntentService(const WebIntentServiceData& service) { | 259 void WebDataService::AddWebIntentService(const WebIntentServiceData& service) { |
261 GenericRequest<WebIntentServiceData>* request = | 260 GenericRequest<WebIntentServiceData>* request = |
262 new GenericRequest<WebIntentServiceData>( | 261 new GenericRequest<WebIntentServiceData>( |
263 this, GetNextRequestHandle(), NULL, service); | 262 this, wdr_mgr_->GetNextRequestHandle(), NULL, service); |
264 RegisterRequest(request); | 263 wdr_mgr_->RegisterRequest(request); |
265 ScheduleTask(FROM_HERE, | 264 ScheduleTask(FROM_HERE, |
266 Bind(&WebDataService::AddWebIntentServiceImpl, this, request)); | 265 Bind(&WebDataService::AddWebIntentServiceImpl, this, request)); |
267 } | 266 } |
268 | 267 |
269 void WebDataService::RemoveWebIntentService( | 268 void WebDataService::RemoveWebIntentService( |
270 const WebIntentServiceData& service) { | 269 const WebIntentServiceData& service) { |
271 GenericRequest<WebIntentServiceData>* request = | 270 GenericRequest<WebIntentServiceData>* request = |
272 new GenericRequest<WebIntentServiceData>( | 271 new GenericRequest<WebIntentServiceData>( |
273 this, GetNextRequestHandle(), NULL, service); | 272 this, wdr_mgr_->GetNextRequestHandle(), NULL, service); |
274 RegisterRequest(request); | 273 wdr_mgr_->RegisterRequest(request); |
275 ScheduleTask(FROM_HERE, Bind(&WebDataService::RemoveWebIntentServiceImpl, | 274 ScheduleTask(FROM_HERE, Bind(&WebDataService::RemoveWebIntentServiceImpl, |
276 this, request)); | 275 this, request)); |
277 } | 276 } |
278 | 277 |
279 WebDataService::Handle WebDataService::GetWebIntentServicesForAction( | 278 WebDataService::Handle WebDataService::GetWebIntentServicesForAction( |
280 const string16& action, | 279 const string16& action, |
281 WebDataServiceConsumer* consumer) { | 280 WebDataServiceConsumer* consumer) { |
282 DCHECK(consumer); | 281 DCHECK(consumer); |
283 GenericRequest<string16>* request = new GenericRequest<string16>( | 282 GenericRequest<string16>* request = |
284 this, GetNextRequestHandle(), consumer, action); | 283 new GenericRequest<string16>( |
285 RegisterRequest(request); | 284 this, wdr_mgr_->GetNextRequestHandle(), consumer, action); |
285 wdr_mgr_->RegisterRequest(request); | |
286 ScheduleTask(FROM_HERE, | 286 ScheduleTask(FROM_HERE, |
287 Bind(&WebDataService::GetWebIntentServicesImpl, this, request)); | 287 Bind(&WebDataService::GetWebIntentServicesImpl, this, request)); |
288 return request->GetHandle(); | 288 return request->GetHandle(); |
289 } | 289 } |
290 | 290 |
291 WebDataService::Handle WebDataService::GetWebIntentServicesForURL( | 291 WebDataService::Handle WebDataService::GetWebIntentServicesForURL( |
292 const string16& service_url, | 292 const string16& service_url, |
293 WebDataServiceConsumer* consumer) { | 293 WebDataServiceConsumer* consumer) { |
294 DCHECK(consumer); | 294 DCHECK(consumer); |
295 GenericRequest<string16>* request = new GenericRequest<string16>( | 295 GenericRequest<string16>* request = |
296 this, GetNextRequestHandle(), consumer, service_url); | 296 new GenericRequest<string16>( |
297 RegisterRequest(request); | 297 this, wdr_mgr_->GetNextRequestHandle(), consumer, service_url); |
298 wdr_mgr_->RegisterRequest(request); | |
298 ScheduleTask(FROM_HERE, Bind(&WebDataService::GetWebIntentServicesForURLImpl, | 299 ScheduleTask(FROM_HERE, Bind(&WebDataService::GetWebIntentServicesForURLImpl, |
299 this, request)); | 300 this, request)); |
300 return request->GetHandle(); | 301 return request->GetHandle(); |
301 } | 302 } |
302 | 303 |
303 | 304 |
304 WebDataService::Handle WebDataService::GetAllWebIntentServices( | 305 WebDataService::Handle WebDataService::GetAllWebIntentServices( |
305 WebDataServiceConsumer* consumer) { | 306 WebDataServiceConsumer* consumer) { |
306 DCHECK(consumer); | 307 DCHECK(consumer); |
307 GenericRequest<std::string>* request = new GenericRequest<std::string>( | 308 GenericRequest<std::string>* request = |
308 this, GetNextRequestHandle(), consumer, std::string()); | 309 new GenericRequest<std::string>( |
309 RegisterRequest(request); | 310 this, wdr_mgr_->GetNextRequestHandle(), consumer, std::string()); |
311 wdr_mgr_->RegisterRequest(request); | |
310 ScheduleTask(FROM_HERE, Bind(&WebDataService::GetAllWebIntentServicesImpl, | 312 ScheduleTask(FROM_HERE, Bind(&WebDataService::GetAllWebIntentServicesImpl, |
311 this, request)); | 313 this, request)); |
312 return request->GetHandle(); | 314 return request->GetHandle(); |
313 } | 315 } |
314 | 316 |
315 void WebDataService::AddDefaultWebIntentService( | 317 void WebDataService::AddDefaultWebIntentService( |
316 const DefaultWebIntentService& service) { | 318 const DefaultWebIntentService& service) { |
317 GenericRequest<DefaultWebIntentService>* request = | 319 GenericRequest<DefaultWebIntentService>* request = |
318 new GenericRequest<DefaultWebIntentService>( | 320 new GenericRequest<DefaultWebIntentService>( |
319 this, GetNextRequestHandle(), NULL, service); | 321 this, wdr_mgr_->GetNextRequestHandle(), NULL, service); |
320 RegisterRequest(request); | 322 wdr_mgr_->RegisterRequest(request); |
321 ScheduleTask(FROM_HERE, | 323 ScheduleTask(FROM_HERE, |
322 Bind(&WebDataService::AddDefaultWebIntentServiceImpl, this, | 324 Bind(&WebDataService::AddDefaultWebIntentServiceImpl, this, |
323 request)); | 325 request)); |
324 } | 326 } |
325 | 327 |
326 void WebDataService::RemoveDefaultWebIntentService( | 328 void WebDataService::RemoveDefaultWebIntentService( |
327 const DefaultWebIntentService& service) { | 329 const DefaultWebIntentService& service) { |
328 GenericRequest<DefaultWebIntentService>* request = | 330 GenericRequest<DefaultWebIntentService>* request = |
329 new GenericRequest<DefaultWebIntentService>( | 331 new GenericRequest<DefaultWebIntentService>( |
330 this, GetNextRequestHandle(), NULL, service); | 332 this, wdr_mgr_->GetNextRequestHandle(), NULL, service); |
331 RegisterRequest(request); | 333 wdr_mgr_->RegisterRequest(request); |
332 ScheduleTask(FROM_HERE, | 334 ScheduleTask(FROM_HERE, |
333 Bind(&WebDataService::RemoveDefaultWebIntentServiceImpl, this, | 335 Bind(&WebDataService::RemoveDefaultWebIntentServiceImpl, this, |
334 request)); | 336 request)); |
335 } | 337 } |
336 | 338 |
337 void WebDataService::RemoveWebIntentServiceDefaults( | 339 void WebDataService::RemoveWebIntentServiceDefaults( |
338 const GURL& service_url) { | 340 const GURL& service_url) { |
339 GenericRequest<GURL>* request = | 341 GenericRequest<GURL>* request = |
340 new GenericRequest<GURL>( | 342 new GenericRequest<GURL>( |
341 this, GetNextRequestHandle(), NULL, service_url); | 343 this, wdr_mgr_->GetNextRequestHandle(), NULL, service_url); |
342 RegisterRequest(request); | 344 wdr_mgr_->RegisterRequest(request); |
343 ScheduleTask( | 345 ScheduleTask( |
344 FROM_HERE, | 346 FROM_HERE, |
345 Bind(&WebDataService::RemoveWebIntentServiceDefaultsImpl, this, request)); | 347 Bind(&WebDataService::RemoveWebIntentServiceDefaultsImpl, this, request)); |
346 } | 348 } |
347 | 349 |
348 WebDataService::Handle WebDataService::GetDefaultWebIntentServicesForAction( | 350 WebDataService::Handle WebDataService::GetDefaultWebIntentServicesForAction( |
349 const string16& action, | 351 const string16& action, |
350 WebDataServiceConsumer* consumer) { | 352 WebDataServiceConsumer* consumer) { |
351 DCHECK(consumer); | 353 DCHECK(consumer); |
352 GenericRequest<string16>* request = new GenericRequest<string16>( | 354 GenericRequest<string16>* request = new GenericRequest<string16>( |
353 this, GetNextRequestHandle(), consumer, action); | 355 this, wdr_mgr_->GetNextRequestHandle(), consumer, action); |
354 RegisterRequest(request); | 356 wdr_mgr_->RegisterRequest(request); |
355 ScheduleTask(FROM_HERE, | 357 ScheduleTask(FROM_HERE, |
356 Bind(&WebDataService::GetDefaultWebIntentServicesForActionImpl, | 358 Bind(&WebDataService::GetDefaultWebIntentServicesForActionImpl, |
357 this, request)); | 359 this, request)); |
358 return request->GetHandle(); | 360 return request->GetHandle(); |
359 } | 361 } |
360 | 362 |
361 WebDataService::Handle WebDataService::GetAllDefaultWebIntentServices( | 363 WebDataService::Handle WebDataService::GetAllDefaultWebIntentServices( |
362 WebDataServiceConsumer* consumer) { | 364 WebDataServiceConsumer* consumer) { |
363 DCHECK(consumer); | 365 DCHECK(consumer); |
364 GenericRequest<std::string>* request = new GenericRequest<std::string>( | 366 GenericRequest<std::string>* request = new GenericRequest<std::string>( |
365 this, GetNextRequestHandle(), consumer, std::string()); | 367 this, wdr_mgr_->GetNextRequestHandle(), consumer, std::string()); |
366 RegisterRequest(request); | 368 wdr_mgr_->RegisterRequest(request); |
367 ScheduleTask(FROM_HERE, | 369 ScheduleTask(FROM_HERE, |
368 Bind(&WebDataService::GetAllDefaultWebIntentServicesImpl, | 370 Bind(&WebDataService::GetAllDefaultWebIntentServicesImpl, |
369 this, request)); | 371 this, request)); |
370 return request->GetHandle(); | 372 return request->GetHandle(); |
371 } | 373 } |
372 | 374 |
373 //////////////////////////////////////////////////////////////////////////////// | 375 //////////////////////////////////////////////////////////////////////////////// |
374 // | 376 // |
375 // Token Service | 377 // Token Service |
376 // | 378 // |
377 //////////////////////////////////////////////////////////////////////////////// | 379 //////////////////////////////////////////////////////////////////////////////// |
378 | 380 |
379 void WebDataService::SetTokenForService(const std::string& service, | 381 void WebDataService::SetTokenForService(const std::string& service, |
380 const std::string& token) { | 382 const std::string& token) { |
381 GenericRequest2<std::string, std::string>* request = | 383 GenericRequest2<std::string, std::string>* request = |
382 new GenericRequest2<std::string, std::string>( | 384 new GenericRequest2<std::string, std::string>( |
383 this, GetNextRequestHandle(), NULL, service, token); | 385 this, wdr_mgr_->GetNextRequestHandle(), NULL, service, token); |
384 RegisterRequest(request); | 386 wdr_mgr_->RegisterRequest(request); |
385 ScheduleTask(FROM_HERE, | 387 ScheduleTask(FROM_HERE, |
386 Bind(&WebDataService::SetTokenForServiceImpl, this, request)); | 388 Bind(&WebDataService::SetTokenForServiceImpl, this, request)); |
387 } | 389 } |
388 | 390 |
389 void WebDataService::RemoveAllTokens() { | 391 void WebDataService::RemoveAllTokens() { |
390 GenericRequest<std::string>* request = | 392 GenericRequest<std::string>* request = |
391 new GenericRequest<std::string>( | 393 new GenericRequest<std::string>( |
392 this, GetNextRequestHandle(), NULL, std::string()); | 394 this, wdr_mgr_->GetNextRequestHandle(), NULL, std::string()); |
393 RegisterRequest(request); | 395 wdr_mgr_->RegisterRequest(request); |
394 ScheduleTask(FROM_HERE, | 396 ScheduleTask(FROM_HERE, |
395 Bind(&WebDataService::RemoveAllTokensImpl, this, request)); | 397 Bind(&WebDataService::RemoveAllTokensImpl, this, request)); |
396 } | 398 } |
397 | 399 |
398 // Null on failure. Success is WDResult<std::string> | 400 // Null on failure. Success is WDResult<std::string> |
399 WebDataService::Handle WebDataService::GetAllTokens( | 401 WebDataService::Handle WebDataService::GetAllTokens( |
400 WebDataServiceConsumer* consumer) { | 402 WebDataServiceConsumer* consumer) { |
401 | 403 |
402 GenericRequest<std::string>* request = | 404 GenericRequest<std::string>* request = |
403 new GenericRequest<std::string>( | 405 new GenericRequest<std::string>( |
404 this, GetNextRequestHandle(), consumer, std::string()); | 406 this, wdr_mgr_->GetNextRequestHandle(), consumer, std::string()); |
405 RegisterRequest(request); | 407 wdr_mgr_->RegisterRequest(request); |
406 ScheduleTask(FROM_HERE, | 408 ScheduleTask(FROM_HERE, |
407 Bind(&WebDataService::GetAllTokensImpl, this, request)); | 409 Bind(&WebDataService::GetAllTokensImpl, this, request)); |
408 return request->GetHandle(); | 410 return request->GetHandle(); |
409 } | 411 } |
410 | 412 |
411 //////////////////////////////////////////////////////////////////////////////// | 413 //////////////////////////////////////////////////////////////////////////////// |
412 // | 414 // |
413 // Autofill. | 415 // Autofill. |
414 // | 416 // |
415 //////////////////////////////////////////////////////////////////////////////// | 417 //////////////////////////////////////////////////////////////////////////////// |
416 | 418 |
417 void WebDataService::AddFormFields( | 419 void WebDataService::AddFormFields( |
418 const std::vector<FormFieldData>& fields) { | 420 const std::vector<FormFieldData>& fields) { |
419 GenericRequest<std::vector<FormFieldData> >* request = | 421 GenericRequest<std::vector<FormFieldData> >* request = |
420 new GenericRequest<std::vector<FormFieldData> >( | 422 new GenericRequest<std::vector<FormFieldData> >( |
421 this, GetNextRequestHandle(), NULL, fields); | 423 this, wdr_mgr_->GetNextRequestHandle(), NULL, fields); |
422 RegisterRequest(request); | 424 wdr_mgr_->RegisterRequest(request); |
423 ScheduleTask(FROM_HERE, | 425 ScheduleTask(FROM_HERE, |
424 Bind(&WebDataService::AddFormElementsImpl, this, request)); | 426 Bind(&WebDataService::AddFormElementsImpl, this, request)); |
425 } | 427 } |
426 | 428 |
427 WebDataService::Handle WebDataService::GetFormValuesForElementName( | 429 WebDataService::Handle WebDataService::GetFormValuesForElementName( |
428 const string16& name, const string16& prefix, int limit, | 430 const string16& name, const string16& prefix, int limit, |
429 WebDataServiceConsumer* consumer) { | 431 WebDataServiceConsumer* consumer) { |
430 WebDataRequest* request = | 432 WebDataRequest* request = |
431 new WebDataRequest(this, GetNextRequestHandle(), consumer); | 433 new WebDataRequest(this, wdr_mgr_->GetNextRequestHandle(), consumer); |
432 RegisterRequest(request); | 434 wdr_mgr_->RegisterRequest(request); |
433 ScheduleTask(FROM_HERE, | 435 ScheduleTask(FROM_HERE, |
434 Bind(&WebDataService::GetFormValuesForElementNameImpl, | 436 Bind(&WebDataService::GetFormValuesForElementNameImpl, |
435 this, request, name, prefix, limit)); | 437 this, request, name, prefix, limit)); |
436 return request->GetHandle(); | 438 return request->GetHandle(); |
437 } | 439 } |
438 | 440 |
439 void WebDataService::RemoveFormElementsAddedBetween(const Time& delete_begin, | 441 void WebDataService::RemoveFormElementsAddedBetween(const Time& delete_begin, |
440 const Time& delete_end) { | 442 const Time& delete_end) { |
441 GenericRequest2<Time, Time>* request = | 443 GenericRequest2<Time, Time>* request = |
442 new GenericRequest2<Time, Time>(this, | 444 new GenericRequest2<Time, Time>( |
443 GetNextRequestHandle(), | 445 this, wdr_mgr_->GetNextRequestHandle(), NULL, delete_begin, delete_end); |
444 NULL, | 446 wdr_mgr_->RegisterRequest(request); |
445 delete_begin, | |
446 delete_end); | |
447 RegisterRequest(request); | |
448 ScheduleTask(FROM_HERE, | 447 ScheduleTask(FROM_HERE, |
449 Bind(&WebDataService::RemoveFormElementsAddedBetweenImpl, | 448 Bind(&WebDataService::RemoveFormElementsAddedBetweenImpl, |
450 this, request)); | 449 this, request)); |
451 } | 450 } |
452 | 451 |
453 void WebDataService::RemoveExpiredFormElements() { | 452 void WebDataService::RemoveExpiredFormElements() { |
454 WebDataRequest* request = | 453 WebDataRequest* request = |
455 new WebDataRequest(this, GetNextRequestHandle(), NULL); | 454 new WebDataRequest(this, wdr_mgr_->GetNextRequestHandle(), NULL); |
456 RegisterRequest(request); | 455 wdr_mgr_->RegisterRequest(request); |
457 ScheduleTask(FROM_HERE, | 456 ScheduleTask(FROM_HERE, |
458 Bind(&WebDataService::RemoveExpiredFormElementsImpl, | 457 Bind(&WebDataService::RemoveExpiredFormElementsImpl, |
459 this, request)); | 458 this, request)); |
460 } | 459 } |
461 | 460 |
462 void WebDataService::RemoveFormValueForElementName( | 461 void WebDataService::RemoveFormValueForElementName( |
463 const string16& name, const string16& value) { | 462 const string16& name, const string16& value) { |
464 GenericRequest2<string16, string16>* request = | 463 GenericRequest2<string16, string16>* request = |
465 new GenericRequest2<string16, string16>(this, | 464 new GenericRequest2<string16, string16>( |
466 GetNextRequestHandle(), | 465 this, wdr_mgr_->GetNextRequestHandle(), NULL, name, value); |
467 NULL, | 466 wdr_mgr_->RegisterRequest(request); |
468 name, value); | |
469 RegisterRequest(request); | |
470 ScheduleTask(FROM_HERE, | 467 ScheduleTask(FROM_HERE, |
471 Bind(&WebDataService::RemoveFormValueForElementNameImpl, | 468 Bind(&WebDataService::RemoveFormValueForElementNameImpl, |
472 this, request)); | 469 this, request)); |
473 } | 470 } |
474 | 471 |
475 void WebDataService::AddAutofillProfile(const AutofillProfile& profile) { | 472 void WebDataService::AddAutofillProfile(const AutofillProfile& profile) { |
476 GenericRequest<AutofillProfile>* request = | 473 GenericRequest<AutofillProfile>* request = |
477 new GenericRequest<AutofillProfile>( | 474 new GenericRequest<AutofillProfile>( |
478 this, GetNextRequestHandle(), NULL, profile); | 475 this, wdr_mgr_->GetNextRequestHandle(), NULL, profile); |
479 RegisterRequest(request); | 476 wdr_mgr_->RegisterRequest(request); |
480 ScheduleTask(FROM_HERE, | 477 ScheduleTask(FROM_HERE, |
481 Bind(&WebDataService::AddAutofillProfileImpl, this, request)); | 478 Bind(&WebDataService::AddAutofillProfileImpl, this, request)); |
482 } | 479 } |
483 | 480 |
484 void WebDataService::UpdateAutofillProfile(const AutofillProfile& profile) { | 481 void WebDataService::UpdateAutofillProfile(const AutofillProfile& profile) { |
485 GenericRequest<AutofillProfile>* request = | 482 GenericRequest<AutofillProfile>* request = |
486 new GenericRequest<AutofillProfile>( | 483 new GenericRequest<AutofillProfile>( |
487 this, GetNextRequestHandle(), NULL, profile); | 484 this, wdr_mgr_->GetNextRequestHandle(), NULL, profile); |
488 RegisterRequest(request); | 485 wdr_mgr_->RegisterRequest(request); |
489 ScheduleTask(FROM_HERE, | 486 ScheduleTask(FROM_HERE, |
490 Bind(&WebDataService::UpdateAutofillProfileImpl, this, request)); | 487 Bind(&WebDataService::UpdateAutofillProfileImpl, this, request)); |
491 } | 488 } |
492 | 489 |
493 void WebDataService::RemoveAutofillProfile(const std::string& guid) { | 490 void WebDataService::RemoveAutofillProfile(const std::string& guid) { |
494 GenericRequest<std::string>* request = | 491 GenericRequest<std::string>* request = |
495 new GenericRequest<std::string>( | 492 new GenericRequest<std::string>( |
496 this, GetNextRequestHandle(), NULL, guid); | 493 this, wdr_mgr_->GetNextRequestHandle(), NULL, guid); |
497 RegisterRequest(request); | 494 wdr_mgr_->RegisterRequest(request); |
498 ScheduleTask(FROM_HERE, | 495 ScheduleTask(FROM_HERE, |
499 Bind(&WebDataService::RemoveAutofillProfileImpl, this, request)); | 496 Bind(&WebDataService::RemoveAutofillProfileImpl, this, request)); |
500 } | 497 } |
501 | 498 |
502 WebDataService::Handle WebDataService::GetAutofillProfiles( | 499 WebDataService::Handle WebDataService::GetAutofillProfiles( |
503 WebDataServiceConsumer* consumer) { | 500 WebDataServiceConsumer* consumer) { |
504 WebDataRequest* request = | 501 WebDataRequest* request = |
505 new WebDataRequest(this, GetNextRequestHandle(), consumer); | 502 new WebDataRequest(this, wdr_mgr_->GetNextRequestHandle(), consumer); |
506 RegisterRequest(request); | 503 wdr_mgr_->RegisterRequest(request); |
507 ScheduleTask(FROM_HERE, | 504 ScheduleTask(FROM_HERE, |
508 Bind(&WebDataService::GetAutofillProfilesImpl, this, request)); | 505 Bind(&WebDataService::GetAutofillProfilesImpl, this, request)); |
509 return request->GetHandle(); | 506 return request->GetHandle(); |
510 } | 507 } |
511 | 508 |
512 void WebDataService::EmptyMigrationTrash(bool notify_sync) { | 509 void WebDataService::EmptyMigrationTrash(bool notify_sync) { |
513 GenericRequest<bool>* request = | 510 GenericRequest<bool>* request = |
514 new GenericRequest<bool>( | 511 new GenericRequest<bool>( |
515 this, GetNextRequestHandle(), NULL, notify_sync); | 512 this, wdr_mgr_->GetNextRequestHandle(), NULL, notify_sync); |
516 RegisterRequest(request); | 513 wdr_mgr_->RegisterRequest(request); |
517 ScheduleTask(FROM_HERE, | 514 ScheduleTask(FROM_HERE, |
518 Bind(&WebDataService::EmptyMigrationTrashImpl, this, request)); | 515 Bind(&WebDataService::EmptyMigrationTrashImpl, this, request)); |
519 } | 516 } |
520 | 517 |
521 void WebDataService::AddCreditCard(const CreditCard& credit_card) { | 518 void WebDataService::AddCreditCard(const CreditCard& credit_card) { |
522 GenericRequest<CreditCard>* request = | 519 GenericRequest<CreditCard>* request = |
523 new GenericRequest<CreditCard>( | 520 new GenericRequest<CreditCard>( |
524 this, GetNextRequestHandle(), NULL, credit_card); | 521 this, wdr_mgr_->GetNextRequestHandle(), NULL, credit_card); |
525 RegisterRequest(request); | 522 wdr_mgr_->RegisterRequest(request); |
526 ScheduleTask(FROM_HERE, | 523 ScheduleTask(FROM_HERE, |
527 Bind(&WebDataService::AddCreditCardImpl, this, request)); | 524 Bind(&WebDataService::AddCreditCardImpl, this, request)); |
528 } | 525 } |
529 | 526 |
530 void WebDataService::UpdateCreditCard(const CreditCard& credit_card) { | 527 void WebDataService::UpdateCreditCard(const CreditCard& credit_card) { |
531 GenericRequest<CreditCard>* request = | 528 GenericRequest<CreditCard>* request = |
532 new GenericRequest<CreditCard>( | 529 new GenericRequest<CreditCard>( |
533 this, GetNextRequestHandle(), NULL, credit_card); | 530 this, wdr_mgr_->GetNextRequestHandle(), NULL, credit_card); |
534 RegisterRequest(request); | 531 wdr_mgr_->RegisterRequest(request); |
535 ScheduleTask(FROM_HERE, | 532 ScheduleTask(FROM_HERE, |
536 Bind(&WebDataService::UpdateCreditCardImpl, this, request)); | 533 Bind(&WebDataService::UpdateCreditCardImpl, this, request)); |
537 } | 534 } |
538 | 535 |
539 void WebDataService::RemoveCreditCard(const std::string& guid) { | 536 void WebDataService::RemoveCreditCard(const std::string& guid) { |
540 GenericRequest<std::string>* request = | 537 GenericRequest<std::string>* request = |
541 new GenericRequest<std::string>( | 538 new GenericRequest<std::string>( |
542 this, GetNextRequestHandle(), NULL, guid); | 539 this, wdr_mgr_->GetNextRequestHandle(), NULL, guid); |
543 RegisterRequest(request); | 540 wdr_mgr_->RegisterRequest(request); |
544 ScheduleTask(FROM_HERE, | 541 ScheduleTask(FROM_HERE, |
545 Bind(&WebDataService::RemoveCreditCardImpl, this, request)); | 542 Bind(&WebDataService::RemoveCreditCardImpl, this, request)); |
546 } | 543 } |
547 | 544 |
548 WebDataService::Handle WebDataService::GetCreditCards( | 545 WebDataService::Handle WebDataService::GetCreditCards( |
549 WebDataServiceConsumer* consumer) { | 546 WebDataServiceConsumer* consumer) { |
550 WebDataRequest* request = | 547 WebDataRequest* request = |
551 new WebDataRequest(this, GetNextRequestHandle(), consumer); | 548 new WebDataRequest(this, wdr_mgr_->GetNextRequestHandle(), consumer); |
552 RegisterRequest(request); | 549 wdr_mgr_->RegisterRequest(request); |
553 ScheduleTask(FROM_HERE, | 550 ScheduleTask(FROM_HERE, |
554 Bind(&WebDataService::GetCreditCardsImpl, this, request)); | 551 Bind(&WebDataService::GetCreditCardsImpl, this, request)); |
555 return request->GetHandle(); | 552 return request->GetHandle(); |
556 } | 553 } |
557 | 554 |
558 void WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetween( | 555 void WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetween( |
559 const Time& delete_begin, | 556 const Time& delete_begin, |
560 const Time& delete_end) { | 557 const Time& delete_end) { |
561 GenericRequest2<Time, Time>* request = | 558 GenericRequest2<Time, Time>* request = |
562 new GenericRequest2<Time, Time>(this, | 559 new GenericRequest2<Time, Time>( |
563 GetNextRequestHandle(), | 560 this, wdr_mgr_->GetNextRequestHandle(), NULL, delete_begin, |
564 NULL, | 561 delete_end); |
565 delete_begin, | 562 wdr_mgr_->RegisterRequest(request); |
566 delete_end); | |
567 RegisterRequest(request); | |
568 ScheduleTask(FROM_HERE, Bind( | 563 ScheduleTask(FROM_HERE, Bind( |
569 &WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl, | 564 &WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl, |
570 this, request)); | 565 this, request)); |
571 } | 566 } |
572 | 567 |
573 WebDataService::~WebDataService() { | 568 WebDataService::~WebDataService() { |
574 if (is_running_ && db_) { | 569 if (is_running_ && db_) { |
575 DLOG_ASSERT("WebDataService dtor called without Shutdown"); | 570 DLOG_ASSERT("WebDataService dtor called without Shutdown"); |
576 NOTREACHED(); | 571 NOTREACHED(); |
577 } | 572 } |
(...skipping 12 matching lines...) Expand all Loading... | |
590 AutofillCountry::ApplicationLocale(); | 585 AutofillCountry::ApplicationLocale(); |
591 | 586 |
592 ScheduleTask(FROM_HERE, | 587 ScheduleTask(FROM_HERE, |
593 Bind(&WebDataService::InitializeDatabaseIfNecessary, this)); | 588 Bind(&WebDataService::InitializeDatabaseIfNecessary, this)); |
594 ScheduleTask(FROM_HERE, | 589 ScheduleTask(FROM_HERE, |
595 Bind(&WebDataService::InitializeSyncableServices, this)); | 590 Bind(&WebDataService::InitializeSyncableServices, this)); |
596 return true; | 591 return true; |
597 } | 592 } |
598 | 593 |
599 void WebDataService::RequestCompleted(Handle h) { | 594 void WebDataService::RequestCompleted(Handle h) { |
600 pending_lock_.Acquire(); | 595 wdr_mgr_->RequestCompleted(h); |
601 RequestMap::iterator i = pending_requests_.find(h); | |
602 if (i == pending_requests_.end()) { | |
603 NOTREACHED() << "Request completed called for an unknown request"; | |
604 pending_lock_.Release(); | |
605 return; | |
606 } | |
607 | |
608 // Take ownership of the request object and remove it from the map. | |
609 scoped_ptr<WebDataRequest> request(i->second); | |
610 pending_requests_.erase(i); | |
611 pending_lock_.Release(); | |
612 | |
613 // Notify the consumer if needed. | |
614 WebDataServiceConsumer* consumer = NULL; | |
615 if (!request->IsCancelled(&consumer) && consumer) { | |
616 consumer->OnWebDataServiceRequestDone(request->GetHandle(), | |
617 request->GetResult()); | |
618 } else { | |
619 // Nobody is taken ownership of the result, either because it is cancelled | |
620 // or there is no consumer. Destroy results that require special handling. | |
621 WDTypedResult const *result = request->GetResult(); | |
622 if (result) { | |
623 if (result->GetType() == AUTOFILL_PROFILES_RESULT) { | |
624 const WDResult<std::vector<AutofillProfile*> >* r = | |
625 static_cast<const WDResult<std::vector<AutofillProfile*> >*>( | |
626 result); | |
627 std::vector<AutofillProfile*> profiles = r->GetValue(); | |
628 STLDeleteElements(&profiles); | |
629 } else if (result->GetType() == AUTOFILL_CREDITCARDS_RESULT) { | |
630 const WDResult<std::vector<CreditCard*> >* r = | |
631 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); | |
632 | |
633 std::vector<CreditCard*> credit_cards = r->GetValue(); | |
634 STLDeleteElements(&credit_cards); | |
635 } | |
636 } | |
637 } | |
638 } | |
639 | |
640 void WebDataService::RegisterRequest(WebDataRequest* request) { | |
641 base::AutoLock l(pending_lock_); | |
642 pending_requests_[request->GetHandle()] = request; | |
643 } | 596 } |
644 | 597 |
645 //////////////////////////////////////////////////////////////////////////////// | 598 //////////////////////////////////////////////////////////////////////////////// |
646 // | 599 // |
647 // The following methods are executed in Chrome_WebDataThread. | 600 // The following methods are executed in Chrome_WebDataThread. |
648 // | 601 // |
649 //////////////////////////////////////////////////////////////////////////////// | 602 //////////////////////////////////////////////////////////////////////////////// |
650 | 603 |
651 void WebDataService::DBInitFailed(sql::InitStatus init_status) { | 604 void WebDataService::DBInitFailed(sql::InitStatus init_status) { |
652 ShowProfileErrorDialog( | 605 ShowProfileErrorDialog( |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
739 NOTREACHED() << "Task scheduled after Shutdown()"; | 692 NOTREACHED() << "Task scheduled after Shutdown()"; |
740 } | 693 } |
741 | 694 |
742 void WebDataService::ScheduleCommit() { | 695 void WebDataService::ScheduleCommit() { |
743 if (should_commit_ == false) { | 696 if (should_commit_ == false) { |
744 should_commit_ = true; | 697 should_commit_ = true; |
745 ScheduleTask(FROM_HERE, Bind(&WebDataService::Commit, this)); | 698 ScheduleTask(FROM_HERE, Bind(&WebDataService::Commit, this)); |
746 } | 699 } |
747 } | 700 } |
748 | 701 |
749 int WebDataService::GetNextRequestHandle() { | |
750 base::AutoLock l(pending_lock_); | |
751 return ++next_request_handle_; | |
752 } | |
753 | |
754 //////////////////////////////////////////////////////////////////////////////// | 702 //////////////////////////////////////////////////////////////////////////////// |
755 // | 703 // |
756 // Keywords implementation. | 704 // Keywords implementation. |
757 // | 705 // |
758 //////////////////////////////////////////////////////////////////////////////// | 706 //////////////////////////////////////////////////////////////////////////////// |
759 | 707 |
760 void WebDataService::AddKeywordImpl(GenericRequest<TemplateURLData>* request) { | 708 void WebDataService::AddKeywordImpl(GenericRequest<TemplateURLData>* request) { |
761 InitializeDatabaseIfNecessary(); | 709 InitializeDatabaseIfNecessary(); |
762 if (db_ && !request->IsCancelled(NULL)) { | 710 if (db_ && !request->IsCancelled(NULL)) { |
763 db_->GetKeywordTable()->AddKeyword(request->arg()); | 711 db_->GetKeywordTable()->AddKeyword(request->arg()); |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1454 return autofill_profile_syncable_service_; | 1402 return autofill_profile_syncable_service_; |
1455 } | 1403 } |
1456 | 1404 |
1457 AutocompleteSyncableService* WebDataService::GetAutocompleteSyncableService() | 1405 AutocompleteSyncableService* WebDataService::GetAutocompleteSyncableService() |
1458 const { | 1406 const { |
1459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 1407 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
1460 DCHECK(autocomplete_syncable_service_); // Make sure we're initialized. | 1408 DCHECK(autocomplete_syncable_service_); // Make sure we're initialized. |
1461 | 1409 |
1462 return autocomplete_syncable_service_; | 1410 return autocomplete_syncable_service_; |
1463 } | 1411 } |
1464 | |
1465 | |
1466 //////////////////////////////////////////////////////////////////////////////// | |
1467 // | |
1468 // WebDataRequest implementation. | |
1469 // | |
1470 //////////////////////////////////////////////////////////////////////////////// | |
1471 | |
1472 WebDataService::WebDataRequest::WebDataRequest(WebDataService* service, | |
1473 Handle handle, | |
1474 WebDataServiceConsumer* consumer) | |
1475 : service_(service), | |
1476 handle_(handle), | |
1477 cancelled_(false), | |
1478 consumer_(consumer), | |
1479 result_(NULL) { | |
1480 message_loop_ = MessageLoop::current(); | |
1481 } | |
1482 | |
1483 WebDataService::WebDataRequest::~WebDataRequest() { | |
1484 delete result_; | |
1485 } | |
1486 | |
1487 WebDataService::Handle WebDataService::WebDataRequest::GetHandle() const { | |
1488 return handle_; | |
1489 } | |
1490 | |
1491 bool WebDataService::WebDataRequest::IsCancelled( | |
1492 WebDataServiceConsumer** consumer) const { | |
1493 base::AutoLock l(cancel_lock_); | |
1494 if (consumer) | |
1495 *consumer = consumer_; | |
1496 return cancelled_; | |
1497 } | |
1498 | |
1499 void WebDataService::WebDataRequest::Cancel() { | |
1500 base::AutoLock l(cancel_lock_); | |
1501 cancelled_ = true; | |
1502 consumer_ = NULL; | |
1503 } | |
1504 | |
1505 void WebDataService::WebDataRequest::SetResult(WDTypedResult* r) { | |
1506 result_ = r; | |
1507 } | |
1508 | |
1509 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { | |
1510 return result_; | |
1511 } | |
1512 | |
1513 void WebDataService::WebDataRequest::RequestComplete() { | |
1514 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, | |
1515 service_.get(), handle_)); | |
1516 } | |
OLD | NEW |