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

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

Issue 10021008: Reland r131019: Move most TemplateURL data members to a new struct, TemplateURLData. This allows us… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 } // namespace 67 } // namespace
68 68
69 WDAppImagesResult::WDAppImagesResult() : has_all_images(false) {} 69 WDAppImagesResult::WDAppImagesResult() : has_all_images(false) {}
70 70
71 WDAppImagesResult::~WDAppImagesResult() {} 71 WDAppImagesResult::~WDAppImagesResult() {}
72 72
73 WDKeywordsResult::WDKeywordsResult() 73 WDKeywordsResult::WDKeywordsResult()
74 : default_search_provider_id(0), 74 : default_search_provider_id(0),
75 builtin_keyword_version(0) { 75 builtin_keyword_version(0),
76 backup_valid(false),
77 did_default_search_provider_change(false) {
76 } 78 }
77 79
78 WDKeywordsResult::~WDKeywordsResult() {} 80 WDKeywordsResult::~WDKeywordsResult() {}
79 81
80 WebDataService::WebDataService() 82 WebDataService::WebDataService()
81 : is_running_(false), 83 : is_running_(false),
82 db_(NULL), 84 db_(NULL),
83 autocomplete_syncable_service_(NULL), 85 autocomplete_syncable_service_(NULL),
84 autofill_profile_syncable_service_(NULL), 86 autofill_profile_syncable_service_(NULL),
85 failed_init_(false), 87 failed_init_(false),
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // 147 //
146 // Keywords. 148 // Keywords.
147 // 149 //
148 ////////////////////////////////////////////////////////////////////////////// 150 //////////////////////////////////////////////////////////////////////////////
149 151
150 void WebDataService::AddKeyword(const TemplateURL& url) { 152 void WebDataService::AddKeyword(const TemplateURL& url) {
151 // Ensure that the keyword is already generated (and cached) before caching 153 // Ensure that the keyword is already generated (and cached) before caching
152 // the TemplateURL for use on another keyword. 154 // the TemplateURL for use on another keyword.
153 url.EnsureKeyword(); 155 url.EnsureKeyword();
154 GenericRequest<TemplateURL>* request = 156 GenericRequest<TemplateURL>* request =
155 new GenericRequest<TemplateURL>(this, GetNextRequestHandle(), NULL, url); 157 new GenericRequest<TemplateURL>(this, GetNextRequestHandle(), NULL, url);
156 RegisterRequest(request); 158 RegisterRequest(request);
157 ScheduleTask(FROM_HERE, Bind(&WebDataService::AddKeywordImpl, this, request)); 159 ScheduleTask(FROM_HERE, Bind(&WebDataService::AddKeywordImpl, this, request));
158 } 160 }
159 161
160 void WebDataService::RemoveKeyword(const TemplateURL& url) { 162 void WebDataService::RemoveKeyword(TemplateURLID id) {
161 GenericRequest<TemplateURLID>* request = new GenericRequest<TemplateURLID>( 163 GenericRequest<TemplateURLID>* request =
162 this, GetNextRequestHandle(), NULL, url.id()); 164 new GenericRequest<TemplateURLID>(this, GetNextRequestHandle(), NULL, id);
163 RegisterRequest(request); 165 RegisterRequest(request);
164 ScheduleTask(FROM_HERE, 166 ScheduleTask(FROM_HERE,
165 Bind(&WebDataService::RemoveKeywordImpl, this, request)); 167 Bind(&WebDataService::RemoveKeywordImpl, this, request));
166 } 168 }
167 169
168 void WebDataService::UpdateKeyword(const TemplateURL& url) { 170 void WebDataService::UpdateKeyword(const TemplateURL& url) {
169 // Ensure that the keyword is already generated (and cached) before caching 171 // Ensure that the keyword is already generated (and cached) before caching
170 // the TemplateURL for use on another keyword. 172 // the TemplateURL for use on another keyword.
171 url.EnsureKeyword(); 173 url.EnsureKeyword();
172 GenericRequest<TemplateURL>* request = 174 GenericRequest<TemplateURL>* request =
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 823
822 void WebDataService::AddKeywordImpl(GenericRequest<TemplateURL>* request) { 824 void WebDataService::AddKeywordImpl(GenericRequest<TemplateURL>* request) {
823 InitializeDatabaseIfNecessary(); 825 InitializeDatabaseIfNecessary();
824 if (db_ && !request->IsCancelled(NULL)) { 826 if (db_ && !request->IsCancelled(NULL)) {
825 db_->GetKeywordTable()->AddKeyword(request->arg()); 827 db_->GetKeywordTable()->AddKeyword(request->arg());
826 ScheduleCommit(); 828 ScheduleCommit();
827 } 829 }
828 request->RequestComplete(); 830 request->RequestComplete();
829 } 831 }
830 832
831 void WebDataService::RemoveKeywordImpl( 833 void WebDataService::RemoveKeywordImpl(GenericRequest<TemplateURLID>* request) {
832 GenericRequest<TemplateURLID>* request) {
833 InitializeDatabaseIfNecessary(); 834 InitializeDatabaseIfNecessary();
834 if (db_ && !request->IsCancelled(NULL)) { 835 if (db_ && !request->IsCancelled(NULL)) {
835 DCHECK(request->arg()); 836 DCHECK(request->arg());
836 db_->GetKeywordTable()->RemoveKeyword(request->arg()); 837 db_->GetKeywordTable()->RemoveKeyword(request->arg());
837 ScheduleCommit(); 838 ScheduleCommit();
838 } 839 }
839 request->RequestComplete(); 840 request->RequestComplete();
840 } 841 }
841 842
842 void WebDataService::UpdateKeywordImpl(GenericRequest<TemplateURL>* request) { 843 void WebDataService::UpdateKeywordImpl(GenericRequest<TemplateURL>* request) {
(...skipping 12 matching lines...) Expand all
855 InitializeDatabaseIfNecessary(); 856 InitializeDatabaseIfNecessary();
856 if (db_ && !request->IsCancelled(NULL)) { 857 if (db_ && !request->IsCancelled(NULL)) {
857 WDKeywordsResult result; 858 WDKeywordsResult result;
858 db_->GetKeywordTable()->GetKeywords(&result.keywords); 859 db_->GetKeywordTable()->GetKeywords(&result.keywords);
859 result.default_search_provider_id = 860 result.default_search_provider_id =
860 db_->GetKeywordTable()->GetDefaultSearchProviderID(); 861 db_->GetKeywordTable()->GetDefaultSearchProviderID();
861 result.builtin_keyword_version = 862 result.builtin_keyword_version =
862 db_->GetKeywordTable()->GetBuiltinKeywordVersion(); 863 db_->GetKeywordTable()->GetBuiltinKeywordVersion();
863 result.did_default_search_provider_change = 864 result.did_default_search_provider_change =
864 db_->GetKeywordTable()->DidDefaultSearchProviderChange(); 865 db_->GetKeywordTable()->DidDefaultSearchProviderChange();
865 result.default_search_provider_backup = 866 result.backup_valid = result.did_default_search_provider_change &&
866 result.did_default_search_provider_change ? 867 db_->GetKeywordTable()->GetDefaultSearchProviderBackup(
867 db_->GetKeywordTable()->GetDefaultSearchProviderBackup() : 868 &result.default_search_provider_backup);
868 NULL;
869 request->SetResult( 869 request->SetResult(
870 new WDResult<WDKeywordsResult>(KEYWORDS_RESULT, result)); 870 new WDResult<WDKeywordsResult>(KEYWORDS_RESULT, result));
871 } 871 }
872 request->RequestComplete(); 872 request->RequestComplete();
873 } 873 }
874 874
875 void WebDataService::SetDefaultSearchProviderImpl( 875 void WebDataService::SetDefaultSearchProviderImpl(
876 GenericRequest<TemplateURLID>* request) { 876 GenericRequest<TemplateURLID>* request) {
877 InitializeDatabaseIfNecessary(); 877 InitializeDatabaseIfNecessary();
878 if (db_ && !request->IsCancelled(NULL)) { 878 if (db_ && !request->IsCancelled(NULL)) {
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 } 1652 }
1653 1653
1654 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { 1654 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const {
1655 return result_; 1655 return result_;
1656 } 1656 }
1657 1657
1658 void WebDataService::WebDataRequest::RequestComplete() { 1658 void WebDataService::WebDataRequest::RequestComplete() {
1659 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, 1659 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted,
1660 service_.get(), handle_)); 1660 service_.get(), handle_));
1661 } 1661 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_data_service.h ('k') | chrome/browser/webdata/web_data_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698