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

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

Issue 9982018: Move most TemplateURL data members to a new struct, TemplateURLData. This allows us to eliminate t… (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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 814
813 void WebDataService::AddKeywordImpl(GenericRequest<TemplateURL>* request) { 815 void WebDataService::AddKeywordImpl(GenericRequest<TemplateURL>* request) {
814 InitializeDatabaseIfNecessary(); 816 InitializeDatabaseIfNecessary();
815 if (db_ && !request->IsCancelled(NULL)) { 817 if (db_ && !request->IsCancelled(NULL)) {
816 db_->GetKeywordTable()->AddKeyword(request->arg()); 818 db_->GetKeywordTable()->AddKeyword(request->arg());
817 ScheduleCommit(); 819 ScheduleCommit();
818 } 820 }
819 request->RequestComplete(); 821 request->RequestComplete();
820 } 822 }
821 823
822 void WebDataService::RemoveKeywordImpl( 824 void WebDataService::RemoveKeywordImpl(GenericRequest<TemplateURLID>* request) {
823 GenericRequest<TemplateURLID>* request) {
824 InitializeDatabaseIfNecessary(); 825 InitializeDatabaseIfNecessary();
825 if (db_ && !request->IsCancelled(NULL)) { 826 if (db_ && !request->IsCancelled(NULL)) {
826 DCHECK(request->arg()); 827 DCHECK(request->arg());
827 db_->GetKeywordTable()->RemoveKeyword(request->arg()); 828 db_->GetKeywordTable()->RemoveKeyword(request->arg());
828 ScheduleCommit(); 829 ScheduleCommit();
829 } 830 }
830 request->RequestComplete(); 831 request->RequestComplete();
831 } 832 }
832 833
833 void WebDataService::UpdateKeywordImpl(GenericRequest<TemplateURL>* request) { 834 void WebDataService::UpdateKeywordImpl(GenericRequest<TemplateURL>* request) {
(...skipping 12 matching lines...) Expand all
846 InitializeDatabaseIfNecessary(); 847 InitializeDatabaseIfNecessary();
847 if (db_ && !request->IsCancelled(NULL)) { 848 if (db_ && !request->IsCancelled(NULL)) {
848 WDKeywordsResult result; 849 WDKeywordsResult result;
849 db_->GetKeywordTable()->GetKeywords(&result.keywords); 850 db_->GetKeywordTable()->GetKeywords(&result.keywords);
850 result.default_search_provider_id = 851 result.default_search_provider_id =
851 db_->GetKeywordTable()->GetDefaultSearchProviderID(); 852 db_->GetKeywordTable()->GetDefaultSearchProviderID();
852 result.builtin_keyword_version = 853 result.builtin_keyword_version =
853 db_->GetKeywordTable()->GetBuiltinKeywordVersion(); 854 db_->GetKeywordTable()->GetBuiltinKeywordVersion();
854 result.did_default_search_provider_change = 855 result.did_default_search_provider_change =
855 db_->GetKeywordTable()->DidDefaultSearchProviderChange(); 856 db_->GetKeywordTable()->DidDefaultSearchProviderChange();
856 result.default_search_provider_backup = 857 result.backup_valid = result.did_default_search_provider_change &&
857 result.did_default_search_provider_change ? 858 db_->GetKeywordTable()->GetDefaultSearchProviderBackup(
858 db_->GetKeywordTable()->GetDefaultSearchProviderBackup() : 859 &result.default_search_provider_backup);
859 NULL;
860 request->SetResult( 860 request->SetResult(
861 new WDResult<WDKeywordsResult>(KEYWORDS_RESULT, result)); 861 new WDResult<WDKeywordsResult>(KEYWORDS_RESULT, result));
862 } 862 }
863 request->RequestComplete(); 863 request->RequestComplete();
864 } 864 }
865 865
866 void WebDataService::SetDefaultSearchProviderImpl( 866 void WebDataService::SetDefaultSearchProviderImpl(
867 GenericRequest<TemplateURLID>* request) { 867 GenericRequest<TemplateURLID>* request) {
868 InitializeDatabaseIfNecessary(); 868 InitializeDatabaseIfNecessary();
869 if (db_ && !request->IsCancelled(NULL)) { 869 if (db_ && !request->IsCancelled(NULL)) {
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 } 1620 }
1621 1621
1622 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { 1622 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const {
1623 return result_; 1623 return result_;
1624 } 1624 }
1625 1625
1626 void WebDataService::WebDataRequest::RequestComplete() { 1626 void WebDataService::WebDataRequest::RequestComplete() {
1627 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, 1627 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted,
1628 service_.get(), handle_)); 1628 service_.get(), handle_));
1629 } 1629 }
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