Chromium Code Reviews| Index: components/gcm_driver/gcm_driver.cc |
| diff --git a/components/gcm_driver/gcm_driver.cc b/components/gcm_driver/gcm_driver.cc |
| index 345fa97dce156622f51083e91f9a98277c68cf9d..776657f8a87c4b19a495ccd0813b43cde0c563d9 100644 |
| --- a/components/gcm_driver/gcm_driver.cc |
| +++ b/components/gcm_driver/gcm_driver.cc |
| @@ -148,7 +148,7 @@ void GCMDriver::AddAppHandler(const std::string& app_id, |
| GCMAppHandler* handler) { |
| DCHECK(!app_id.empty()); |
| DCHECK(handler); |
| - DCHECK(app_handlers_.find(app_id) == app_handlers_.end()); |
| + DCHECK(app_handlers_.count(app_id) == 0); |
| app_handlers_[app_id] = handler; |
| } |
| @@ -158,8 +158,19 @@ void GCMDriver::RemoveAppHandler(const std::string& app_id) { |
| } |
| GCMAppHandler* GCMDriver::GetAppHandler(const std::string& app_id) { |
| + // Look for exact match. |
| GCMAppHandlerMap::const_iterator iter = app_handlers_.find(app_id); |
| - return iter == app_handlers_.end() ? &default_app_handler_ : iter->second; |
| + if (iter != app_handlers_.end()) |
| + return iter->second; |
| + |
| + // Ask the handlers whether they know how to handle it. |
| + iter = app_handlers_.begin(); |
|
fgorski
2014/06/17 17:24:00
nit: any reason not to put it in the for header?
Michael van Ouwerkerk
2014/06/17 19:22:05
Done.
|
| + for (; iter != app_handlers_.end(); ++iter) { |
| + if (iter->second->CanHandle(app_id)) |
| + return iter->second; |
| + } |
| + |
| + return &default_app_handler_; |
| } |
| bool GCMDriver::HasRegisterCallback(const std::string& app_id) { |