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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 const string16& action, | 271 const string16& action, |
272 WebDataServiceConsumer* consumer) { | 272 WebDataServiceConsumer* consumer) { |
273 DCHECK(consumer); | 273 DCHECK(consumer); |
274 GenericRequest<string16>* request = new GenericRequest<string16>( | 274 GenericRequest<string16>* request = new GenericRequest<string16>( |
275 this, GetNextRequestHandle(), consumer, action); | 275 this, GetNextRequestHandle(), consumer, action); |
276 RegisterRequest(request); | 276 RegisterRequest(request); |
277 ScheduleTask(Bind(&WebDataService::GetWebIntentServicesImpl, this, request)); | 277 ScheduleTask(Bind(&WebDataService::GetWebIntentServicesImpl, this, request)); |
278 return request->GetHandle(); | 278 return request->GetHandle(); |
279 } | 279 } |
280 | 280 |
| 281 WebDataService::Handle WebDataService::GetWebIntentServicesForURL( |
| 282 const string16& service_url, |
| 283 WebDataServiceConsumer* consumer) { |
| 284 DCHECK(consumer); |
| 285 GenericRequest<string16>* request = new GenericRequest<string16>( |
| 286 this, GetNextRequestHandle(), consumer, service_url); |
| 287 RegisterRequest(request); |
| 288 ScheduleTask(Bind(&WebDataService::GetWebIntentServicesForURLImpl, |
| 289 this, |
| 290 request)); |
| 291 return request->GetHandle(); |
| 292 } |
| 293 |
| 294 |
281 WebDataService::Handle WebDataService::GetAllWebIntentServices( | 295 WebDataService::Handle WebDataService::GetAllWebIntentServices( |
282 WebDataServiceConsumer* consumer) { | 296 WebDataServiceConsumer* consumer) { |
283 DCHECK(consumer); | 297 DCHECK(consumer); |
284 GenericRequest<std::string>* request = new GenericRequest<std::string>( | 298 GenericRequest<std::string>* request = new GenericRequest<std::string>( |
285 this, GetNextRequestHandle(), consumer, std::string()); | 299 this, GetNextRequestHandle(), consumer, std::string()); |
286 RegisterRequest(request); | 300 RegisterRequest(request); |
287 ScheduleTask(Bind(&WebDataService::GetAllWebIntentServicesImpl, | 301 ScheduleTask(Bind(&WebDataService::GetAllWebIntentServicesImpl, |
288 this, | 302 this, |
289 request)); | 303 request)); |
290 return request->GetHandle(); | 304 return request->GetHandle(); |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 if (db_ && !request->IsCancelled(NULL)) { | 898 if (db_ && !request->IsCancelled(NULL)) { |
885 std::vector<WebIntentServiceData> result; | 899 std::vector<WebIntentServiceData> result; |
886 db_->GetWebIntentsTable()->GetWebIntentServices(request->arg(), &result); | 900 db_->GetWebIntentsTable()->GetWebIntentServices(request->arg(), &result); |
887 request->SetResult( | 901 request->SetResult( |
888 new WDResult<std::vector<WebIntentServiceData> >( | 902 new WDResult<std::vector<WebIntentServiceData> >( |
889 WEB_INTENTS_RESULT, result)); | 903 WEB_INTENTS_RESULT, result)); |
890 } | 904 } |
891 request->RequestComplete(); | 905 request->RequestComplete(); |
892 } | 906 } |
893 | 907 |
| 908 void WebDataService::GetWebIntentServicesForURLImpl( |
| 909 GenericRequest<string16>* request) { |
| 910 InitializeDatabaseIfNecessary(); |
| 911 if (db_ && !request->IsCancelled(NULL)) { |
| 912 std::vector<WebIntentServiceData> result; |
| 913 db_->GetWebIntentsTable()->GetWebIntentServicesForURL( |
| 914 request->arg(), &result); |
| 915 request->SetResult( |
| 916 new WDResult<std::vector<WebIntentServiceData> >( |
| 917 WEB_INTENTS_RESULT, result)); |
| 918 } |
| 919 request->RequestComplete(); |
| 920 } |
| 921 |
894 void WebDataService::GetAllWebIntentServicesImpl( | 922 void WebDataService::GetAllWebIntentServicesImpl( |
895 GenericRequest<std::string>* request) { | 923 GenericRequest<std::string>* request) { |
896 InitializeDatabaseIfNecessary(); | 924 InitializeDatabaseIfNecessary(); |
897 if (db_ && !request->IsCancelled(NULL)) { | 925 if (db_ && !request->IsCancelled(NULL)) { |
898 std::vector<WebIntentServiceData> result; | 926 std::vector<WebIntentServiceData> result; |
899 db_->GetWebIntentsTable()->GetAllWebIntentServices(&result); | 927 db_->GetWebIntentsTable()->GetAllWebIntentServices(&result); |
900 request->SetResult( | 928 request->SetResult( |
901 new WDResult<std::vector<WebIntentServiceData> >( | 929 new WDResult<std::vector<WebIntentServiceData> >( |
902 WEB_INTENTS_RESULT, result)); | 930 WEB_INTENTS_RESULT, result)); |
903 } | 931 } |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1467 } | 1495 } |
1468 | 1496 |
1469 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { | 1497 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { |
1470 return result_; | 1498 return result_; |
1471 } | 1499 } |
1472 | 1500 |
1473 void WebDataService::WebDataRequest::RequestComplete() { | 1501 void WebDataService::WebDataRequest::RequestComplete() { |
1474 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, | 1502 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, |
1475 service_.get(), handle_)); | 1503 service_.get(), handle_)); |
1476 } | 1504 } |
OLD | NEW |