OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 } | 253 } |
254 | 254 |
255 void WebDataService::RemoveWebIntent(const WebIntentServiceData& service) { | 255 void WebDataService::RemoveWebIntent(const WebIntentServiceData& service) { |
256 GenericRequest<WebIntentServiceData>* request = | 256 GenericRequest<WebIntentServiceData>* request = |
257 new GenericRequest<WebIntentServiceData>( | 257 new GenericRequest<WebIntentServiceData>( |
258 this, GetNextRequestHandle(), NULL, service); | 258 this, GetNextRequestHandle(), NULL, service); |
259 RegisterRequest(request); | 259 RegisterRequest(request); |
260 ScheduleTask(Bind(&WebDataService::RemoveWebIntentImpl, this, request)); | 260 ScheduleTask(Bind(&WebDataService::RemoveWebIntentImpl, this, request)); |
261 } | 261 } |
262 | 262 |
263 WebDataService::Handle WebDataService::GetWebIntents(const string16& action, | 263 WebDataService::Handle WebDataService::GetWebIntents( |
264 WebDataServiceConsumer* consumer) { | 264 const string16& action, |
James Hawkins
2011/10/29 21:41:32
Optional: You can save a line by moving |consumer|
Greg Billock
2011/10/31 17:07:09
I think when split having these long args one per
| |
265 WebDataServiceConsumer* consumer) { | |
265 DCHECK(consumer); | 266 DCHECK(consumer); |
266 GenericRequest<string16>* request = new GenericRequest<string16>( | 267 GenericRequest<string16>* request = new GenericRequest<string16>( |
267 this, GetNextRequestHandle(), consumer, action); | 268 this, GetNextRequestHandle(), consumer, action); |
268 RegisterRequest(request); | 269 RegisterRequest(request); |
269 ScheduleTask(Bind(&WebDataService::GetWebIntentsImpl, this, request)); | 270 ScheduleTask(Bind(&WebDataService::GetWebIntentsImpl, this, request)); |
270 return request->GetHandle(); | 271 return request->GetHandle(); |
271 } | 272 } |
272 | 273 |
274 WebDataService::Handle WebDataService::GetWebIntentsForURL( | |
275 const string16& service_url, | |
276 WebDataServiceConsumer* consumer) { | |
277 DCHECK(consumer); | |
278 GenericRequest<string16>* request = new GenericRequest<string16>( | |
279 this, GetNextRequestHandle(), consumer, service_url); | |
280 RegisterRequest(request); | |
281 ScheduleTask(Bind(&WebDataService::GetWebIntentsForURLImpl, this, request)); | |
282 return request->GetHandle(); | |
283 } | |
284 | |
285 | |
273 WebDataService::Handle WebDataService::GetAllWebIntents( | 286 WebDataService::Handle WebDataService::GetAllWebIntents( |
274 WebDataServiceConsumer* consumer) { | 287 WebDataServiceConsumer* consumer) { |
275 DCHECK(consumer); | 288 DCHECK(consumer); |
276 GenericRequest<std::string>* request = new GenericRequest<std::string>( | 289 GenericRequest<std::string>* request = new GenericRequest<std::string>( |
277 this, GetNextRequestHandle(), consumer, std::string()); | 290 this, GetNextRequestHandle(), consumer, std::string()); |
278 RegisterRequest(request); | 291 RegisterRequest(request); |
279 ScheduleTask(Bind(&WebDataService::GetAllWebIntentsImpl, this, request)); | 292 ScheduleTask(Bind(&WebDataService::GetAllWebIntentsImpl, this, request)); |
280 return request->GetHandle(); | 293 return request->GetHandle(); |
281 } | 294 } |
282 | 295 |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
865 if (db_ && !request->IsCancelled(NULL)) { | 878 if (db_ && !request->IsCancelled(NULL)) { |
866 std::vector<WebIntentServiceData> result; | 879 std::vector<WebIntentServiceData> result; |
867 db_->GetWebIntentsTable()->GetWebIntents(request->arg(), &result); | 880 db_->GetWebIntentsTable()->GetWebIntents(request->arg(), &result); |
868 request->SetResult( | 881 request->SetResult( |
869 new WDResult<std::vector<WebIntentServiceData> >( | 882 new WDResult<std::vector<WebIntentServiceData> >( |
870 WEB_INTENTS_RESULT, result)); | 883 WEB_INTENTS_RESULT, result)); |
871 } | 884 } |
872 request->RequestComplete(); | 885 request->RequestComplete(); |
873 } | 886 } |
874 | 887 |
888 void WebDataService::GetWebIntentsForURLImpl( | |
889 GenericRequest<string16>* request) { | |
890 InitializeDatabaseIfNecessary(); | |
891 if (db_ && !request->IsCancelled(NULL)) { | |
892 std::vector<WebIntentServiceData> result; | |
893 db_->GetWebIntentsTable()->GetWebIntentsForURL( | |
894 request->arg(), &result); | |
895 request->SetResult( | |
896 new WDResult<std::vector<WebIntentServiceData> >( | |
897 WEB_INTENTS_RESULT, result)); | |
898 } | |
899 request->RequestComplete(); | |
900 } | |
901 | |
875 void WebDataService::GetAllWebIntentsImpl( | 902 void WebDataService::GetAllWebIntentsImpl( |
876 GenericRequest<std::string>* request) { | 903 GenericRequest<std::string>* request) { |
877 InitializeDatabaseIfNecessary(); | 904 InitializeDatabaseIfNecessary(); |
878 if (db_ && !request->IsCancelled(NULL)) { | 905 if (db_ && !request->IsCancelled(NULL)) { |
879 std::vector<WebIntentServiceData> result; | 906 std::vector<WebIntentServiceData> result; |
880 db_->GetWebIntentsTable()->GetAllWebIntents(&result); | 907 db_->GetWebIntentsTable()->GetAllWebIntents(&result); |
881 request->SetResult( | 908 request->SetResult( |
882 new WDResult<std::vector<WebIntentServiceData> >( | 909 new WDResult<std::vector<WebIntentServiceData> >( |
883 WEB_INTENTS_RESULT, result)); | 910 WEB_INTENTS_RESULT, result)); |
884 } | 911 } |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1439 } | 1466 } |
1440 | 1467 |
1441 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { | 1468 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { |
1442 return result_; | 1469 return result_; |
1443 } | 1470 } |
1444 | 1471 |
1445 void WebDataService::WebDataRequest::RequestComplete() { | 1472 void WebDataService::WebDataRequest::RequestComplete() { |
1446 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, | 1473 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, |
1447 service_.get(), handle_)); | 1474 service_.get(), handle_)); |
1448 } | 1475 } |
OLD | NEW |