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

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

Issue 10381016: Remove the "autogenerate keyword" bit on TemplateURL. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/webdata/web_data_service.h" 5 #include "chrome/browser/webdata/web_data_service.h"
6 6
7 #include "base/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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
141 return db_; 141 return db_;
142 } 142 }
143 143
144 ////////////////////////////////////////////////////////////////////////////// 144 //////////////////////////////////////////////////////////////////////////////
145 // 145 //
146 // Keywords. 146 // Keywords.
147 // 147 //
148 ////////////////////////////////////////////////////////////////////////////// 148 //////////////////////////////////////////////////////////////////////////////
149 149
150 void WebDataService::AddKeyword(const TemplateURL& url) { 150 void WebDataService::AddKeyword(const TemplateURLData& data) {
151 // Ensure that the keyword is already generated (and cached) before caching 151 GenericRequest<TemplateURLData>* request =
152 // the TemplateURL for use on another keyword. 152 new GenericRequest<TemplateURLData>(this, GetNextRequestHandle(), NULL,
153 url.EnsureKeyword(); 153 data);
154 GenericRequest<TemplateURL>* request =
155 new GenericRequest<TemplateURL>(this, GetNextRequestHandle(), NULL, url);
156 RegisterRequest(request); 154 RegisterRequest(request);
157 ScheduleTask(FROM_HERE, Bind(&WebDataService::AddKeywordImpl, this, request)); 155 ScheduleTask(FROM_HERE, Bind(&WebDataService::AddKeywordImpl, this, request));
158 } 156 }
159 157
160 void WebDataService::RemoveKeyword(TemplateURLID id) { 158 void WebDataService::RemoveKeyword(TemplateURLID id) {
161 GenericRequest<TemplateURLID>* request = 159 GenericRequest<TemplateURLID>* request =
162 new GenericRequest<TemplateURLID>(this, GetNextRequestHandle(), NULL, id); 160 new GenericRequest<TemplateURLID>(this, GetNextRequestHandle(), NULL, id);
163 RegisterRequest(request); 161 RegisterRequest(request);
164 ScheduleTask(FROM_HERE, 162 ScheduleTask(FROM_HERE,
165 Bind(&WebDataService::RemoveKeywordImpl, this, request)); 163 Bind(&WebDataService::RemoveKeywordImpl, this, request));
166 } 164 }
167 165
168 void WebDataService::UpdateKeyword(const TemplateURL& url) { 166 void WebDataService::UpdateKeyword(const TemplateURLData& data) {
169 // Ensure that the keyword is already generated (and cached) before caching 167 GenericRequest<TemplateURLData>* request =
170 // the TemplateURL for use on another keyword. 168 new GenericRequest<TemplateURLData>(this, GetNextRequestHandle(), NULL,
171 url.EnsureKeyword(); 169 data);
172 GenericRequest<TemplateURL>* request =
173 new GenericRequest<TemplateURL>(this, GetNextRequestHandle(), NULL, url);
174 RegisterRequest(request); 170 RegisterRequest(request);
175 ScheduleTask(FROM_HERE, 171 ScheduleTask(FROM_HERE,
176 Bind(&WebDataService::UpdateKeywordImpl, this, request)); 172 Bind(&WebDataService::UpdateKeywordImpl, this, request));
177 } 173 }
178 174
179 WebDataService::Handle WebDataService::GetKeywords( 175 WebDataService::Handle WebDataService::GetKeywords(
180 WebDataServiceConsumer* consumer) { 176 WebDataServiceConsumer* consumer) {
181 WebDataRequest* request = 177 WebDataRequest* request =
182 new WebDataRequest(this, GetNextRequestHandle(), consumer); 178 new WebDataRequest(this, GetNextRequestHandle(), consumer);
183 RegisterRequest(request); 179 RegisterRequest(request);
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 base::AutoLock l(pending_lock_); 728 base::AutoLock l(pending_lock_);
733 return ++next_request_handle_; 729 return ++next_request_handle_;
734 } 730 }
735 731
736 //////////////////////////////////////////////////////////////////////////////// 732 ////////////////////////////////////////////////////////////////////////////////
737 // 733 //
738 // Keywords implementation. 734 // Keywords implementation.
739 // 735 //
740 //////////////////////////////////////////////////////////////////////////////// 736 ////////////////////////////////////////////////////////////////////////////////
741 737
742 void WebDataService::AddKeywordImpl(GenericRequest<TemplateURL>* request) { 738 void WebDataService::AddKeywordImpl(GenericRequest<TemplateURLData>* request) {
743 InitializeDatabaseIfNecessary(); 739 InitializeDatabaseIfNecessary();
744 if (db_ && !request->IsCancelled(NULL)) { 740 if (db_ && !request->IsCancelled(NULL)) {
745 db_->GetKeywordTable()->AddKeyword(request->arg()); 741 db_->GetKeywordTable()->AddKeyword(request->arg());
746 ScheduleCommit(); 742 ScheduleCommit();
747 } 743 }
748 request->RequestComplete(); 744 request->RequestComplete();
749 } 745 }
750 746
751 void WebDataService::RemoveKeywordImpl(GenericRequest<TemplateURLID>* request) { 747 void WebDataService::RemoveKeywordImpl(GenericRequest<TemplateURLID>* request) {
752 InitializeDatabaseIfNecessary(); 748 InitializeDatabaseIfNecessary();
753 if (db_ && !request->IsCancelled(NULL)) { 749 if (db_ && !request->IsCancelled(NULL)) {
754 DCHECK(request->arg()); 750 DCHECK(request->arg());
755 db_->GetKeywordTable()->RemoveKeyword(request->arg()); 751 db_->GetKeywordTable()->RemoveKeyword(request->arg());
756 ScheduleCommit(); 752 ScheduleCommit();
757 } 753 }
758 request->RequestComplete(); 754 request->RequestComplete();
759 } 755 }
760 756
761 void WebDataService::UpdateKeywordImpl(GenericRequest<TemplateURL>* request) { 757 void WebDataService::UpdateKeywordImpl(
758 GenericRequest<TemplateURLData>* request) {
762 InitializeDatabaseIfNecessary(); 759 InitializeDatabaseIfNecessary();
763 if (db_ && !request->IsCancelled(NULL)) { 760 if (db_ && !request->IsCancelled(NULL)) {
764 if (!db_->GetKeywordTable()->UpdateKeyword(request->arg())) { 761 if (!db_->GetKeywordTable()->UpdateKeyword(request->arg())) {
765 NOTREACHED(); 762 NOTREACHED();
766 return; 763 return;
767 } 764 }
768 ScheduleCommit(); 765 ScheduleCommit();
769 } 766 }
770 request->RequestComplete(); 767 request->RequestComplete();
771 } 768 }
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 } 1479 }
1483 1480
1484 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { 1481 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const {
1485 return result_; 1482 return result_;
1486 } 1483 }
1487 1484
1488 void WebDataService::WebDataRequest::RequestComplete() { 1485 void WebDataService::WebDataRequest::RequestComplete() {
1489 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, 1486 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted,
1490 service_.get(), handle_)); 1487 service_.get(), handle_));
1491 } 1488 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698