| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/gcm_driver/gcm_driver.h" | 5 #include "components/gcm_driver/gcm_driver.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "components/gcm_driver/gcm_app_handler.h" | 10 #include "components/gcm_driver/gcm_app_handler.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 DCHECK_EQ(app_handlers_.count(app_id), 0u); | 151 DCHECK_EQ(app_handlers_.count(app_id), 0u); |
| 152 app_handlers_[app_id] = handler; | 152 app_handlers_[app_id] = handler; |
| 153 } | 153 } |
| 154 | 154 |
| 155 void GCMDriver::RemoveAppHandler(const std::string& app_id) { | 155 void GCMDriver::RemoveAppHandler(const std::string& app_id) { |
| 156 DCHECK(!app_id.empty()); | 156 DCHECK(!app_id.empty()); |
| 157 app_handlers_.erase(app_id); | 157 app_handlers_.erase(app_id); |
| 158 } | 158 } |
| 159 | 159 |
| 160 GCMAppHandler* GCMDriver::GetAppHandler(const std::string& app_id) { | 160 GCMAppHandler* GCMDriver::GetAppHandler(const std::string& app_id) { |
| 161 LOG(WARNING) << "app_id: " << app_id; |
| 161 // Look for exact match. | 162 // Look for exact match. |
| 162 GCMAppHandlerMap::const_iterator iter = app_handlers_.find(app_id); | 163 GCMAppHandlerMap::const_iterator iter = app_handlers_.find(app_id); |
| 163 if (iter != app_handlers_.end()) | 164 if (iter != app_handlers_.end()) |
| 164 return iter->second; | 165 return iter->second; |
| 165 | 166 |
| 166 // Ask the handlers whether they know how to handle it. | 167 // Ask the handlers whether they know how to handle it. |
| 167 for (iter = app_handlers_.begin(); iter != app_handlers_.end(); ++iter) { | 168 for (iter = app_handlers_.begin(); iter != app_handlers_.end(); ++iter) { |
| 168 if (iter->second->CanHandle(app_id)) | 169 if (iter->second->CanHandle(app_id)) |
| 169 return iter->second; | 170 return iter->second; |
| 170 } | 171 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 181 unregister_callbacks_.clear(); | 182 unregister_callbacks_.clear(); |
| 182 send_callbacks_.clear(); | 183 send_callbacks_.clear(); |
| 183 } | 184 } |
| 184 | 185 |
| 185 bool GCMDriver::IsAsyncOperationPending(const std::string& app_id) const { | 186 bool GCMDriver::IsAsyncOperationPending(const std::string& app_id) const { |
| 186 return register_callbacks_.find(app_id) != register_callbacks_.end() || | 187 return register_callbacks_.find(app_id) != register_callbacks_.end() || |
| 187 unregister_callbacks_.find(app_id) != unregister_callbacks_.end(); | 188 unregister_callbacks_.find(app_id) != unregister_callbacks_.end(); |
| 188 } | 189 } |
| 189 | 190 |
| 190 } // namespace gcm | 191 } // namespace gcm |
| OLD | NEW |