GCMDriverDesktop::GCMDriverDesktop(
scoped_ptr<GCMClientFactory> gcm_client_factory,
const GCMClient::ChromeBuildInfo& chrome_build_info,
+ const std::string& channel_status_request_url,
+ const std::string& user_agent,
PrefService* prefs,
const base::FilePath& store_path,
const scoped_refptr<net::URLRequestContextGetter>& request_context,
const scoped_refptr<base::SequencedTaskRunner>& io_thread,
const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner)
: gcm_channel_status_syncer_(
- new GCMChannelStatusSyncer(this, prefs, request_context)),
+ new GCMChannelStatusSyncer(this,
+ prefs,
+ channel_status_request_url,
+ user_agent,
+ request_context)),
signed_in_(false),
gcm_started_(false),
gcm_enabled_(true),
EnsureStarted();
}
+void GCMDriverDesktop::OnSignedOut() {
+ signed_in_ = false;
+
+ // When sign-in enforcement is not dropped, we will stop the GCM connection
+ // when the user signs out.
+ if (!GCMDriver::IsAllowedForAllUsers())
+ Stop();
+}
+
void GCMDriverDesktop::Purge() {
DCHECK(ui_thread_->RunsTasksOnCurrentThread());
- // We still proceed with the check-out logic even if the check-in is not
- // initiated in the current session. This will make sure that all the
- // persisted data written previously will get purged.
- signed_in_ = false;
RemoveCachedData();
io_thread_->PostTask(FROM_HERE,
GCMDriver::RemoveAppHandler(app_id);
// Stops the GCM service when no app intends to consume it.
- if (app_handlers().empty())
+ if (app_handlers().empty()) {
Stop();
+ gcm_channel_status_syncer_->Stop();
+ }
}
void GCMDriverDesktop::AddConnectionObserver(GCMConnectionObserver* observer) {
if (!gcm_started_)
return;
- gcm_channel_status_syncer_->Stop();
-
RemoveCachedData();
io_thread_->PostTask(
if (gcm_started_)
return GCMClient::SUCCESS;
- if (!gcm_enabled_)
+ if (!gcm_enabled_) {
+ // Poll for channel status in order to find out when it is re-enabled when
+ // GCM is currently disabled.
+ if (GCMDriver::IsAllowedForAllUsers())
+ gcm_channel_status_syncer_->EnsureStarted();
+
return GCMClient::GCM_DISABLED;
+ }
// Have any app requested the service?
if (app_handlers().empty())