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, |
| 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& action, |
| 276 const string16& service_url, |
| 277 WebDataServiceConsumer* consumer) { |
| 278 DCHECK(consumer); |
| 279 GenericRequest2<string16, string16>* request = |
| 280 new GenericRequest2<string16, string16>( |
| 281 this, GetNextRequestHandle(), consumer, action, service_url); |
| 282 RegisterRequest(request); |
| 283 ScheduleTask(Bind(&WebDataService::GetWebIntentsForURLImpl, this, request)); |
| 284 return request->GetHandle(); |
| 285 } |
| 286 |
| 287 |
273 WebDataService::Handle WebDataService::GetAllWebIntents( | 288 WebDataService::Handle WebDataService::GetAllWebIntents( |
274 WebDataServiceConsumer* consumer) { | 289 WebDataServiceConsumer* consumer) { |
275 DCHECK(consumer); | 290 DCHECK(consumer); |
276 GenericRequest<std::string>* request = new GenericRequest<std::string>( | 291 GenericRequest<std::string>* request = new GenericRequest<std::string>( |
277 this, GetNextRequestHandle(), consumer, std::string()); | 292 this, GetNextRequestHandle(), consumer, std::string()); |
278 RegisterRequest(request); | 293 RegisterRequest(request); |
279 ScheduleTask(Bind(&WebDataService::GetAllWebIntentsImpl, this, request)); | 294 ScheduleTask(Bind(&WebDataService::GetAllWebIntentsImpl, this, request)); |
280 return request->GetHandle(); | 295 return request->GetHandle(); |
281 } | 296 } |
282 | 297 |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 if (db_ && !request->IsCancelled(NULL)) { | 857 if (db_ && !request->IsCancelled(NULL)) { |
843 std::vector<WebIntentServiceData> result; | 858 std::vector<WebIntentServiceData> result; |
844 db_->GetWebIntentsTable()->GetWebIntents(request->arg(), &result); | 859 db_->GetWebIntentsTable()->GetWebIntents(request->arg(), &result); |
845 request->SetResult( | 860 request->SetResult( |
846 new WDResult<std::vector<WebIntentServiceData> >( | 861 new WDResult<std::vector<WebIntentServiceData> >( |
847 WEB_INTENTS_RESULT, result)); | 862 WEB_INTENTS_RESULT, result)); |
848 } | 863 } |
849 request->RequestComplete(); | 864 request->RequestComplete(); |
850 } | 865 } |
851 | 866 |
| 867 void WebDataService::GetWebIntentsForURLImpl( |
| 868 GenericRequest2<string16, string16>* request) { |
| 869 InitializeDatabaseIfNecessary(); |
| 870 if (db_ && !request->IsCancelled(NULL)) { |
| 871 std::vector<WebIntentServiceData> result; |
| 872 db_->GetWebIntentsTable()->GetWebIntentsForURL( |
| 873 request->arg1(), request->arg2(), &result); |
| 874 request->SetResult( |
| 875 new WDResult<std::vector<WebIntentServiceData> >( |
| 876 WEB_INTENTS_RESULT, result)); |
| 877 } |
| 878 request->RequestComplete(); |
| 879 } |
| 880 |
852 void WebDataService::GetAllWebIntentsImpl( | 881 void WebDataService::GetAllWebIntentsImpl( |
853 GenericRequest<std::string>* request) { | 882 GenericRequest<std::string>* request) { |
854 InitializeDatabaseIfNecessary(); | 883 InitializeDatabaseIfNecessary(); |
855 if (db_ && !request->IsCancelled(NULL)) { | 884 if (db_ && !request->IsCancelled(NULL)) { |
856 std::vector<WebIntentServiceData> result; | 885 std::vector<WebIntentServiceData> result; |
857 db_->GetWebIntentsTable()->GetAllWebIntents(&result); | 886 db_->GetWebIntentsTable()->GetAllWebIntents(&result); |
858 request->SetResult( | 887 request->SetResult( |
859 new WDResult<std::vector<WebIntentServiceData> >( | 888 new WDResult<std::vector<WebIntentServiceData> >( |
860 WEB_INTENTS_RESULT, result)); | 889 WEB_INTENTS_RESULT, result)); |
861 } | 890 } |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 } | 1437 } |
1409 | 1438 |
1410 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { | 1439 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { |
1411 return result_; | 1440 return result_; |
1412 } | 1441 } |
1413 | 1442 |
1414 void WebDataService::WebDataRequest::RequestComplete() { | 1443 void WebDataService::WebDataRequest::RequestComplete() { |
1415 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, | 1444 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, |
1416 service_.get(), handle_)); | 1445 service_.get(), handle_)); |
1417 } | 1446 } |
OLD | NEW |