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

Side by Side Diff: chrome/browser/intents/web_intents_registry.cc

Issue 10854019: Make GetIntentServicesForExtensionFilter work synchronously (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make GetIntentServicesForExtensionFilter synchronous. Created 8 years, 4 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/intents/web_intents_registry.h" 5 #include "chrome/browser/intents/web_intents_registry.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 398
399 QueryAdapter* query = new QueryAdapter(this, handler); 399 QueryAdapter* query = new QueryAdapter(this, handler);
400 query->query_handle_ = wds_->GetWebIntentServicesForURL( 400 query->query_handle_ = wds_->GetWebIntentServicesForURL(
401 UTF8ToUTF16(service.service_url.spec()), query); 401 UTF8ToUTF16(service.service_url.spec()), query);
402 } 402 }
403 403
404 void WebIntentsRegistry::GetIntentServicesForExtensionFilter( 404 void WebIntentsRegistry::GetIntentServicesForExtensionFilter(
405 const string16& action, 405 const string16& action,
406 const string16& type, 406 const string16& type,
407 const std::string& extension_id, 407 const std::string& extension_id,
408 const QueryCallback& callback) { 408 IntentServiceList* services) {
409 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
410 DCHECK(!callback.is_null());
411
412 const QueryParams params(action, type);
413 content::BrowserThread::PostTask(
414 content::BrowserThread::UI,
415 FROM_HERE,
416 base::Bind(
417 &WebIntentsRegistry::DoGetIntentServicesForExtensionFilter,
418 base::Unretained(this),
419 params,
420 extension_id,
421 callback));
422 }
423
424 void WebIntentsRegistry::DoGetIntentServicesForExtensionFilter(
425 const QueryParams& params,
426 const std::string& extension_id,
427 const QueryCallback& callback) {
428 IntentServiceList matching_services;
429
430 if (extension_service_) { 409 if (extension_service_) {
431 const Extension* extension = 410 const Extension* extension =
432 extension_service_->GetExtensionById(extension_id, false); 411 extension_service_->GetExtensionById(extension_id, false);
433 AddMatchingServicesForExtension(*extension, 412 AddMatchingServicesForExtension(*extension,
434 params.action_, 413 action,
435 &matching_services); 414 services);
436 FilterServicesByType(params.type_, &matching_services); 415 FilterServicesByType(type, services);
437 } 416 }
438
439 callback.Run(matching_services);
440 } 417 }
441 418
442 void WebIntentsRegistry::RegisterDefaultIntentService( 419 void WebIntentsRegistry::RegisterDefaultIntentService(
443 const DefaultWebIntentService& default_service) { 420 const DefaultWebIntentService& default_service) {
444 DCHECK(wds_.get()); 421 DCHECK(wds_.get());
445 wds_->AddDefaultWebIntentService(default_service); 422 wds_->AddDefaultWebIntentService(default_service);
446 } 423 }
447 424
448 void WebIntentsRegistry::UnregisterDefaultIntentService( 425 void WebIntentsRegistry::UnregisterDefaultIntentService(
449 const DefaultWebIntentService& default_service) { 426 const DefaultWebIntentService& default_service) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 void WebIntentsRegistry::ReleaseQuery(QueryAdapter* query) { 511 void WebIntentsRegistry::ReleaseQuery(QueryAdapter* query) {
535 QueryVector::iterator it = std::find( 512 QueryVector::iterator it = std::find(
536 pending_queries_.begin(), pending_queries_.end(), query); 513 pending_queries_.begin(), pending_queries_.end(), query);
537 if (it != pending_queries_.end()) { 514 if (it != pending_queries_.end()) {
538 pending_queries_.erase(it); 515 pending_queries_.erase(it);
539 delete query; 516 delete query;
540 } else { 517 } else {
541 NOTREACHED(); 518 NOTREACHED();
542 } 519 }
543 } 520 }
OLDNEW
« no previous file with comments | « chrome/browser/intents/web_intents_registry.h ('k') | chrome/browser/intents/web_intents_registry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698