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

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

Issue 1701012: Cleanup: Order the methods in WebDataService. Rename a method to match current style. (Closed)
Patch Set: Fix test compile. Created 10 years, 8 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ 5 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
6 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ 6 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 mutable T value_; 149 mutable T value_;
150 DISALLOW_EVIL_CONSTRUCTORS(WDObjectResult); 150 DISALLOW_EVIL_CONSTRUCTORS(WDObjectResult);
151 }; 151 };
152 152
153 class WebDataServiceConsumer; 153 class WebDataServiceConsumer;
154 154
155 class WebDataService 155 class WebDataService
156 : public base::RefCountedThreadSafe<WebDataService, 156 : public base::RefCountedThreadSafe<WebDataService,
157 ChromeThread::DeleteOnUIThread> { 157 ChromeThread::DeleteOnUIThread> {
158 public: 158 public:
159
160 // All requests return an opaque handle of the following type. 159 // All requests return an opaque handle of the following type.
161 typedef int Handle; 160 typedef int Handle;
162 161
163 WebDataService();
164
165 // Initializes the web data service. Returns false on failure
166 // Takes the path of the profile directory as its argument.
167 bool Init(const FilePath& profile_path);
168
169 // Shutdown the web data service. The service can no longer be used after this
170 // call.
171 void Shutdown();
172
173 // Returns false if Shutdown() has been called.
174 bool IsRunning() const;
175
176 // Unloads the database without actually shutting down the service. This can
177 // be used to temporarily reduce the browser process' memory footprint.
178 void UnloadDatabase();
179
180 ////////////////////////////////////////////////////////////////////////////// 162 //////////////////////////////////////////////////////////////////////////////
181 // 163 //
182 // Internal requests 164 // Internal requests
183 // 165 //
184 // Every request is processed using a request object. The object contains 166 // Every request is processed using a request object. The object contains
185 // both the request parameters and the results. 167 // both the request parameters and the results.
186 ////////////////////////////////////////////////////////////////////////////// 168 //////////////////////////////////////////////////////////////////////////////
187 class WebDataRequest { 169 class WebDataRequest {
188 public: 170 public:
189 WebDataRequest(WebDataService* service, 171 WebDataRequest(WebDataService* service,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 248
267 U GetArgument2() { 249 U GetArgument2() {
268 return arg2_; 250 return arg2_;
269 } 251 }
270 252
271 private: 253 private:
272 T arg1_; 254 T arg1_;
273 U arg2_; 255 U arg2_;
274 }; 256 };
275 257
258 WebDataService();
259
260 // Initializes the web data service. Returns false on failure
261 // Takes the path of the profile directory as its argument.
262 bool Init(const FilePath& profile_path);
263
264 // Shutdown the web data service. The service can no longer be used after this
265 // call.
266 void Shutdown();
267
268 // Returns false if Shutdown() has been called.
269 bool IsRunning() const;
270
271 // Unloads the database without actually shutting down the service. This can
272 // be used to temporarily reduce the browser process' memory footprint.
273 void UnloadDatabase();
274
275 // Cancel any pending request. You need to call this method if your
276 // WebDataServiceConsumer is about to be deleted.
277 void CancelRequest(Handle h);
278
279 virtual bool IsDatabaseLoaded();
280 virtual WebDatabase* GetDatabase();
281
276 ////////////////////////////////////////////////////////////////////////////// 282 //////////////////////////////////////////////////////////////////////////////
277 // 283 //
278 // Keywords 284 // Keywords
279 // 285 //
280 ////////////////////////////////////////////////////////////////////////////// 286 //////////////////////////////////////////////////////////////////////////////
281 287
282 // As the database processes requests at a later date, all deletion is 288 // As the database processes requests at a later date, all deletion is
283 // done on the background thread. 289 // done on the background thread.
284 // 290 //
285 // Many of the keyword related methods do not return a handle. This is because 291 // Many of the keyword related methods do not return a handle. This is because
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 330
325 ////////////////////////////////////////////////////////////////////////////// 331 //////////////////////////////////////////////////////////////////////////////
326 // 332 //
327 // Password manager 333 // Password manager
328 // NOTE: These methods are all deprecated; new clients should use 334 // NOTE: These methods are all deprecated; new clients should use
329 // PasswordStore. These are only still here because Windows is (temporarily) 335 // PasswordStore. These are only still here because Windows is (temporarily)
330 // still using them for its PasswordStore implementation. 336 // still using them for its PasswordStore implementation.
331 // 337 //
332 ////////////////////////////////////////////////////////////////////////////// 338 //////////////////////////////////////////////////////////////////////////////
333 339
340 // Adds |form| to the list of remembered password forms.
341 void AddLogin(const webkit_glue::PasswordForm& form);
342
334 // Updates the remembered password form. 343 // Updates the remembered password form.
335 void UpdateLogin(const webkit_glue::PasswordForm& form); 344 void UpdateLogin(const webkit_glue::PasswordForm& form);
336 345
337 // Adds |form| to the list of remembered password forms.
338 void AddLogin(const webkit_glue::PasswordForm& form);
339
340 // Removes |form| from the list of remembered password forms. 346 // Removes |form| from the list of remembered password forms.
341 void RemoveLogin(const webkit_glue::PasswordForm& form); 347 void RemoveLogin(const webkit_glue::PasswordForm& form);
342 348
343 // Removes all logins created in the specified daterange 349 // Removes all logins created in the specified daterange
344 void RemoveLoginsCreatedBetween(const base::Time& delete_begin, 350 void RemoveLoginsCreatedBetween(const base::Time& delete_begin,
345 const base::Time& delete_end); 351 const base::Time& delete_end);
346 352
347 // Removes all logins created on or after the date passed in. 353 // Removes all logins created on or after the date passed in.
348 void RemoveLoginsCreatedAfter(const base::Time& delete_begin); 354 void RemoveLoginsCreatedAfter(const base::Time& delete_begin);
349 355
(...skipping 25 matching lines...) Expand all
375 void RemoveIE7Login(const IE7PasswordInfo& info); 381 void RemoveIE7Login(const IE7PasswordInfo& info);
376 382
377 // Get the login matching the information in |info|. |consumer| will be 383 // Get the login matching the information in |info|. |consumer| will be
378 // notified when the request is done. The result is of type 384 // notified when the request is done. The result is of type
379 // WDResult<IE7PasswordInfo>. 385 // WDResult<IE7PasswordInfo>.
380 // If there is no match, the fields of the IE7PasswordInfo will be empty. 386 // If there is no match, the fields of the IE7PasswordInfo will be empty.
381 Handle GetIE7Login(const IE7PasswordInfo& info, 387 Handle GetIE7Login(const IE7PasswordInfo& info,
382 WebDataServiceConsumer* consumer); 388 WebDataServiceConsumer* consumer);
383 #endif // defined(OS_WIN) 389 #endif // defined(OS_WIN)
384 390
385 // Cancel any pending request. You need to call this method if your
386 // WebDataServiceConsumer is about to be deleted.
387 void CancelRequest(Handle h);
388
389 ////////////////////////////////////////////////////////////////////////////// 391 //////////////////////////////////////////////////////////////////////////////
390 // 392 //
391 // Autofill. 393 // AutoFill.
392 // 394 //
393 ////////////////////////////////////////////////////////////////////////////// 395 //////////////////////////////////////////////////////////////////////////////
394 396
395 // Schedules a task to add form elements to the web database. 397 // Schedules a task to add form fields to the web database.
396 void AddFormFieldValues( 398 void AddFormFields(const std::vector<webkit_glue::FormField>& fields);
397 const std::vector<webkit_glue::FormField>& elements);
398 399
399 // Initiates the request for a vector of values which have been entered in 400 // Initiates the request for a vector of values which have been entered in
400 // form input fields named |name|. The method OnWebDataServiceRequestDone of 401 // form input fields named |name|. The method OnWebDataServiceRequestDone of
401 // |consumer| gets called back when the request is finished, with the vector 402 // |consumer| gets called back when the request is finished, with the vector
402 // included in the argument |result|. 403 // included in the argument |result|.
403 Handle GetFormValuesForElementName(const string16& name, 404 Handle GetFormValuesForElementName(const string16& name,
404 const string16& prefix, 405 const string16& prefix,
405 int limit, 406 int limit,
406 WebDataServiceConsumer* consumer); 407 WebDataServiceConsumer* consumer);
407 408
408 // Removes form elements recorded for autofill from the database. 409 // Removes form elements recorded for Autocomplete from the database.
409 void RemoveFormElementsAddedBetween(const base::Time& delete_begin, 410 void RemoveFormElementsAddedBetween(const base::Time& delete_begin,
410 const base::Time& delete_end); 411 const base::Time& delete_end);
411 void RemoveFormValueForElementName(const string16& name, 412 void RemoveFormValueForElementName(const string16& name,
412 const string16& value); 413 const string16& value);
413 414
414 // Schedules a task to add an AutoFill profile to the web database. 415 // Schedules a task to add an AutoFill profile to the web database.
415 void AddAutoFillProfile(const AutoFillProfile& profile); 416 void AddAutoFillProfile(const AutoFillProfile& profile);
416 417
417 // Schedules a task to update an AutoFill profile in the web database. 418 // Schedules a task to update an AutoFill profile in the web database.
418 void UpdateAutoFillProfile(const AutoFillProfile& profile); 419 void UpdateAutoFillProfile(const AutoFillProfile& profile);
(...skipping 22 matching lines...) Expand all
441 // OnWebDataServiceRequestDone of |consumer| gets called when the request is 442 // OnWebDataServiceRequestDone of |consumer| gets called when the request is
442 // finished, with the credit cards included in the argument |result|. The 443 // finished, with the credit cards included in the argument |result|. The
443 // consumer owns the credit cards. 444 // consumer owns the credit cards.
444 Handle GetCreditCards(WebDataServiceConsumer* consumer); 445 Handle GetCreditCards(WebDataServiceConsumer* consumer);
445 446
446 // Testing 447 // Testing
447 #ifdef UNIT_TEST 448 #ifdef UNIT_TEST
448 void set_failed_init(bool value) { failed_init_ = value; } 449 void set_failed_init(bool value) { failed_init_ = value; }
449 #endif 450 #endif
450 451
451 virtual bool IsDatabaseLoaded();
452 virtual WebDatabase* GetDatabase();
453
454 protected: 452 protected:
455 virtual ~WebDataService();
456
457 friend class TemplateURLModelTest; 453 friend class TemplateURLModelTest;
458 friend class TemplateURLModelTestingProfile; 454 friend class TemplateURLModelTestingProfile;
459 friend class WebDataServiceTest; 455 friend class WebDataServiceTest;
460 friend class WebDataRequest; 456 friend class WebDataRequest;
461 457
458 virtual ~WebDataService();
459
462 // This is invoked by the unit test; path is the path of the Web Data file. 460 // This is invoked by the unit test; path is the path of the Web Data file.
463 bool InitWithPath(const FilePath& path); 461 bool InitWithPath(const FilePath& path);
464 462
465 // Invoked by request implementations when a request has been processed. 463 // Invoked by request implementations when a request has been processed.
466 void RequestCompleted(Handle h); 464 void RequestCompleted(Handle h);
467 465
468 // Register the request as a pending request. 466 // Register the request as a pending request.
469 void RegisterRequest(WebDataRequest* request); 467 void RegisterRequest(WebDataRequest* request);
470 468
471 ////////////////////////////////////////////////////////////////////////////// 469 //////////////////////////////////////////////////////////////////////////////
(...skipping 18 matching lines...) Expand all
490 488
491 // The notification method. 489 // The notification method.
492 void NotifyDatabaseLoadedOnUIThread(); 490 void NotifyDatabaseLoadedOnUIThread();
493 491
494 // Commit any pending transaction and deletes the database. 492 // Commit any pending transaction and deletes the database.
495 void ShutdownDatabase(); 493 void ShutdownDatabase();
496 494
497 // Commit the current transaction and creates a new one. 495 // Commit the current transaction and creates a new one.
498 void Commit(); 496 void Commit();
499 497
498 // Schedule a task on our worker thread.
499 void ScheduleTask(Task* t);
500
501 // Schedule a commit if one is not already pending.
502 void ScheduleCommit();
503
504 // Return the next request handle.
505 int GetNextRequestHandle();
506
500 ////////////////////////////////////////////////////////////////////////////// 507 //////////////////////////////////////////////////////////////////////////////
501 // 508 //
502 // Keywords. 509 // Keywords.
503 // 510 //
504 ////////////////////////////////////////////////////////////////////////////// 511 //////////////////////////////////////////////////////////////////////////////
505 void AddKeywordImpl(GenericRequest<TemplateURL>* request); 512 void AddKeywordImpl(GenericRequest<TemplateURL>* request);
506 void RemoveKeywordImpl(GenericRequest<TemplateURL::IDType>* request); 513 void RemoveKeywordImpl(GenericRequest<TemplateURL::IDType>* request);
507 void UpdateKeywordImpl(GenericRequest<TemplateURL>* request); 514 void UpdateKeywordImpl(GenericRequest<TemplateURL>* request);
508 void GetKeywordsImpl(WebDataRequest* request); 515 void GetKeywordsImpl(WebDataRequest* request);
509 void SetDefaultSearchProviderImpl(GenericRequest<TemplateURL::IDType>* r); 516 void SetDefaultSearchProviderImpl(GenericRequest<TemplateURL::IDType>* r);
510 void SetBuiltinKeywordVersionImpl(GenericRequest<int>* r); 517 void SetBuiltinKeywordVersionImpl(GenericRequest<int>* r);
511 518
512 ////////////////////////////////////////////////////////////////////////////// 519 //////////////////////////////////////////////////////////////////////////////
513 // 520 //
521 // Web Apps.
522 //
523 //////////////////////////////////////////////////////////////////////////////
524 void SetWebAppImageImpl(GenericRequest2<GURL, SkBitmap>* request);
525 void SetWebAppHasAllImagesImpl(GenericRequest2<GURL, bool>* request);
526 void RemoveWebAppImpl(GenericRequest<GURL>* request);
527 void GetWebAppImagesImpl(GenericRequest<GURL>* request);
528
529 //////////////////////////////////////////////////////////////////////////////
530 //
514 // Password manager. 531 // Password manager.
515 // 532 //
516 ////////////////////////////////////////////////////////////////////////////// 533 //////////////////////////////////////////////////////////////////////////////
517 void AddLoginImpl(GenericRequest<webkit_glue::PasswordForm>* request); 534 void AddLoginImpl(GenericRequest<webkit_glue::PasswordForm>* request);
518 void UpdateLoginImpl(GenericRequest<webkit_glue::PasswordForm>* request); 535 void UpdateLoginImpl(GenericRequest<webkit_glue::PasswordForm>* request);
519 void RemoveLoginImpl(GenericRequest<webkit_glue::PasswordForm>* request); 536 void RemoveLoginImpl(GenericRequest<webkit_glue::PasswordForm>* request);
520 void RemoveLoginsCreatedBetweenImpl( 537 void RemoveLoginsCreatedBetweenImpl(
521 GenericRequest2<base::Time, base::Time>* request); 538 GenericRequest2<base::Time, base::Time>* request);
522 void GetLoginsImpl(GenericRequest<webkit_glue::PasswordForm>* request); 539 void GetLoginsImpl(GenericRequest<webkit_glue::PasswordForm>* request);
523 void GetAutofillableLoginsImpl(WebDataRequest* request); 540 void GetAutofillableLoginsImpl(WebDataRequest* request);
524 void GetBlacklistLoginsImpl(WebDataRequest* request); 541 void GetBlacklistLoginsImpl(WebDataRequest* request);
525 #if defined(OS_WIN) 542 #if defined(OS_WIN)
526 void AddIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request); 543 void AddIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request);
527 void RemoveIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request); 544 void RemoveIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request);
528 void GetIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request); 545 void GetIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request);
529 #endif // defined(OS_WIN) 546 #endif // defined(OS_WIN)
530 547
531 ////////////////////////////////////////////////////////////////////////////// 548 //////////////////////////////////////////////////////////////////////////////
532 // 549 //
533 // Autofill. 550 // AutoFill.
534 // 551 //
535 ////////////////////////////////////////////////////////////////////////////// 552 //////////////////////////////////////////////////////////////////////////////
536 void AddFormFieldValuesImpl( 553 void AddFormElementsImpl(
537 GenericRequest<std::vector<webkit_glue::FormField> >* request); 554 GenericRequest<std::vector<webkit_glue::FormField> >* request);
538 void GetFormValuesForElementNameImpl(WebDataRequest* request, 555 void GetFormValuesForElementNameImpl(WebDataRequest* request,
539 const string16& name, const string16& prefix, int limit); 556 const string16& name, const string16& prefix, int limit);
540 void RemoveFormElementsAddedBetweenImpl( 557 void RemoveFormElementsAddedBetweenImpl(
541 GenericRequest2<base::Time, base::Time>* request); 558 GenericRequest2<base::Time, base::Time>* request);
542 void RemoveFormValueForElementNameImpl( 559 void RemoveFormValueForElementNameImpl(
543 GenericRequest2<string16, string16>* request); 560 GenericRequest2<string16, string16>* request);
544 void AddAutoFillProfileImpl(GenericRequest<AutoFillProfile>* request); 561 void AddAutoFillProfileImpl(GenericRequest<AutoFillProfile>* request);
545 void UpdateAutoFillProfileImpl(GenericRequest<AutoFillProfile>* request); 562 void UpdateAutoFillProfileImpl(GenericRequest<AutoFillProfile>* request);
546 void RemoveAutoFillProfileImpl(GenericRequest<int>* request); 563 void RemoveAutoFillProfileImpl(GenericRequest<int>* request);
547 void GetAutoFillProfileForLabelImpl(WebDataRequest* request,
548 const string16& label);
549 void GetAutoFillProfilesImpl(WebDataRequest* request); 564 void GetAutoFillProfilesImpl(WebDataRequest* request);
550 void AddCreditCardImpl(GenericRequest<CreditCard>* request); 565 void AddCreditCardImpl(GenericRequest<CreditCard>* request);
551 void UpdateCreditCardImpl(GenericRequest<CreditCard>* request); 566 void UpdateCreditCardImpl(GenericRequest<CreditCard>* request);
552 void RemoveCreditCardImpl(GenericRequest<int>* request); 567 void RemoveCreditCardImpl(GenericRequest<int>* request);
553 void GetCreditCardForLabelImpl(WebDataRequest* request,
554 const string16& label);
555 void GetCreditCardsImpl(WebDataRequest* request); 568 void GetCreditCardsImpl(WebDataRequest* request);
556 569
557 //////////////////////////////////////////////////////////////////////////////
558 //
559 // Web Apps.
560 //
561 //////////////////////////////////////////////////////////////////////////////
562
563 void SetWebAppImageImpl(GenericRequest2<GURL, SkBitmap>* request);
564
565 void SetWebAppHasAllImagesImpl(GenericRequest2<GURL, bool>* request);
566
567 void RemoveWebAppImpl(GenericRequest<GURL>* request);
568
569 void GetWebAppImagesImpl(GenericRequest<GURL>* request);
570
571 // Schedule a task on our worker thread.
572 void ScheduleTask(Task* t);
573
574 // Schedule a commit if one is not already pending.
575 void ScheduleCommit();
576
577 // Return the next request handle.
578 int GetNextRequestHandle();
579
580 // True once initialization has started. 570 // True once initialization has started.
581 bool is_running_; 571 bool is_running_;
582 572
583 // The path with which to initialize the database. 573 // The path with which to initialize the database.
584 FilePath path_; 574 FilePath path_;
585 575
586 // Our database. 576 // Our database.
587 WebDatabase* db_; 577 WebDatabase* db_;
588 578
589 // Whether the database failed to initialize. We use this to avoid 579 // Whether the database failed to initialize. We use this to avoid
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 // result can be NULL, if no result is expected or if the database could 614 // result can be NULL, if no result is expected or if the database could
625 // not be opened. The result object is destroyed after this call. 615 // not be opened. The result object is destroyed after this call.
626 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, 616 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h,
627 const WDTypedResult* result) = 0; 617 const WDTypedResult* result) = 0;
628 618
629 protected: 619 protected:
630 virtual ~WebDataServiceConsumer() {} 620 virtual ~WebDataServiceConsumer() {}
631 }; 621 };
632 622
633 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ 623 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete_history_manager.cc ('k') | chrome/browser/webdata/web_data_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698