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

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

Issue 10908065: Introduce a couple of abstract bases for WebDataService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to comments Created 8 years, 3 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/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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 namespace { 54 namespace {
55 55
56 // A task used by WebDataService (for Sync mainly) to inform the 56 // A task used by WebDataService (for Sync mainly) to inform the
57 // PersonalDataManager living on the UI thread that it needs to refresh. 57 // PersonalDataManager living on the UI thread that it needs to refresh.
58 void NotifyOfMultipleAutofillChangesTask( 58 void NotifyOfMultipleAutofillChangesTask(
59 const scoped_refptr<WebDataService>& web_data_service) { 59 const scoped_refptr<WebDataService>& web_data_service) {
60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
61 61
62 content::NotificationService::current()->Notify( 62 content::NotificationService::current()->Notify(
63 chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED, 63 chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED,
64 content::Source<WebDataService>(web_data_service.get()), 64 content::Source<WebDataServiceBase>(web_data_service.get()),
65 content::NotificationService::NoDetails()); 65 content::NotificationService::NoDetails());
66 } 66 }
67 67
68 } // namespace 68 } // namespace
69 69
70 WDAppImagesResult::WDAppImagesResult() : has_all_images(false) {} 70 WDAppImagesResult::WDAppImagesResult() : has_all_images(false) {}
71 71
72 WDAppImagesResult::~WDAppImagesResult() {} 72 WDAppImagesResult::~WDAppImagesResult() {}
73 73
74 WDKeywordsResult::WDKeywordsResult() 74 WDKeywordsResult::WDKeywordsResult()
75 : default_search_provider_id(0), 75 : default_search_provider_id(0),
76 builtin_keyword_version(0), 76 builtin_keyword_version(0),
77 backup_valid(false), 77 backup_valid(false),
78 did_default_search_provider_change(false) { 78 did_default_search_provider_change(false) {
79 } 79 }
80 80
81 WDKeywordsResult::~WDKeywordsResult() {} 81 WDKeywordsResult::~WDKeywordsResult() {}
82 82
83 WebDataService::WebDataService() 83 WebDataService::WebDataService()
84 : RefcountedProfileKeyedService(BrowserThread::UI), 84 : is_running_(false),
85 is_running_(false),
86 db_(NULL), 85 db_(NULL),
87 autocomplete_syncable_service_(NULL), 86 autocomplete_syncable_service_(NULL),
88 autofill_profile_syncable_service_(NULL), 87 autofill_profile_syncable_service_(NULL),
89 failed_init_(false), 88 failed_init_(false),
90 should_commit_(false), 89 should_commit_(false),
91 next_request_handle_(1), 90 next_request_handle_(1),
92 main_loop_(MessageLoop::current()) { 91 main_loop_(MessageLoop::current()) {
93 // WebDataService requires DB thread if instantiated. 92 // WebDataService requires DB thread if instantiated.
94 // Set WebDataServiceFactory::GetInstance()->SetTestingFactory(&profile, NULL) 93 // Set WebDataServiceFactory::GetInstance()->SetTestingFactory(&profile, NULL)
95 // if you do not want to instantiate WebDataService in your test. 94 // if you do not want to instantiate WebDataService in your test.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 void WebDataService::CancelRequest(Handle h) { 132 void WebDataService::CancelRequest(Handle h) {
134 base::AutoLock l(pending_lock_); 133 base::AutoLock l(pending_lock_);
135 RequestMap::iterator i = pending_requests_.find(h); 134 RequestMap::iterator i = pending_requests_.find(h);
136 if (i == pending_requests_.end()) { 135 if (i == pending_requests_.end()) {
137 NOTREACHED() << "Canceling a nonexistent web data service request"; 136 NOTREACHED() << "Canceling a nonexistent web data service request";
138 return; 137 return;
139 } 138 }
140 i->second->Cancel(); 139 i->second->Cancel();
141 } 140 }
142 141
142 content::NotificationSource WebDataService::GetNotificationSource() {
143 return content::Source<WebDataService>(this);
144 }
145
143 bool WebDataService::IsDatabaseLoaded() { 146 bool WebDataService::IsDatabaseLoaded() {
144 return db_ != NULL; 147 return db_ != NULL;
145 } 148 }
146 149
147 WebDatabase* WebDataService::GetDatabase() { 150 WebDatabase* WebDataService::GetDatabase() {
148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
149 return db_; 152 return db_;
150 } 153 }
151 154
152 ////////////////////////////////////////////////////////////////////////////// 155 //////////////////////////////////////////////////////////////////////////////
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 } 1515 }
1513 1516
1514 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { 1517 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const {
1515 return result_; 1518 return result_;
1516 } 1519 }
1517 1520
1518 void WebDataService::WebDataRequest::RequestComplete() { 1521 void WebDataService::WebDataRequest::RequestComplete() {
1519 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, 1522 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted,
1520 service_.get(), handle_)); 1523 service_.get(), handle_));
1521 } 1524 }
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