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

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: 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
« components/gcm_driver/gcm_driver.h ('K') | « components/gcm_driver/gcm_driver.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d768206bdfd1e923205d2627cce62e4a390132d3 100644
--- a/components/gcm_driver/gcm_driver.cc
+++ b/components/gcm_driver/gcm_driver.cc
@@ -17,6 +17,11 @@ GCMDriver::GCMDriver() {
GCMDriver::~GCMDriver() {
}
+void GCMDriver::SetLazyLoadAppHandlersClosure(
+ const base::Closure& lazy_load_app_handlers) {
+ lazy_load_app_handlers_ = lazy_load_app_handlers;
+}
+
void GCMDriver::Register(const std::string& app_id,
const std::vector<std::string>& sender_ids,
const RegisterCallback& callback) {
@@ -148,7 +153,8 @@ 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_.find(app_id) == app_handlers_.end() ||
+ app_handlers_[app_id] == handler);
app_handlers_[app_id] = handler;
}
@@ -158,6 +164,10 @@ void GCMDriver::RemoveAppHandler(const std::string& app_id) {
}
GCMAppHandler* GCMDriver::GetAppHandler(const std::string& app_id) {
+ if (!lazy_load_app_handlers_.is_null()) {
+ lazy_load_app_handlers_.Run();
+ lazy_load_app_handlers_.Reset();
+ }
GCMAppHandlerMap::const_iterator iter = app_handlers_.find(app_id);
return iter == app_handlers_.end() ? &default_app_handler_ : iter->second;
}
« components/gcm_driver/gcm_driver.h ('K') | « components/gcm_driver/gcm_driver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698