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

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

Issue 11783091: Remove GenericRequest templates from WebDataService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style fixes Created 7 years, 11 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 // Chromium settings and storage represent user-selected preferences and 5 // Chromium settings and storage represent user-selected preferences and
6 // information and MUST not be extracted, overwritten or modified except 6 // information and MUST not be extracted, overwritten or modified except
7 // through Chromium defined APIs. 7 // through Chromium defined APIs.
8 8
9 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ 9 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
10 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ 10 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
11 11
12 #include <map> 12 #include <map>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/callback.h"
erikwright (departed) 2013/01/14 15:51:36 I don't see why this is required here, but if it i
16 #include "base/callback_forward.h" 17 #include "base/callback_forward.h"
17 #include "base/file_path.h" 18 #include "base/file_path.h"
18 #include "base/location.h" 19 #include "base/location.h"
19 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
20 #include "base/sequenced_task_runner_helpers.h" 21 #include "base/sequenced_task_runner_helpers.h"
21 #include "base/synchronization/lock.h" 22 #include "base/synchronization/lock.h"
22 #include "chrome/browser/api/webdata/autofill_web_data_service.h" 23 #include "chrome/browser/api/webdata/autofill_web_data_service.h"
23 #include "chrome/browser/api/webdata/web_data_results.h" 24 #include "chrome/browser/api/webdata/web_data_results.h"
24 #include "chrome/browser/api/webdata/web_data_service_base.h" 25 #include "chrome/browser/api/webdata/web_data_service_base.h"
25 #include "chrome/browser/api/webdata/web_data_service_consumer.h" 26 #include "chrome/browser/api/webdata/web_data_service_consumer.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 64
64 65
65 //////////////////////////////////////////////////////////////////////////////// 66 ////////////////////////////////////////////////////////////////////////////////
66 // 67 //
67 // WebDataService results 68 // WebDataService results
68 // 69 //
69 //////////////////////////////////////////////////////////////////////////////// 70 ////////////////////////////////////////////////////////////////////////////////
70 71
71 typedef std::vector<AutofillChange> AutofillChangeList; 72 typedef std::vector<AutofillChange> AutofillChangeList;
72 73
74 typedef base::Callback<scoped_ptr<WDTypedResult>(void)> ResultTask;
75
73 // Result from GetWebAppImages. 76 // Result from GetWebAppImages.
74 struct WDAppImagesResult { 77 struct WDAppImagesResult {
75 WDAppImagesResult(); 78 WDAppImagesResult();
76 ~WDAppImagesResult(); 79 ~WDAppImagesResult();
77 80
78 // True if SetWebAppHasAllImages(true) was invoked. 81 // True if SetWebAppHasAllImages(true) was invoked.
79 bool has_all_images; 82 bool has_all_images;
80 83
81 // The images, may be empty. 84 // The images, may be empty.
82 std::vector<SkBitmap> images; 85 std::vector<SkBitmap> images;
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 ////////////////////////////////////////////////////////////////////////////// 334 //////////////////////////////////////////////////////////////////////////////
332 // 335 //
333 // The following methods are only invoked in the web data service thread. 336 // The following methods are only invoked in the web data service thread.
334 // 337 //
335 ////////////////////////////////////////////////////////////////////////////// 338 //////////////////////////////////////////////////////////////////////////////
336 private: 339 private:
337 friend struct content::BrowserThread::DeleteOnThread< 340 friend struct content::BrowserThread::DeleteOnThread<
338 content::BrowserThread::UI>; 341 content::BrowserThread::UI>;
339 friend class base::DeleteHelper<WebDataService>; 342 friend class base::DeleteHelper<WebDataService>;
340 343
341 typedef GenericRequest2<std::vector<const TemplateURLData*>,
342 KeywordTable::Keywords> SetKeywordsRequest;
343
344 // Invoked on the main thread if initializing the db fails. 344 // Invoked on the main thread if initializing the db fails.
345 void DBInitFailed(sql::InitStatus init_status); 345 void DBInitFailed(sql::InitStatus init_status);
346 346
347 // Initialize the database, if it hasn't already been initialized. 347 // Initialize the database, if it hasn't already been initialized.
348 void InitializeDatabaseIfNecessary(); 348 void InitializeDatabaseIfNecessary();
349 349
350 // Initialize any syncable services. 350 // Initialize any syncable services.
351 void InitializeSyncableServices(); 351 void InitializeSyncableServices();
352 352
353 // The notification method. 353 // The notification method.
354 void NotifyDatabaseLoadedOnUIThread(); 354 void NotifyDatabaseLoadedOnUIThread();
355 355
356 // Commit any pending transaction and deletes the database. 356 // Commit any pending transaction and deletes the database.
357 void ShutdownDatabase(); 357 void ShutdownDatabase();
358 358
359 // Deletes the syncable services. 359 // Deletes the syncable services.
360 void ShutdownSyncableServices(); 360 void ShutdownSyncableServices();
361 361
362 // Commit the current transaction and creates a new one. 362 // Commit the current transaction and creates a new one.
363 void Commit(); 363 void Commit();
364 364
365 // Schedule a task on our worker thread. 365 // Schedule a task on our worker thread.
366 void ScheduleTask(const tracked_objects::Location& from_here, 366 void ScheduleTask(const tracked_objects::Location& from_here,
367 const base::Closure& task); 367 const base::Closure& task);
368 368
369 void ScheduleDBTask(const tracked_objects::Location& from_here,
370 const base::Closure& task);
371
372 WebDataService::Handle ScheduleDBTaskWithResult(
373 const tracked_objects::Location& from_here,
374 const ResultTask& task,
375 WebDataServiceConsumer* consumer);
376
377 void DBTaskWrapper(const base::Closure& task,
378 WebDataRequest* request);
379
380 void DBResultTaskWrapper(const ResultTask& task,
381 WebDataRequest* request);
382
369 // Schedule a commit if one is not already pending. 383 // Schedule a commit if one is not already pending.
370 void ScheduleCommit(); 384 void ScheduleCommit();
371 385
372 ////////////////////////////////////////////////////////////////////////////// 386 //////////////////////////////////////////////////////////////////////////////
373 // 387 //
374 // Keywords. 388 // Keywords.
375 // 389 //
376 ////////////////////////////////////////////////////////////////////////////// 390 //////////////////////////////////////////////////////////////////////////////
377 void AddKeywordImpl(GenericRequest<TemplateURLData>* request); 391 void AddKeywordImpl(const TemplateURLData& data);
378 void RemoveKeywordImpl(GenericRequest<TemplateURLID>* request); 392 void RemoveKeywordImpl(TemplateURLID id);
379 void UpdateKeywordImpl(GenericRequest<TemplateURLData>* request); 393 void UpdateKeywordImpl(const TemplateURLData& data);
380 void GetKeywordsImpl(WebDataRequest* request); 394 scoped_ptr<WDTypedResult> GetKeywordsImpl();
381 void SetDefaultSearchProviderImpl(GenericRequest<TemplateURLID>* r); 395 void SetDefaultSearchProviderImpl(TemplateURLID r);
382 void SetBuiltinKeywordVersionImpl(GenericRequest<int>* r); 396 void SetBuiltinKeywordVersionImpl(int version);
383 397
384 ////////////////////////////////////////////////////////////////////////////// 398 //////////////////////////////////////////////////////////////////////////////
385 // 399 //
386 // Web Apps. 400 // Web Apps.
387 // 401 //
388 ////////////////////////////////////////////////////////////////////////////// 402 //////////////////////////////////////////////////////////////////////////////
389 void SetWebAppImageImpl(GenericRequest2<GURL, SkBitmap>* request); 403
390 void SetWebAppHasAllImagesImpl(GenericRequest2<GURL, bool>* request); 404 void SetWebAppImageImpl(const GURL& app_url, const SkBitmap& image);
391 void RemoveWebAppImpl(GenericRequest<GURL>* request); 405 void SetWebAppHasAllImagesImpl(const GURL& app_url, bool has_all_images);
392 void GetWebAppImagesImpl(GenericRequest<GURL>* request); 406 void RemoveWebAppImpl(const GURL& app_url);
407 scoped_ptr<WDTypedResult> GetWebAppImagesImpl(const GURL& app_url);
393 408
394 ////////////////////////////////////////////////////////////////////////////// 409 //////////////////////////////////////////////////////////////////////////////
395 // 410 //
396 // Web Intents. 411 // Web Intents.
397 // 412 //
398 ////////////////////////////////////////////////////////////////////////////// 413 //////////////////////////////////////////////////////////////////////////////
399 void AddWebIntentServiceImpl( 414 void AddWebIntentServiceImpl(
400 GenericRequest<webkit_glue::WebIntentServiceData>* request); 415 const webkit_glue::WebIntentServiceData& service);
401 void RemoveWebIntentServiceImpl( 416 void RemoveWebIntentServiceImpl(
402 GenericRequest<webkit_glue::WebIntentServiceData>* request); 417 const webkit_glue::WebIntentServiceData& service);
403 void GetWebIntentServicesImpl(GenericRequest<string16>* request); 418 scoped_ptr<WDTypedResult> GetWebIntentServicesImpl(const string16& action);
404 void GetWebIntentServicesForURLImpl(GenericRequest<string16>* request); 419 scoped_ptr<WDTypedResult> GetWebIntentServicesForURLImpl(
405 void GetAllWebIntentServicesImpl(GenericRequest<std::string>* request); 420 const string16& service_url);
406 void AddDefaultWebIntentServiceImpl( 421 scoped_ptr<WDTypedResult> GetAllWebIntentServicesImpl();
407 GenericRequest<DefaultWebIntentService>* request); 422 void AddDefaultWebIntentServiceImpl(const DefaultWebIntentService& service);
408 void RemoveDefaultWebIntentServiceImpl( 423 void RemoveDefaultWebIntentServiceImpl(
409 GenericRequest<DefaultWebIntentService>* request); 424 const DefaultWebIntentService& service);
410 void RemoveWebIntentServiceDefaultsImpl(GenericRequest<GURL>* request); 425 void RemoveWebIntentServiceDefaultsImpl(const GURL& service_url);
411 void GetDefaultWebIntentServicesForActionImpl( 426 scoped_ptr<WDTypedResult> GetDefaultWebIntentServicesForActionImpl(
412 GenericRequest<string16>* request); 427 const string16& action);
413 void GetAllDefaultWebIntentServicesImpl(GenericRequest<std::string>* request); 428 scoped_ptr<WDTypedResult> GetAllDefaultWebIntentServicesImpl();
414 429
415 ////////////////////////////////////////////////////////////////////////////// 430 //////////////////////////////////////////////////////////////////////////////
416 // 431 //
417 // Token Service. 432 // Token Service.
418 // 433 //
419 ////////////////////////////////////////////////////////////////////////////// 434 //////////////////////////////////////////////////////////////////////////////
420 435
421 void RemoveAllTokensImpl(GenericRequest<std::string>* request); 436 void RemoveAllTokensImpl();
422 void SetTokenForServiceImpl( 437 void SetTokenForServiceImpl(const std::string& service,
423 GenericRequest2<std::string, std::string>* request); 438 const std::string& token);
424 void GetAllTokensImpl(GenericRequest<std::string>* request); 439 scoped_ptr<WDTypedResult> GetAllTokensImpl();
425 440
426 #if defined(OS_WIN) 441 #if defined(OS_WIN)
427 ////////////////////////////////////////////////////////////////////////////// 442 //////////////////////////////////////////////////////////////////////////////
428 // 443 //
429 // Password manager. 444 // Password manager.
430 // 445 //
431 ////////////////////////////////////////////////////////////////////////////// 446 //////////////////////////////////////////////////////////////////////////////
432 void AddIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request); 447 void AddIE7LoginImpl(const IE7PasswordInfo& info);
433 void RemoveIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request); 448 void RemoveIE7LoginImpl(const IE7PasswordInfo& info);
434 void GetIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request); 449 scoped_ptr<WDTypedResult> GetIE7LoginImpl(const IE7PasswordInfo& info);
435 #endif // defined(OS_WIN) 450 #endif // defined(OS_WIN)
436 451
437 ////////////////////////////////////////////////////////////////////////////// 452 //////////////////////////////////////////////////////////////////////////////
438 // 453 //
439 // Autofill. 454 // Autofill.
440 // 455 //
441 ////////////////////////////////////////////////////////////////////////////// 456 //////////////////////////////////////////////////////////////////////////////
442 void AddFormElementsImpl( 457 void AddFormElementsImpl(const std::vector<FormFieldData>& fields);
443 GenericRequest<std::vector<FormFieldData> >* request); 458 scoped_ptr<WDTypedResult> GetFormValuesForElementNameImpl(
444 void GetFormValuesForElementNameImpl(WebDataRequest* request,
445 const string16& name, const string16& prefix, int limit); 459 const string16& name, const string16& prefix, int limit);
446 void RemoveFormElementsAddedBetweenImpl( 460 void RemoveFormElementsAddedBetweenImpl(
447 GenericRequest2<base::Time, base::Time>* request); 461 const base::Time& delete_begin, const base::Time& delete_end);
448 void RemoveExpiredFormElementsImpl(WebDataRequest* request); 462 void RemoveExpiredFormElementsImpl();
449 void RemoveFormValueForElementNameImpl( 463 void RemoveFormValueForElementNameImpl(const string16& name,
450 GenericRequest2<string16, string16>* request); 464 const string16& value);
451 void AddAutofillProfileImpl(GenericRequest<AutofillProfile>* request); 465 void AddAutofillProfileImpl(const AutofillProfile& profile);
452 void UpdateAutofillProfileImpl(GenericRequest<AutofillProfile>* request); 466 void UpdateAutofillProfileImpl(const AutofillProfile& profile);
453 void RemoveAutofillProfileImpl(GenericRequest<std::string>* request); 467 void RemoveAutofillProfileImpl(const std::string& guid);
454 void GetAutofillProfilesImpl(WebDataRequest* request); 468 scoped_ptr<WDTypedResult> GetAutofillProfilesImpl();
455 void EmptyMigrationTrashImpl(GenericRequest<bool>* request); 469 void EmptyMigrationTrashImpl(bool notify_sync);
456 void AddCreditCardImpl(GenericRequest<CreditCard>* request); 470 void AddCreditCardImpl(const CreditCard& credit_card);
457 void UpdateCreditCardImpl(GenericRequest<CreditCard>* request); 471 void UpdateCreditCardImpl(const CreditCard& credit_card);
458 void RemoveCreditCardImpl(GenericRequest<std::string>* request); 472 void RemoveCreditCardImpl(const std::string& guid);
459 void GetCreditCardsImpl(WebDataRequest* request); 473 scoped_ptr<WDTypedResult> GetCreditCardsImpl();
460 void RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl( 474 void RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl(
461 GenericRequest2<base::Time, base::Time>* request); 475 const base::Time& delete_begin, const base::Time& delete_end);
462 476
463 // Callbacks to ensure that sensitive info is destroyed if request is 477 // Callbacks to ensure that sensitive info is destroyed if request is
464 // cancelled. 478 // cancelled.
465 void DestroyAutofillProfileResult(const WDTypedResult* result); 479 void DestroyAutofillProfileResult(const WDTypedResult* result);
466 void DestroyAutofillCreditCardResult(const WDTypedResult* result); 480 void DestroyAutofillCreditCardResult(const WDTypedResult* result);
467 481
468 // True once initialization has started. 482 // True once initialization has started.
469 bool is_running_; 483 bool is_running_;
470 484
471 // The path with which to initialize the database. 485 // The path with which to initialize the database.
(...skipping 21 matching lines...) Expand all
493 // Whether we should commit the database. 507 // Whether we should commit the database.
494 bool should_commit_; 508 bool should_commit_;
495 509
496 // MessageLoop the WebDataService is created on. 510 // MessageLoop the WebDataService is created on.
497 MessageLoop* main_loop_; 511 MessageLoop* main_loop_;
498 512
499 DISALLOW_COPY_AND_ASSIGN(WebDataService); 513 DISALLOW_COPY_AND_ASSIGN(WebDataService);
500 }; 514 };
501 515
502 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ 516 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698