OLD | NEW |
---|---|
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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 const DefaultWebIntentService& service) { | 327 const DefaultWebIntentService& service) { |
328 GenericRequest<DefaultWebIntentService>* request = | 328 GenericRequest<DefaultWebIntentService>* request = |
329 new GenericRequest<DefaultWebIntentService>( | 329 new GenericRequest<DefaultWebIntentService>( |
330 this, GetNextRequestHandle(), NULL, service); | 330 this, GetNextRequestHandle(), NULL, service); |
331 RegisterRequest(request); | 331 RegisterRequest(request); |
332 ScheduleTask(FROM_HERE, | 332 ScheduleTask(FROM_HERE, |
333 Bind(&WebDataService::RemoveDefaultWebIntentServiceImpl, this, | 333 Bind(&WebDataService::RemoveDefaultWebIntentServiceImpl, this, |
334 request)); | 334 request)); |
335 } | 335 } |
336 | 336 |
337 void WebDataService::RemoveDefaultWebIntentServiceForServiceURL( | |
338 const GURL& service_url) { | |
339 GenericRequest<GURL>* request = | |
340 new GenericRequest<GURL>( | |
341 this, GetNextRequestHandle(), NULL, service_url); | |
342 RegisterRequest(request); | |
343 ScheduleTask( | |
344 FROM_HERE, | |
345 Bind(&WebDataService::RemoveDefaultWebIntentServiceForServiceURLImpl, | |
346 this, | |
347 request)); | |
James Hawkins
2012/08/08 16:22:37
Optional nit: Condense parameters to save a line.
Steve McKay
2012/08/08 17:54:42
Collapsed entire call after method renaming.
| |
348 } | |
349 | |
337 WebDataService::Handle WebDataService::GetDefaultWebIntentServicesForAction( | 350 WebDataService::Handle WebDataService::GetDefaultWebIntentServicesForAction( |
338 const string16& action, | 351 const string16& action, |
339 WebDataServiceConsumer* consumer) { | 352 WebDataServiceConsumer* consumer) { |
340 DCHECK(consumer); | 353 DCHECK(consumer); |
341 GenericRequest<string16>* request = new GenericRequest<string16>( | 354 GenericRequest<string16>* request = new GenericRequest<string16>( |
342 this, GetNextRequestHandle(), consumer, action); | 355 this, GetNextRequestHandle(), consumer, action); |
343 RegisterRequest(request); | 356 RegisterRequest(request); |
344 ScheduleTask(FROM_HERE, | 357 ScheduleTask(FROM_HERE, |
345 Bind(&WebDataService::GetDefaultWebIntentServicesForActionImpl, | 358 Bind(&WebDataService::GetDefaultWebIntentServicesForActionImpl, |
346 this, request)); | 359 this, request)); |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
958 GenericRequest<DefaultWebIntentService>* request) { | 971 GenericRequest<DefaultWebIntentService>* request) { |
959 InitializeDatabaseIfNecessary(); | 972 InitializeDatabaseIfNecessary(); |
960 if (db_ && !request->IsCancelled(NULL)) { | 973 if (db_ && !request->IsCancelled(NULL)) { |
961 const DefaultWebIntentService& service = request->arg(); | 974 const DefaultWebIntentService& service = request->arg(); |
962 db_->GetWebIntentsTable()->RemoveDefaultService(service); | 975 db_->GetWebIntentsTable()->RemoveDefaultService(service); |
963 ScheduleCommit(); | 976 ScheduleCommit(); |
964 } | 977 } |
965 request->RequestComplete(); | 978 request->RequestComplete(); |
966 } | 979 } |
967 | 980 |
981 void WebDataService::RemoveDefaultWebIntentServiceForServiceURLImpl( | |
982 GenericRequest<GURL>* request) { | |
983 InitializeDatabaseIfNecessary(); | |
984 if (db_ && !request->IsCancelled(NULL)) { | |
985 const GURL& service_url = request->arg(); | |
986 db_->GetWebIntentsTable()->RemoveDefaultServicesForServiceURL(service_url); | |
987 ScheduleCommit(); | |
988 } | |
989 request->RequestComplete(); | |
990 } | |
991 | |
968 void WebDataService::GetDefaultWebIntentServicesForActionImpl( | 992 void WebDataService::GetDefaultWebIntentServicesForActionImpl( |
969 GenericRequest<string16>* request) { | 993 GenericRequest<string16>* request) { |
970 InitializeDatabaseIfNecessary(); | 994 InitializeDatabaseIfNecessary(); |
971 if (db_ && !request->IsCancelled(NULL)) { | 995 if (db_ && !request->IsCancelled(NULL)) { |
972 std::vector<DefaultWebIntentService> result; | 996 std::vector<DefaultWebIntentService> result; |
973 db_->GetWebIntentsTable()->GetDefaultServices( | 997 db_->GetWebIntentsTable()->GetDefaultServices( |
974 request->arg(), &result); | 998 request->arg(), &result); |
975 request->SetResult( | 999 request->SetResult( |
976 new WDResult<std::vector<DefaultWebIntentService> >( | 1000 new WDResult<std::vector<DefaultWebIntentService> >( |
977 WEB_INTENTS_DEFAULTS_RESULT, result)); | 1001 WEB_INTENTS_DEFAULTS_RESULT, result)); |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1490 } | 1514 } |
1491 | 1515 |
1492 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { | 1516 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { |
1493 return result_; | 1517 return result_; |
1494 } | 1518 } |
1495 | 1519 |
1496 void WebDataService::WebDataRequest::RequestComplete() { | 1520 void WebDataService::WebDataRequest::RequestComplete() { |
1497 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, | 1521 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, |
1498 service_.get(), handle_)); | 1522 service_.get(), handle_)); |
1499 } | 1523 } |
OLD | NEW |