Commit d9d58401 authored by jianli@chromium.org's avatar jianli@chromium.org

[GCM] Create and use event router in GCMProfileService

BUG=284553

Review URL: https://codereview.chromium.org/146703006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247872 0039d316-1c4b-4281-b951-d872f2087c98
parent 877d32ad
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
#include "base/prefs/pref_service.h" #include "base/prefs/pref_service.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#if !defined(OS_ANDROID)
#include "chrome/browser/extensions/api/gcm/gcm_api.h"
#endif
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/state_store.h" #include "chrome/browser/extensions/state_store.h"
#include "chrome/browser/services/gcm/gcm_client_factory.h" #include "chrome/browser/services/gcm/gcm_client_factory.h"
...@@ -486,6 +489,10 @@ void GCMProfileService::Initialize() { ...@@ -486,6 +489,10 @@ void GCMProfileService::Initialize() {
// This has to be done first since CheckIn depends on it. // This has to be done first since CheckIn depends on it.
io_worker_ = new IOWorker(weak_ptr_factory_.GetWeakPtr()); io_worker_ = new IOWorker(weak_ptr_factory_.GetWeakPtr());
#if !defined(OS_ANDROID)
js_event_router_.reset(new extensions::GcmJsEventRouter(profile_));
#endif
// This initializes GCMClient and also does the check to find out if GCMClient // This initializes GCMClient and also does the check to find out if GCMClient
// has finished the loading. // has finished the loading.
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
...@@ -922,11 +929,15 @@ void GCMProfileService::GCMClientLoadingFinished() { ...@@ -922,11 +929,15 @@ void GCMProfileService::GCMClientLoadingFinished() {
DoCheckIn(); DoCheckIn();
} }
GCMEventRouter* GCMProfileService::GetEventRouter(const std::string& app_id) { GCMEventRouter* GCMProfileService::GetEventRouter(const std::string& app_id)
const {
if (testing_delegate_ && testing_delegate_->GetEventRouter()) if (testing_delegate_ && testing_delegate_->GetEventRouter())
return testing_delegate_->GetEventRouter(); return testing_delegate_->GetEventRouter();
// TODO(fgorski): check and create the event router for JS routing. #if defined(OS_ANDROID)
return NULL;
#else
return js_event_router_.get(); return js_event_router_.get();
#endif
} }
void GCMProfileService::DeleteRegistrationInfo(const std::string& app_id) { void GCMProfileService::DeleteRegistrationInfo(const std::string& app_id) {
......
...@@ -160,7 +160,7 @@ class GCMProfileService : public BrowserContextKeyedService, ...@@ -160,7 +160,7 @@ class GCMProfileService : public BrowserContextKeyedService,
void GCMClientLoadingFinished(); void GCMClientLoadingFinished();
// Returns the event router to fire the event for the given app. // Returns the event router to fire the event for the given app.
GCMEventRouter* GetEventRouter(const std::string& app_id); GCMEventRouter* GetEventRouter(const std::string& app_id) const;
// Used to persist registration info into the app's state store. // Used to persist registration info into the app's state store.
void DeleteRegistrationInfo(const std::string& app_id); void DeleteRegistrationInfo(const std::string& app_id);
...@@ -206,7 +206,9 @@ class GCMProfileService : public BrowserContextKeyedService, ...@@ -206,7 +206,9 @@ class GCMProfileService : public BrowserContextKeyedService,
RegistrationInfoMap registration_info_map_; RegistrationInfoMap registration_info_map_;
// Event router to talk with JS API. // Event router to talk with JS API.
#if !defined(OS_ANDROID)
scoped_ptr<GCMEventRouter> js_event_router_; scoped_ptr<GCMEventRouter> js_event_router_;
#endif
// For testing purpose. // For testing purpose.
TestingDelegate* testing_delegate_; TestingDelegate* testing_delegate_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment