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

Unified Diff: components/gcm_driver/gcm_driver.cc

Issue 324913004: Skeleton GCMAppHandler for Push API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
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..99209359f84fb8937123f039c342280cc6187acf 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;
}
@@ -157,9 +157,26 @@ void GCMDriver::RemoveAppHandler(const std::string& app_id) {
app_handlers_.erase(app_id);
}
+void GCMDriver::AddWildcardAppHandler(GCMWildcardAppHandler* handler) {
+ DCHECK(handler);
+ DCHECK(wildcard_app_handlers_.count(handler) == 0);
+ wildcard_app_handlers_.insert(handler);
+}
+
+void GCMDriver::RemoveWildcardAppHandler(GCMWildcardAppHandler* handler) {
+ wildcard_app_handlers_.erase(handler);
+}
+
GCMAppHandler* GCMDriver::GetAppHandler(const std::string& app_id) {
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;
+ GCMWildcardAppHandlerSet::const_iterator it = wildcard_app_handlers_.begin();
+ for (; it != wildcard_app_handlers_.end(); ++it) {
+ if ((*it)->CanHandle(app_id))
+ return *it;
+ }
+ return &default_app_handler_;
}
bool GCMDriver::HasRegisterCallback(const std::string& app_id) {

Powered by Google App Engine
This is Rietveld 408576698