Commit c5fd1796 authored by dbeam's avatar dbeam Committed by Commit bot

Revert of Add GCMChannelStatusSyncer to schedule requests and enable/disable...

Revert of Add GCMChannelStatusSyncer to schedule requests and enable/disable GCM (patchset #8 id:150001 of https://codereview.chromium.org/561943002/)

Reason for revert:
this CL might be breaking browser_tests and interactive_ui_tests on ChromeOS because it's starting a request on startup.  here's an example:

[15345:15369:0918/132152:ERROR:leak_tracker.h(97)] Leaked 0x11cd70da7cc0 which was allocated by:
[15345:15369:0918/132152:ERROR:leak_tracker.h(98)] #0 0x7f44b584025e base::debug::StackTrace::StackTrace()
#1 0x000000dfc481 base::debug::LeakTracker<>::LeakTracker()
#2 0x000000df3e8d SystemURLRequestContextGetter::SystemURLRequestContextGetter()
#3 0x000000df57f1 IOThread::InitSystemRequestContext()
#4 0x000000df570b IOThread::system_url_request_context_getter()
#5 0x000001443d9e BrowserProcessImpl::system_request_context()
#6 0x000001028a8e SafeBrowsingService::Initialize()
#7 0x0000014462c9 BrowserProcessImpl::CreateSafeBrowsingService()
#8 0x000001446196 BrowserProcessImpl::safe_browsing_service()
#9 0x0000014b9a06 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate()
#10 0x0000014466dc BrowserProcessImpl::ResourceDispatcherHostCreated()
#11 0x0000008a88e5 chrome::ChromeContentBrowserClient::ResourceDispatcherHostCreated()
#12 0x7f44be489a2f content::ResourceDispatcherHostImpl::ResourceDispatcherHostImpl()
#13 0x7f44be060f44 content::BrowserMainLoop::BrowserThreadsStarted()
#14 0x7f44be068302 base::internal::RunnableAdapter<>::Run()
#15 0x7f44be06826c base::internal::InvokeHelper<>::MakeItSo()
#16 0x7f44be06821a base::internal::Invoker<>::Run()
#17 0x7f44be54e46e base::Callback<>::Run()
#18 0x7f44be8d223b content::StartupTaskRunner::RunAllTasksNow()
#19 0x7f44be05ff97 content::BrowserMainLoop::CreateStartupTasks()
#20 0x7f44be06b824 content::BrowserMainRunnerImpl::Initialize()
#21 0x7f44be05c7df content::BrowserMain()
#22 0x7f44bdee5f6f content::RunNamedProcessTypeMain()
#23 0x7f44bdee9268 content::ContentMainRunnerImpl::Run()
#24 0x7f44bdee5505 content::ContentMain()
#25 0x0000041aa8cb content::BrowserTestBase::SetUp()
#26 0x00000173e117 InProcessBrowserTest::SetUp()
#27 0x000000671180 ExtensionBrowserTest::SetUp()
#28 0x0000006711b2 ExtensionBrowserTest::SetUp()
#29 0x0000017fb993 testing::internal::HandleSehExceptionsInMethodIfSupported<>()
#30 0x0000017e8bfe testing::internal::HandleExceptionsInMethodIfSupported<>()
#31 0x0000017dd1e3 testing::Test::Run()
#32 0x0000017dd92b testing::TestInfo::Run()
#33 0x0000017ddf1a testing::TestCase::Run()
#34 0x0000017e3413 testing::internal::UnitTestImpl::RunAllTests()
#35 0x0000017f47d3 testing::internal::HandleSehExceptionsInMethodIfSupported<>()
#36 0x0000017ea96e testing::internal::HandleExceptionsInMethodIfSupported<>()
#37 0x0000017e30b1 testing::UnitTest::Run()
#38 0x000004187e41 RUN_ALL_TESTS()
#39 0x000004186e67 base::TestSuite::Run()
#40 0x0000007fcd62 InteractiveUITestSuiteRunner::RunTestSuite()
#41 0x00000173c7b8 (anonymous namespace)::ChromeTestLauncherDelegate::RunTestSuite()
#42 0x0000041bc2fb content::LaunchTests()
#43 0x00000173c6e9 LaunchChromeTests()
#44 0x0000007fccbf main
#45 0x7f44ad8ed76d __libc_start_main
#46 0x000000601389 <unknown>

[15345:15369:0918/132152:FATAL:leak_tracker.h(102)] Check failed: 0u == count (0 vs. 1)
#0 0x7f44b584025e base::debug::StackTrace::StackTrace()
#1 0x7f44b58d7a62 logging::LogMessage::~LogMessage()
#2 0x000000dfdd01 base::debug::LeakTracker<>::CheckForLeaks()
#3 0x000000df8e13 IOThread::CleanUp()
#4 0x7f44be0810b6 content::BrowserThreadImpl::CleanUp()
#5 0x7f44be07e852 content::BrowserProcessSubThread::CleanUp()
#6 0x7f44b59d0601 base::Thread::ThreadMain()
#7 0x7f44b59bba3c base::(anonymous namespace)::ThreadFunc()
#8 0x7f44b1aa9e9a start_thread
#9 0x7f44ad9c03fd clone

Original issue's description:
> Add GCMChannelStatusSyncer to schedule requests and enable/disable GCM
>
> BUG=384041
> TEST=new tests added
>
> Committed: https://crrev.com/3c23f4a188e171998f3042ad62f4aa5717e66d63
> Cr-Commit-Position: refs/heads/master@{#295524}

TBR=zea@chromium.org,fgorski@chromium.org,thestig@chromium.org,bauerb@chromium.org,jianli@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=384041

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

Cr-Commit-Position: refs/heads/master@{#295549}
parent aeae967c
......@@ -1135,7 +1135,6 @@ void BrowserProcessImpl::CreateGCMDriver() {
CHECK(PathService::Get(chrome::DIR_GLOBAL_GCM_STORE, &store_path));
gcm_driver_ = gcm::CreateGCMDriverDesktop(
make_scoped_ptr(new gcm::GCMClientFactory),
local_state(),
store_path,
system_request_context());
// Sign-in is not required for device-level GCM usage. So we just call
......
......@@ -82,7 +82,6 @@
#include "components/autofill/core/browser/autofill_manager.h"
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/dom_distiller/core/distilled_page_prefs.h"
#include "components/gcm_driver/gcm_channel_status_syncer.h"
#include "components/google/core/browser/google_pref_names.h"
#include "components/google/core/browser/google_url_tracker.h"
#include "components/network_time/network_time_tracker.h"
......@@ -294,8 +293,6 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
AutomaticProfileResetterFactory::RegisterPrefs(registry);
BackgroundModeManager::RegisterPrefs(registry);
RegisterBrowserPrefs(registry);
// The native GCM is used on Android instead.
gcm::GCMChannelStatusSyncer::RegisterPrefs(registry);
#if !defined(OS_CHROMEOS)
RegisterDefaultBrowserPromptPrefs(registry);
#endif // !defined(OS_CHROMEOS)
......@@ -446,7 +443,6 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
extensions::ExtensionSettingsHandler::RegisterProfilePrefs(registry);
extensions::TabsCaptureVisibleTabFunction::RegisterProfilePrefs(registry);
first_run::RegisterProfilePrefs(registry);
gcm::GCMChannelStatusSyncer::RegisterProfilePrefs(registry);
NewTabUI::RegisterProfilePrefs(registry);
PepperFlashSettingsManager::RegisterProfilePrefs(registry);
PinnedTabCodec::RegisterProfilePrefs(registry);
......
......@@ -73,7 +73,6 @@ GCMClient::ChromeBuildInfo GetChromeBuildInfo() {
scoped_ptr<GCMDriver> CreateGCMDriverDesktop(
scoped_ptr<GCMClientFactory> gcm_client_factory,
PrefService* prefs,
const base::FilePath& store_path,
const scoped_refptr<net::URLRequestContextGetter>& request_context) {
scoped_refptr<base::SequencedWorkerPool> worker_pool(
......@@ -85,7 +84,6 @@ scoped_ptr<GCMDriver> CreateGCMDriverDesktop(
return scoped_ptr<GCMDriver>(new GCMDriverDesktop(
gcm_client_factory.Pass(),
GetChromeBuildInfo(),
prefs,
store_path,
request_context,
content::BrowserThread::GetMessageLoopProxyForThread(
......
......@@ -8,7 +8,6 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
class PrefService;
namespace base {
class FilePath;
}
......@@ -24,7 +23,6 @@ class GCMClientFactory;
scoped_ptr<GCMDriver> CreateGCMDriverDesktop(
scoped_ptr<GCMClientFactory> gcm_client_factory,
PrefService* prefs,
const base::FilePath& store_path,
const scoped_refptr<net::URLRequestContextGetter>& request_context);
......
......@@ -169,7 +169,6 @@ GCMProfileService::GCMProfileService(
driver_ = CreateGCMDriverDesktop(
gcm_client_factory.Pass(),
profile_->GetPrefs(),
profile_->GetPath().Append(chrome::kGCMStoreDirname),
profile_->GetRequestContext());
......
......@@ -33,8 +33,6 @@
'gcm_driver/gcm_backoff_policy.h',
'gcm_driver/gcm_channel_status_request.cc',
'gcm_driver/gcm_channel_status_request.h',
'gcm_driver/gcm_channel_status_syncer.cc',
'gcm_driver/gcm_channel_status_syncer.h',
'gcm_driver/gcm_client.cc',
'gcm_driver/gcm_client.h',
'gcm_driver/gcm_client_factory.cc',
......@@ -75,8 +73,6 @@
'gcm_driver/gcm_account_mapper.h',
'gcm_driver/gcm_channel_status_request.cc',
'gcm_driver/gcm_channel_status_request.h',
'gcm_driver/gcm_channel_status_syncer.cc',
'gcm_driver/gcm_channel_status_syncer.h',
'gcm_driver/gcm_client_factory.cc',
'gcm_driver/gcm_client_factory.h',
'gcm_driver/gcm_client_impl.cc',
......
......@@ -17,8 +17,6 @@ static_library("gcm_driver") {
"gcm_backoff_policy.h",
"gcm_channel_status_request.cc",
"gcm_channel_status_request.h",
"gcm_channel_status_syncer.cc",
"gcm_channel_status_syncer.h",
"gcm_client.cc",
"gcm_client.h",
"gcm_client_factory.cc",
......@@ -53,8 +51,6 @@ static_library("gcm_driver") {
sources -= [
"gcm_channel_status_request.cc",
"gcm_channel_status_request.h",
"gcm_channel_status_syncer.cc",
"gcm_channel_status_syncer.h",
"gcm_client_factory.cc",
"gcm_client_factory.h",
"gcm_client_impl.cc",
......
include_rules = [
"+components/os_crypt",
"+components/pref_registry",
# TODO(johnme): Fix this layering violation.
"!content/public/android/java",
"+google_apis/gaia",
......
......@@ -41,12 +41,12 @@ GCMChannelStatusRequest::~GCMChannelStatusRequest() {
}
// static
int GCMChannelStatusRequest::default_poll_interval_seconds() {
int GCMChannelStatusRequest::default_poll_interval_seconds_for_testing() {
return kDefaultPollIntervalSeconds;
}
// static
int GCMChannelStatusRequest::min_poll_interval_seconds() {
int GCMChannelStatusRequest::min_poll_interval_seconds_for_testing() {
return kMinPollIntervalSeconds;
}
......
......@@ -36,8 +36,9 @@ class GCMChannelStatusRequest : public net::URLFetcherDelegate {
void Start();
static int default_poll_interval_seconds();
static int min_poll_interval_seconds();
// Exposed for testing purpose.
static int default_poll_interval_seconds_for_testing();
static int min_poll_interval_seconds_for_testing();
private:
// Overridden from URLFetcherDelegate:
......
......@@ -136,7 +136,7 @@ TEST_F(GCMChannelStatusRequestTest, ResponseWithDisabledStatus) {
EXPECT_TRUE(request_callback_invoked_);
EXPECT_FALSE(enabled_);
EXPECT_EQ(
GCMChannelStatusRequest::default_poll_interval_seconds(),
GCMChannelStatusRequest::default_poll_interval_seconds_for_testing(),
poll_interval_seconds_);
}
......@@ -148,7 +148,7 @@ TEST_F(GCMChannelStatusRequestTest, ResponseWithEnabledStatus) {
EXPECT_TRUE(request_callback_invoked_);
EXPECT_TRUE(enabled_);
EXPECT_EQ(
GCMChannelStatusRequest::default_poll_interval_seconds(),
GCMChannelStatusRequest::default_poll_interval_seconds_for_testing(),
poll_interval_seconds_);
}
......@@ -156,7 +156,8 @@ TEST_F(GCMChannelStatusRequestTest, ResponseWithPollInterval) {
// Setting a poll interval 15 minutes longer than the minimum interval we
// enforce.
int poll_interval_seconds =
GCMChannelStatusRequest::min_poll_interval_seconds() + 15 * 60;
GCMChannelStatusRequest::min_poll_interval_seconds_for_testing() +
15 * 60;
StartRequest();
SetResponseProtoData(NOT_SPECIFIED, poll_interval_seconds);
CompleteFetch();
......@@ -170,20 +171,22 @@ TEST_F(GCMChannelStatusRequestTest, ResponseWithShortPollInterval) {
// Setting a poll interval 15 minutes shorter than the minimum interval we
// enforce.
int poll_interval_seconds =
GCMChannelStatusRequest::min_poll_interval_seconds() - 15 * 60;
GCMChannelStatusRequest::min_poll_interval_seconds_for_testing() -
15 * 60;
StartRequest();
SetResponseProtoData(NOT_SPECIFIED, poll_interval_seconds);
CompleteFetch();
EXPECT_TRUE(request_callback_invoked_);
EXPECT_TRUE(enabled_);
EXPECT_EQ(GCMChannelStatusRequest::min_poll_interval_seconds(),
EXPECT_EQ(GCMChannelStatusRequest::min_poll_interval_seconds_for_testing(),
poll_interval_seconds_);
}
TEST_F(GCMChannelStatusRequestTest, ResponseWithDisabledStatusAndPollInterval) {
int poll_interval_seconds =
GCMChannelStatusRequest::min_poll_interval_seconds() + 15 * 60;
GCMChannelStatusRequest::min_poll_interval_seconds_for_testing() +
15 * 60;
StartRequest();
SetResponseProtoData(GCM_DISABLED, poll_interval_seconds);
CompleteFetch();
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/gcm_driver/gcm_channel_status_syncer.h"
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
#include "base/rand_util.h"
#include "components/gcm_driver/gcm_channel_status_request.h"
#include "components/gcm_driver/gcm_driver.h"
#include "components/pref_registry/pref_registry_syncable.h"
namespace gcm {
namespace {
// The GCM channel's enabled state.
const char kGCMChannelStatus[] = "gcm.channel_status";
// The GCM channel's polling interval (in seconds).
const char kGCMChannelPollIntervalSeconds[] = "gcm.poll_interval";
// Last time when checking with the GCM channel status server is done.
const char kGCMChannelLastCheckTime[] = "gcm.check_time";
// A small delay to avoid sending request at browser startup time for first-time
// request.
const int kFirstTimeDelaySeconds = 1 * 60; // 1 minute.
// The fuzzing variation added to the polling delay.
const int kGCMChannelRequestTimeJitterSeconds = 15 * 60; // 15 minues.
} // namespace
// static
void GCMChannelStatusSyncer::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(kGCMChannelStatus, true);
registry->RegisterIntegerPref(
kGCMChannelPollIntervalSeconds,
GCMChannelStatusRequest::default_poll_interval_seconds());
registry->RegisterInt64Pref(kGCMChannelLastCheckTime, 0);
}
// static
void GCMChannelStatusSyncer::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(
kGCMChannelStatus,
true,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterIntegerPref(
kGCMChannelPollIntervalSeconds,
GCMChannelStatusRequest::default_poll_interval_seconds(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterInt64Pref(
kGCMChannelLastCheckTime,
0,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
}
// static
int GCMChannelStatusSyncer::first_time_delay_seconds() {
return kFirstTimeDelaySeconds;
}
GCMChannelStatusSyncer::GCMChannelStatusSyncer(
GCMDriver* driver,
PrefService* prefs,
const scoped_refptr<net::URLRequestContextGetter>& request_context)
: driver_(driver),
prefs_(prefs),
request_context_(request_context),
gcm_enabled_(true),
poll_interval_seconds_(
GCMChannelStatusRequest::default_poll_interval_seconds()),
delay_removed_for_testing_(false),
weak_ptr_factory_(this) {
gcm_enabled_ = prefs_->GetBoolean(kGCMChannelStatus);
poll_interval_seconds_ = prefs_->GetInteger(kGCMChannelPollIntervalSeconds);
if (poll_interval_seconds_ <
GCMChannelStatusRequest::min_poll_interval_seconds()) {
poll_interval_seconds_ =
GCMChannelStatusRequest::min_poll_interval_seconds();
}
last_check_time_ = base::Time::FromInternalValue(
prefs_->GetInt64(kGCMChannelLastCheckTime));
}
GCMChannelStatusSyncer::~GCMChannelStatusSyncer() {
}
void GCMChannelStatusSyncer::EnsureStarted() {
// Bail out if the request is already scheduled or started.
if (weak_ptr_factory_.HasWeakPtrs() || request_)
return;
ScheduleRequest();
}
void GCMChannelStatusSyncer::Stop() {
request_.reset();
weak_ptr_factory_.InvalidateWeakPtrs();
}
void GCMChannelStatusSyncer::OnRequestCompleted(bool enabled,
int poll_interval_seconds) {
DCHECK(request_);
request_.reset();
// Persist the current time as the last request complete time.
last_check_time_ = base::Time::Now();
prefs_->SetInt64(kGCMChannelLastCheckTime,
last_check_time_.ToInternalValue());
if (gcm_enabled_ != enabled) {
gcm_enabled_ = enabled;
prefs_->SetBoolean(kGCMChannelStatus, enabled);
if (gcm_enabled_)
driver_->Enable();
else
driver_->Disable();
}
DCHECK_GE(poll_interval_seconds,
GCMChannelStatusRequest::min_poll_interval_seconds());
if (poll_interval_seconds_ != poll_interval_seconds) {
poll_interval_seconds_ = poll_interval_seconds;
prefs_->SetInteger(kGCMChannelPollIntervalSeconds, poll_interval_seconds_);
}
ScheduleRequest();
}
void GCMChannelStatusSyncer::ScheduleRequest() {
current_request_delay_interval_ = GetRequestDelayInterval();
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&GCMChannelStatusSyncer::StartRequest,
weak_ptr_factory_.GetWeakPtr()),
current_request_delay_interval_);
}
void GCMChannelStatusSyncer::StartRequest() {
DCHECK(!request_);
request_.reset(new GCMChannelStatusRequest(
request_context_,
base::Bind(&GCMChannelStatusSyncer::OnRequestCompleted,
weak_ptr_factory_.GetWeakPtr())));
request_->Start();
}
base::TimeDelta GCMChannelStatusSyncer::GetRequestDelayInterval() const {
// No delay during testing.
if (delay_removed_for_testing_)
return base::TimeDelta();
// Make sure that checking with server occurs at polling interval, regardless
// whether the browser restarts.
int64 delay_seconds = poll_interval_seconds_ -
(base::Time::Now() - last_check_time_).InSeconds();
if (delay_seconds < 0)
delay_seconds = 0;
if (last_check_time_.is_null()) {
// For the first-time request, add a small delay to avoid sending request at
// browser startup time.
DCHECK(!delay_seconds);
delay_seconds = kFirstTimeDelaySeconds;
} else {
// Otherwise, add a fuzzing variation to the delay.
delay_seconds += base::RandInt(0, kGCMChannelRequestTimeJitterSeconds);
}
return base::TimeDelta::FromSeconds(delay_seconds);
}
} // namespace gcm
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_SYNCER_H_
#define COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_SYNCER_H_
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
class PrefService;
class PrefRegistrySimple;
namespace net {
class URLRequestContextGetter;
}
namespace user_prefs {
class PrefRegistrySyncable;
}
namespace gcm {
class GCMChannelStatusRequest;
class GCMDriver;
// Syncing with the server for GCM channel status that controls if GCM
// functionality should be enabled or disabled.
class GCMChannelStatusSyncer {
public:
static void RegisterPrefs(PrefRegistrySimple* registry);
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
GCMChannelStatusSyncer(
GCMDriver* driver,
PrefService* prefs,
const scoped_refptr<net::URLRequestContextGetter>& request_context);
~GCMChannelStatusSyncer();
void EnsureStarted();
void Stop();
bool gcm_enabled() const { return gcm_enabled_; }
// For testing purpose.
void set_delay_removed_for_testing(bool delay_removed) {
delay_removed_for_testing_ = delay_removed;
}
base::TimeDelta current_request_delay_interval() const {
return current_request_delay_interval_;
}
static int first_time_delay_seconds();
private:
// Called when a request is completed.
void OnRequestCompleted(bool enabled, int poll_interval_seconds);
// Schedules next request to start after appropriate delay.
void ScheduleRequest();
// Creates and starts a request immediately.
void StartRequest();
// Computes and returns a delay with the fuzzing variation added if needed,
// after which the request could start.
base::TimeDelta GetRequestDelayInterval() const;
// GCMDriver owns GCMChannelStatusSyncer instance.
GCMDriver* driver_;
PrefService* prefs_;
scoped_refptr<net::URLRequestContextGetter> request_context_;
scoped_ptr<GCMChannelStatusRequest> request_;
bool gcm_enabled_;
int poll_interval_seconds_;
base::Time last_check_time_;
// The flag that indicates if the delay, including fuzzing variation and poll
// interval, is removed for testing purpose.
bool delay_removed_for_testing_;
// Tracked for testing purpose.
base::TimeDelta current_request_delay_interval_;
// Used to pass a weak pointer to a task.
base::WeakPtrFactory<GCMChannelStatusSyncer> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusSyncer);
};
} // namespace gcm
#endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_SYNCER_H_
......@@ -14,7 +14,6 @@
#include "base/sequenced_task_runner.h"
#include "base/threading/sequenced_worker_pool.h"
#include "components/gcm_driver/gcm_app_handler.h"
#include "components/gcm_driver/gcm_channel_status_syncer.h"
#include "components/gcm_driver/gcm_client_factory.h"
#include "components/gcm_driver/gcm_delayed_task_controller.h"
#include "components/gcm_driver/system_encryptor.h"
......@@ -330,22 +329,18 @@ void GCMDriverDesktop::IOWorker::RemoveAccountMapping(
GCMDriverDesktop::GCMDriverDesktop(
scoped_ptr<GCMClientFactory> gcm_client_factory,
const GCMClient::ChromeBuildInfo& chrome_build_info,
PrefService* prefs,
const base::FilePath& store_path,
const scoped_refptr<net::URLRequestContextGetter>& request_context,
const scoped_refptr<base::SequencedTaskRunner>& ui_thread,
const scoped_refptr<base::SequencedTaskRunner>& io_thread,
const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner)
: gcm_channel_status_syncer_(this, prefs, request_context),
signed_in_(false),
: signed_in_(false),
gcm_started_(false),
gcm_enabled_(true),
connected_(false),
ui_thread_(ui_thread),
io_thread_(io_thread),
weak_ptr_factory_(this) {
gcm_enabled_ = gcm_channel_status_syncer_.gcm_enabled();
// Create and initialize the GCMClient. Note that this does not initiate the
// GCM check-in.
io_worker_.reset(new IOWorker(ui_thread, io_thread));
......@@ -447,8 +442,6 @@ void GCMDriverDesktop::Stop() {
if (!gcm_started_)
return;
gcm_channel_status_syncer_.Stop();
RemoveCachedData();
io_thread_->PostTask(
......@@ -634,11 +627,6 @@ GCMClient::Result GCMDriverDesktop::EnsureStarted() {
DCHECK(!delayed_task_controller_);
delayed_task_controller_.reset(new GCMDelayedTaskController);
// Polling for channel status is only needed when GCM is supported for all
// users.
if (GCMDriver::IsAllowedForAllUsers())
gcm_channel_status_syncer_.EnsureStarted();
// Note that we need to pass weak pointer again since the existing weak
// pointer in IOWorker might have been invalidated when check-out occurs.
io_thread_->PostTask(
......
......@@ -15,13 +15,10 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "components/gcm_driver/gcm_channel_status_syncer.h"
#include "components/gcm_driver/gcm_client.h"
#include "components/gcm_driver/gcm_connection_observer.h"
#include "components/gcm_driver/gcm_driver.h"
class PrefService;
namespace base {
class FilePath;
class SequencedTaskRunner;
......@@ -47,7 +44,6 @@ class GCMDriverDesktop : public GCMDriver {
GCMDriverDesktop(
scoped_ptr<GCMClientFactory> gcm_client_factory,
const GCMClient::ChromeBuildInfo& chrome_build_info,
PrefService* prefs,
const base::FilePath& store_path,
const scoped_refptr<net::URLRequestContextGetter>& request_context,
const scoped_refptr<base::SequencedTaskRunner>& ui_thread,
......@@ -88,12 +84,6 @@ class GCMDriverDesktop : public GCMDriver {
void SetAccountsForCheckin(
const std::map<std::string, std::string>& account_tokens);
// Exposed for testing purpose.
bool gcm_enabled() const { return gcm_enabled_; }
GCMChannelStatusSyncer* gcm_channel_status_syncer_for_testing() {
return &gcm_channel_status_syncer_;
}
protected:
// GCMDriver implementation:
virtual GCMClient::Result EnsureStarted() OVERRIDE;
......@@ -135,8 +125,6 @@ class GCMDriverDesktop : public GCMDriver {
void GetGCMStatisticsFinished(const GCMClient::GCMStatistics& stats);
GCMChannelStatusSyncer gcm_channel_status_syncer_;
// Flag to indicate whether the user is signed in to a GAIA account.
// TODO(jianli): To be removed when sign-in enforcement is dropped.
bool signed_in_;
......@@ -145,7 +133,6 @@ class GCMDriverDesktop : public GCMDriver {
bool gcm_started_;
// Flag to indicate if GCM is enabled.
// TODO(jianli): Removed when we switch completely to support all users.
bool gcm_enabled_;
// Flag to indicate the last known state of the GCM client. Because this
......
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