Commit ae8cac69 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Cleanup: Delete GCMChannelStatusSyncer

It was used to check if "GCM is enabled" by calling a special API on the
Sync service, but in practice this has always been true for years.
Removing this code will let us (eventually) shut down this API.

Bug: 1009361
Change-Id: I9de53187fc85e5b4eac0a7c566aafe36dbb3442c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2017429Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735834}
parent 31f93aa2
...@@ -95,7 +95,6 @@ ...@@ -95,7 +95,6 @@
#include "components/dom_distiller/core/distilled_page_prefs.h" #include "components/dom_distiller/core/distilled_page_prefs.h"
#include "components/feature_engagement/buildflags.h" #include "components/feature_engagement/buildflags.h"
#include "components/flags_ui/pref_service_flags_storage.h" #include "components/flags_ui/pref_service_flags_storage.h"
#include "components/gcm_driver/gcm_channel_status_syncer.h"
#include "components/image_fetcher/core/cache/image_cache.h" #include "components/image_fetcher/core/cache/image_cache.h"
#include "components/invalidation/impl/invalidator_registrar_with_memory.h" #include "components/invalidation/impl/invalidator_registrar_with_memory.h"
#include "components/invalidation/impl/per_user_topic_subscription_manager.h" #include "components/invalidation/impl/per_user_topic_subscription_manager.h"
...@@ -527,6 +526,10 @@ const char kBlacklistedCredentialsNormalized[] = ...@@ -527,6 +526,10 @@ const char kBlacklistedCredentialsNormalized[] =
const char kKeyCreated[] = "os_crypt.key_created"; const char kKeyCreated[] = "os_crypt.key_created";
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
const char kGCMChannelStatus[] = "gcm.channel_status";
const char kGCMChannelPollIntervalSeconds[] = "gcm.poll_interval";
const char kGCMChannelLastCheckTime[] = "gcm.check_time";
// Register prefs used only for migration (clearing or moving to a new key). // Register prefs used only for migration (clearing or moving to a new key).
void RegisterProfilePrefsForMigration( void RegisterProfilePrefsForMigration(
user_prefs::PrefRegistrySyncable* registry) { user_prefs::PrefRegistrySyncable* registry) {
...@@ -614,6 +617,10 @@ void RegisterProfilePrefsForMigration( ...@@ -614,6 +617,10 @@ void RegisterProfilePrefsForMigration(
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
registry->RegisterBooleanPref(kBlacklistedCredentialsNormalized, false); registry->RegisterBooleanPref(kBlacklistedCredentialsNormalized, false);
registry->RegisterBooleanPref(kGCMChannelStatus, true);
registry->RegisterIntegerPref(kGCMChannelPollIntervalSeconds, 0);
registry->RegisterInt64Pref(kGCMChannelLastCheckTime, 0);
} }
} // namespace } // namespace
...@@ -668,8 +675,6 @@ void RegisterLocalState(PrefRegistrySimple* registry) { ...@@ -668,8 +675,6 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
::android::RegisterPrefs(registry); ::android::RegisterPrefs(registry);
#else #else
enterprise_reporting::RegisterLocalStatePrefs(registry); enterprise_reporting::RegisterLocalStatePrefs(registry);
// The native GCM is used on Android instead.
gcm::GCMChannelStatusSyncer::RegisterPrefs(registry);
gcm::RegisterPrefs(registry); gcm::RegisterPrefs(registry);
media_router::RegisterLocalStatePrefs(registry); media_router::RegisterLocalStatePrefs(registry);
metrics::TabStatsTracker::RegisterPrefs(registry); metrics::TabStatsTracker::RegisterPrefs(registry);
...@@ -784,6 +789,11 @@ void RegisterLocalState(PrefRegistrySimple* registry) { ...@@ -784,6 +789,11 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
#if defined(TOOLKIT_VIEWS) #if defined(TOOLKIT_VIEWS)
RegisterBrowserViewLocalPrefs(registry); RegisterBrowserViewLocalPrefs(registry);
#endif #endif
// Obsolete. See MigrateObsoleteBrowserPrefs().
registry->RegisterBooleanPref(kGCMChannelStatus, true);
registry->RegisterIntegerPref(kGCMChannelPollIntervalSeconds, 0);
registry->RegisterInt64Pref(kGCMChannelLastCheckTime, 0);
} }
// Register prefs applicable to all profiles. // Register prefs applicable to all profiles.
...@@ -935,7 +945,6 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry, ...@@ -935,7 +945,6 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
extensions::CommandService::RegisterProfilePrefs(registry); extensions::CommandService::RegisterProfilePrefs(registry);
extensions::TabsCaptureVisibleTabFunction::RegisterProfilePrefs(registry); extensions::TabsCaptureVisibleTabFunction::RegisterProfilePrefs(registry);
first_run::RegisterProfilePrefs(registry); first_run::RegisterProfilePrefs(registry);
gcm::GCMChannelStatusSyncer::RegisterProfilePrefs(registry);
gcm::RegisterProfilePrefs(registry); gcm::RegisterProfilePrefs(registry);
HatsService::RegisterProfilePrefs(registry); HatsService::RegisterProfilePrefs(registry);
HistoryUI::RegisterProfilePrefs(registry); HistoryUI::RegisterProfilePrefs(registry);
...@@ -1103,6 +1112,9 @@ void MigrateObsoleteBrowserPrefs(Profile* profile, PrefService* local_state) { ...@@ -1103,6 +1112,9 @@ void MigrateObsoleteBrowserPrefs(Profile* profile, PrefService* local_state) {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
local_state->ClearPref(kKeyCreated); local_state->ClearPref(kKeyCreated);
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
local_state->ClearPref(kGCMChannelStatus);
local_state->ClearPref(kGCMChannelPollIntervalSeconds);
local_state->ClearPref(kGCMChannelLastCheckTime);
} }
// This method should be periodically pruned of year+ old migrations. // This method should be periodically pruned of year+ old migrations.
...@@ -1241,4 +1253,9 @@ void MigrateObsoleteProfilePrefs(Profile* profile) { ...@@ -1241,4 +1253,9 @@ void MigrateObsoleteProfilePrefs(Profile* profile) {
// Added 11/2019. // Added 11/2019.
profile_prefs->ClearPref(kBlacklistedCredentialsNormalized); profile_prefs->ClearPref(kBlacklistedCredentialsNormalized);
// Added 1/2020.
profile_prefs->ClearPref(kGCMChannelStatus);
profile_prefs->ClearPref(kGCMChannelPollIntervalSeconds);
profile_prefs->ClearPref(kGCMChannelLastCheckTime);
} }
...@@ -99,10 +99,6 @@ static_library("gcm_driver") { ...@@ -99,10 +99,6 @@ static_library("gcm_driver") {
"gcm_account_mapper.h", "gcm_account_mapper.h",
"gcm_account_tracker.cc", "gcm_account_tracker.cc",
"gcm_account_tracker.h", "gcm_account_tracker.h",
"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.cc",
"gcm_client_factory.h", "gcm_client_factory.h",
"gcm_client_impl.cc", "gcm_client_impl.cc",
...@@ -210,7 +206,6 @@ source_set("unit_tests") { ...@@ -210,7 +206,6 @@ source_set("unit_tests") {
"account_tracker_unittest.cc", "account_tracker_unittest.cc",
"gcm_account_mapper_unittest.cc", "gcm_account_mapper_unittest.cc",
"gcm_account_tracker_unittest.cc", "gcm_account_tracker_unittest.cc",
"gcm_channel_status_request_unittest.cc",
"gcm_client_impl_unittest.cc", "gcm_client_impl_unittest.cc",
"gcm_driver_desktop_unittest.cc", "gcm_driver_desktop_unittest.cc",
"gcm_driver_unittest.cc", "gcm_driver_unittest.cc",
......
// 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_request.h"
#include "base/bind.h"
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/gcm_driver/gcm_backoff_policy.h"
#include "components/sync/protocol/experiment_status.pb.h"
#include "net/base/escape.h"
#include "net/base/load_flags.h"
#include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "url/gurl.h"
namespace gcm {
namespace {
const char kRequestContentType[] = "application/octet-stream";
const char kGCMChannelTag[] = "gcm_channel";
const int kDefaultPollIntervalSeconds = 60 * 60; // 60 minutes.
const int kMinPollIntervalSeconds = 30 * 60; // 30 minutes.
} // namespace
GCMChannelStatusRequest::GCMChannelStatusRequest(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const std::string& channel_status_request_url,
const std::string& user_agent,
const GCMChannelStatusRequestCallback& callback)
: url_loader_factory_(url_loader_factory),
channel_status_request_url_(channel_status_request_url),
user_agent_(user_agent),
callback_(callback),
backoff_entry_(&(GetGCMBackoffPolicy())) {}
GCMChannelStatusRequest::~GCMChannelStatusRequest() {
}
// static
int GCMChannelStatusRequest::default_poll_interval_seconds() {
return kDefaultPollIntervalSeconds;
}
// static
int GCMChannelStatusRequest::min_poll_interval_seconds() {
return kMinPollIntervalSeconds;
}
void GCMChannelStatusRequest::Start() {
// url_loader_factory_ can be null for tests.
if (!url_loader_factory_)
return;
DCHECK(!simple_url_loader_);
GURL request_url(channel_status_request_url_);
sync_pb::ExperimentStatusRequest proto_data;
proto_data.add_experiment_name(kGCMChannelTag);
std::string upload_data;
if (!proto_data.SerializeToString(&upload_data)) {
NOTREACHED();
}
net::NetworkTrafficAnnotationTag traffic_annotation =
net::DefineNetworkTrafficAnnotation("gcm_channel_status_request", R"(
semantics {
sender: "GCM Driver"
description:
"Google Chrome interacts with Google Cloud Messaging to receive "
"push messages for various browser features, as well as on behalf "
"of websites and extensions. The channel status request "
"periodically confirms with Google servers whether the feature "
"should be enabled."
trigger:
"Periodically when Chrome has established an active Google Cloud "
"Messaging subscription. The first request will be issued a minute "
"after the first subscription activates. Subsequent requests will "
"be issued each hour with a jitter of 15 minutes. Google can "
"adjust this interval when it deems necessary."
data:
"A user agent string containing the Chrome version, channel and "
"platform will be sent to the server. No user identifier is sent "
"along with the request."
destination: GOOGLE_OWNED_SERVICE
}
policy {
cookies_allowed: NO
setting:
"Support for interacting with Google Cloud Messaging is enabled by "
"default, and there is no configuration option to completely "
"disable it. Websites wishing to receive push messages must "
"acquire express permission from the user for the 'Notification' "
"permission."
policy_exception_justification:
"Not implemented, considered not useful."
})");
auto resource_request = std::make_unique<network::ResourceRequest>();
resource_request->url = request_url;
resource_request->credentials_mode = network::mojom::CredentialsMode::kOmit;
resource_request->method = "POST";
resource_request->headers.SetHeader(net::HttpRequestHeaders::kUserAgent,
user_agent_);
simple_url_loader_ = network::SimpleURLLoader::Create(
std::move(resource_request), traffic_annotation);
simple_url_loader_->AttachStringForUpload(upload_data, kRequestContentType);
simple_url_loader_->DownloadToStringOfUnboundedSizeUntilCrashAndDie(
url_loader_factory_.get(),
base::BindOnce(&GCMChannelStatusRequest::OnSimpleLoaderComplete,
base::Unretained(this)));
}
void GCMChannelStatusRequest::OnSimpleLoaderComplete(
std::unique_ptr<std::string> response_body) {
if (ParseResponse(std::move(response_body)))
return;
RetryWithBackoff(true);
}
bool GCMChannelStatusRequest::ParseResponse(
std::unique_ptr<std::string> response_body) {
if (simple_url_loader_->ResponseInfo() &&
simple_url_loader_->ResponseInfo()->headers) {
int response_code =
simple_url_loader_->ResponseInfo()->headers->response_code();
if (response_code != net::HTTP_OK) {
LOG(ERROR) << "GCM channel request failed. HTTP status: "
<< response_code;
return false;
}
}
if (!response_body) {
LOG(ERROR) << "GCM channel request failed.";
return false;
}
// Empty response means to keep the existing values.
if (response_body->empty()) {
callback_.Run(false, false, 0);
return true;
}
sync_pb::ExperimentStatusResponse response_proto;
if (!response_proto.ParseFromString(*response_body)) {
LOG(ERROR) << "GCM channel response failed to be parsed as proto.";
return false;
}
ParseResponseProto(response_proto);
return true;
}
void GCMChannelStatusRequest::ParseResponseProto(
sync_pb::ExperimentStatusResponse response_proto) {
bool enabled = true;
if (response_proto.experiment_size() == 1 &&
response_proto.experiment(0).has_gcm_channel() &&
response_proto.experiment(0).gcm_channel().has_enabled()) {
enabled = response_proto.experiment(0).gcm_channel().enabled();
}
int poll_interval_seconds;
if (response_proto.has_poll_interval_seconds())
poll_interval_seconds = response_proto.poll_interval_seconds();
else
poll_interval_seconds = kDefaultPollIntervalSeconds;
if (poll_interval_seconds < kMinPollIntervalSeconds)
poll_interval_seconds = kMinPollIntervalSeconds;
callback_.Run(true, enabled, poll_interval_seconds);
}
void GCMChannelStatusRequest::RetryWithBackoff(bool update_backoff) {
if (update_backoff) {
simple_url_loader_.reset();
backoff_entry_.InformOfRequest(false);
}
if (backoff_entry_.ShouldRejectRequest()) {
DVLOG(1) << "Delaying GCM channel request for "
<< backoff_entry_.GetTimeUntilRelease().InMilliseconds()
<< " ms.";
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(&GCMChannelStatusRequest::RetryWithBackoff,
weak_ptr_factory_.GetWeakPtr(), false),
backoff_entry_.GetTimeUntilRelease());
return;
}
Start();
}
} // 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_REQUEST_H_
#define COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_
#include <memory>
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "net/base/backoff_entry.h"
namespace network {
class SharedURLLoaderFactory;
class SimpleURLLoader;
} // namespace network
namespace sync_pb {
class ExperimentStatusResponse;
}
namespace gcm {
// Defines the request to talk with the server to determine if the GCM support
// should be enabled.
class GCMChannelStatusRequest {
public:
// Callback completing the channel status request.
// |update_received|: use the existing values if it is false which means no
// update is received.
// |enabled|: indicates if GCM is enabled (allowed to run) or not.
// |poll_interval_seconds|: the interval in seconds to start next poll
// request.
typedef base::Callback<void(bool update_received,
bool enabled,
int poll_interval_seconds)>
GCMChannelStatusRequestCallback;
GCMChannelStatusRequest(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const std::string& channel_status_request_url,
const std::string& user_agent,
const GCMChannelStatusRequestCallback& callback);
~GCMChannelStatusRequest();
void Start();
static int default_poll_interval_seconds();
static int min_poll_interval_seconds();
// Public so tests can use it.
void ParseResponseProto(sync_pb::ExperimentStatusResponse response_proto);
private:
FRIEND_TEST_ALL_PREFIXES(GCMChannelStatusRequestTest, RequestData);
void OnSimpleLoaderComplete(std::unique_ptr<std::string> response_body);
bool ParseResponse(std::unique_ptr<std::string> response_body);
void RetryWithBackoff(bool update_backoff);
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
const std::string channel_status_request_url_;
const std::string user_agent_;
GCMChannelStatusRequestCallback callback_;
std::unique_ptr<network::SimpleURLLoader> simple_url_loader_;
net::BackoffEntry backoff_entry_;
base::WeakPtrFactory<GCMChannelStatusRequest> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusRequest);
};
} // namespace gcm
#endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_REQUEST_H_
// 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_request.h"
#include "base/bind.h"
#include "base/run_loop.h"
#include "base/test/bind_test_util.h"
#include "base/test/task_environment.h"
#include "components/sync/protocol/experiment_status.pb.h"
#include "components/sync/protocol/experiments_specifics.pb.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
#include "services/network/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace gcm {
namespace {
const char kTestURL[] = "http://channel.status.request.com/";
}
class GCMChannelStatusRequestTest : public testing::Test {
public:
GCMChannelStatusRequestTest();
~GCMChannelStatusRequestTest() override;
protected:
enum GCMStatus {
NOT_SPECIFIED,
GCM_ENABLED,
GCM_DISABLED,
};
void CreateRequest();
void SetResponseStatusAndString(net::HttpStatusCode status_code,
const std::string& response_body);
void SetResponseProtoData(GCMStatus status, int poll_interval_seconds);
void StartRequest();
void OnRequestCompleted(bool update_received,
bool enabled,
int poll_interval_seconds);
network::TestURLLoaderFactory* test_url_loader_factory();
std::unique_ptr<GCMChannelStatusRequest> request_;
base::test::SingleThreadTaskEnvironment task_environment_;
network::TestURLLoaderFactory test_url_loader_factory_;
scoped_refptr<network::SharedURLLoaderFactory> test_shared_loader_factory_;
bool request_callback_invoked_;
bool update_received_;
bool enabled_;
int poll_interval_seconds_;
};
GCMChannelStatusRequestTest::GCMChannelStatusRequestTest()
: test_shared_loader_factory_(
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&test_url_loader_factory_)),
request_callback_invoked_(false),
update_received_(false),
enabled_(true),
poll_interval_seconds_(0) {}
GCMChannelStatusRequestTest::~GCMChannelStatusRequestTest() {
}
void GCMChannelStatusRequestTest::CreateRequest() {
request_.reset(new GCMChannelStatusRequest(
test_shared_loader_factory_, kTestURL, "user agent string",
base::Bind(&GCMChannelStatusRequestTest::OnRequestCompleted,
base::Unretained(this))));
test_url_loader_factory_.ClearResponses();
}
void GCMChannelStatusRequestTest::SetResponseStatusAndString(
net::HttpStatusCode status_code,
const std::string& response_body) {
test_url_loader_factory_.AddResponse(kTestURL, response_body, status_code);
}
void GCMChannelStatusRequestTest::SetResponseProtoData(
GCMStatus status, int poll_interval_seconds) {
sync_pb::ExperimentStatusResponse response_proto;
if (status != NOT_SPECIFIED) {
sync_pb::ExperimentsSpecifics* experiment_specifics =
response_proto.add_experiment();
experiment_specifics->mutable_gcm_channel()->set_enabled(status ==
GCM_ENABLED);
}
// Zero |poll_interval_seconds| means the optional field is not set.
if (poll_interval_seconds)
response_proto.set_poll_interval_seconds(poll_interval_seconds);
std::string response_string;
response_proto.SerializeToString(&response_string);
SetResponseStatusAndString(net::HTTP_OK, response_string);
}
void GCMChannelStatusRequestTest::StartRequest() {
request_->Start();
base::RunLoop run_loop;
run_loop.RunUntilIdle();
}
void GCMChannelStatusRequestTest::OnRequestCompleted(
bool update_received, bool enabled, int poll_interval_seconds) {
request_callback_invoked_ = true;
update_received_ = update_received;
enabled_ = enabled;
poll_interval_seconds_ = poll_interval_seconds;
}
network::TestURLLoaderFactory*
GCMChannelStatusRequestTest::test_url_loader_factory() {
return &test_url_loader_factory_;
}
TEST_F(GCMChannelStatusRequestTest, RequestData) {
CreateRequest();
GURL intercepted_url;
net::HttpRequestHeaders intercepted_headers;
std::string upload_data;
test_url_loader_factory()->SetInterceptor(
base::BindLambdaForTesting([&](const network::ResourceRequest& request) {
intercepted_url = request.url;
intercepted_headers = request.headers;
upload_data = network::GetUploadData(request);
}));
StartRequest();
EXPECT_EQ(GURL(request_->channel_status_request_url_), intercepted_url);
std::string user_agent_header;
intercepted_headers.GetHeader("User-Agent", &user_agent_header);
EXPECT_FALSE(user_agent_header.empty());
EXPECT_EQ(request_->user_agent_, user_agent_header);
EXPECT_FALSE(upload_data.empty());
sync_pb::ExperimentStatusRequest proto_data;
proto_data.ParseFromString(upload_data);
EXPECT_EQ(1, proto_data.experiment_name_size());
EXPECT_EQ("gcm_channel", proto_data.experiment_name(0));
}
TEST_F(GCMChannelStatusRequestTest, ResponseHttpStatusNotOK) {
CreateRequest();
SetResponseStatusAndString(net::HTTP_UNAUTHORIZED, "");
StartRequest();
EXPECT_FALSE(request_callback_invoked_);
}
TEST_F(GCMChannelStatusRequestTest, ResponseEmpty) {
CreateRequest();
SetResponseStatusAndString(net::HTTP_OK, "");
StartRequest();
EXPECT_TRUE(request_callback_invoked_);
EXPECT_FALSE(update_received_);
}
TEST_F(GCMChannelStatusRequestTest, ResponseNotInProtoFormat) {
CreateRequest();
SetResponseStatusAndString(net::HTTP_OK, "foo");
StartRequest();
EXPECT_FALSE(request_callback_invoked_);
}
TEST_F(GCMChannelStatusRequestTest, ResponseEmptyProtoData) {
CreateRequest();
SetResponseProtoData(NOT_SPECIFIED, 0);
StartRequest();
EXPECT_TRUE(request_callback_invoked_);
EXPECT_FALSE(update_received_);
}
TEST_F(GCMChannelStatusRequestTest, ResponseWithDisabledStatus) {
CreateRequest();
SetResponseProtoData(GCM_DISABLED, 0);
StartRequest();
EXPECT_TRUE(request_callback_invoked_);
EXPECT_TRUE(update_received_);
EXPECT_FALSE(enabled_);
EXPECT_EQ(
GCMChannelStatusRequest::default_poll_interval_seconds(),
poll_interval_seconds_);
}
TEST_F(GCMChannelStatusRequestTest, ResponseWithEnabledStatus) {
CreateRequest();
SetResponseProtoData(GCM_ENABLED, 0);
StartRequest();
EXPECT_TRUE(request_callback_invoked_);
EXPECT_TRUE(update_received_);
EXPECT_TRUE(enabled_);
EXPECT_EQ(
GCMChannelStatusRequest::default_poll_interval_seconds(),
poll_interval_seconds_);
}
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;
CreateRequest();
SetResponseProtoData(NOT_SPECIFIED, poll_interval_seconds);
StartRequest();
EXPECT_TRUE(request_callback_invoked_);
EXPECT_TRUE(update_received_);
EXPECT_TRUE(enabled_);
EXPECT_EQ(poll_interval_seconds, poll_interval_seconds_);
}
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;
CreateRequest();
SetResponseProtoData(NOT_SPECIFIED, poll_interval_seconds);
StartRequest();
EXPECT_TRUE(request_callback_invoked_);
EXPECT_TRUE(update_received_);
EXPECT_TRUE(enabled_);
EXPECT_EQ(GCMChannelStatusRequest::min_poll_interval_seconds(),
poll_interval_seconds_);
}
TEST_F(GCMChannelStatusRequestTest, ResponseWithDisabledStatusAndPollInterval) {
int poll_interval_seconds =
GCMChannelStatusRequest::min_poll_interval_seconds() + 15 * 60;
CreateRequest();
SetResponseProtoData(GCM_DISABLED, poll_interval_seconds);
StartRequest();
EXPECT_TRUE(request_callback_invoked_);
EXPECT_TRUE(update_received_);
EXPECT_FALSE(enabled_);
EXPECT_EQ(poll_interval_seconds, poll_interval_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.
#include "components/gcm_driver/gcm_channel_status_syncer.h"
#include <stdint.h>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/rand_util.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/threading/thread_task_runner_handle.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"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace gcm {
namespace {
// 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.
// The minimum poll interval that can be overridden to.
const int kMinCustomPollIntervalMinutes = 2;
// Custom poll interval could not be used more than the limit below.
const int kMaxNumberToUseCustomPollInterval = 10;
} // namespace
namespace prefs {
// 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";
} // namepsace prefs
namespace switches {
// Override the default poll interval for testing purpose.
const char kCustomPollIntervalMinutes[] = "gcm-channel-poll-interval";
} // namepsace switches
// static
void GCMChannelStatusSyncer::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(prefs::kGCMChannelStatus, true);
registry->RegisterIntegerPref(
prefs::kGCMChannelPollIntervalSeconds,
GCMChannelStatusRequest::default_poll_interval_seconds());
registry->RegisterInt64Pref(prefs::kGCMChannelLastCheckTime, 0);
}
// static
void GCMChannelStatusSyncer::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(prefs::kGCMChannelStatus, true);
registry->RegisterIntegerPref(
prefs::kGCMChannelPollIntervalSeconds,
GCMChannelStatusRequest::default_poll_interval_seconds());
registry->RegisterInt64Pref(prefs::kGCMChannelLastCheckTime, 0);
}
// static
int GCMChannelStatusSyncer::first_time_delay_seconds() {
return kFirstTimeDelaySeconds;
}
GCMChannelStatusSyncer::GCMChannelStatusSyncer(
GCMDriver* driver,
PrefService* prefs,
const std::string& channel_status_request_url,
const std::string& user_agent,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory)
: driver_(driver),
prefs_(prefs),
channel_status_request_url_(channel_status_request_url),
user_agent_(user_agent),
url_loader_factory_(std::move(url_loader_factory)),
started_(false),
gcm_enabled_(true),
poll_interval_seconds_(
GCMChannelStatusRequest::default_poll_interval_seconds()),
custom_poll_interval_use_count_(0),
delay_removed_for_testing_(false) {
gcm_enabled_ = prefs_->GetBoolean(prefs::kGCMChannelStatus);
poll_interval_seconds_ = prefs_->GetInteger(
prefs::kGCMChannelPollIntervalSeconds);
if (poll_interval_seconds_ <
GCMChannelStatusRequest::min_poll_interval_seconds()) {
poll_interval_seconds_ =
GCMChannelStatusRequest::min_poll_interval_seconds();
}
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kCustomPollIntervalMinutes)) {
std::string value(command_line.GetSwitchValueASCII(
switches::kCustomPollIntervalMinutes));
int minutes = 0;
if (base::StringToInt(value, &minutes)) {
DCHECK_GE(minutes, kMinCustomPollIntervalMinutes);
if (minutes >= kMinCustomPollIntervalMinutes) {
poll_interval_seconds_ = minutes * 60;
custom_poll_interval_use_count_ = kMaxNumberToUseCustomPollInterval;
}
}
}
last_check_time_ = base::Time::FromInternalValue(
prefs_->GetInt64(prefs::kGCMChannelLastCheckTime));
}
GCMChannelStatusSyncer::~GCMChannelStatusSyncer() {
}
void GCMChannelStatusSyncer::EnsureStarted() {
// Bail out if the request is already scheduled or started.
if (started_)
return;
started_ = true;
ScheduleRequest();
}
void GCMChannelStatusSyncer::Stop() {
started_ = false;
request_.reset();
weak_ptr_factory_.InvalidateWeakPtrs();
}
void GCMChannelStatusSyncer::OnRequestCompleted(bool update_received,
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(prefs::kGCMChannelLastCheckTime,
last_check_time_.ToInternalValue());
if (update_received) {
if (gcm_enabled_ != enabled) {
gcm_enabled_ = enabled;
prefs_->SetBoolean(prefs::kGCMChannelStatus, enabled);
if (gcm_enabled_)
driver_->Enable();
else
driver_->Disable();
}
// Skip updating poll interval if the custom one is still in effect.
if (!custom_poll_interval_use_count_) {
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(prefs::kGCMChannelPollIntervalSeconds,
poll_interval_seconds_);
}
}
}
// Do not schedule next request if syncer is stopped.
if (started_)
ScheduleRequest();
}
void GCMChannelStatusSyncer::ScheduleRequest() {
current_request_delay_interval_ = GetRequestDelayInterval();
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(&GCMChannelStatusSyncer::StartRequest,
weak_ptr_factory_.GetWeakPtr()),
current_request_delay_interval_);
if (custom_poll_interval_use_count_)
custom_poll_interval_use_count_--;
}
void GCMChannelStatusSyncer::StartRequest() {
DCHECK(!request_);
if (channel_status_request_url_.empty())
return;
request_.reset(new GCMChannelStatusRequest(
url_loader_factory_, channel_status_request_url_, user_agent_,
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_t 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.
// The fuzzing variation is off when the custom interval is used.
if (!custom_poll_interval_use_count_)
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 <memory>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
class PrefService;
class PrefRegistrySimple;
namespace network {
class SharedURLLoaderFactory;
}
namespace user_prefs {
class PrefRegistrySyncable;
}
namespace gcm {
class GCMChannelStatusRequest;
class GCMDriver;
namespace prefs {
// The GCM channel's enabled state.
extern const char kGCMChannelStatus[];
} // namepsace prefs
// 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 std::string& channel_status_request_url,
const std::string& user_agent,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
~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_;
}
GCMChannelStatusRequest* request_for_testing() const {
return request_.get();
}
static int first_time_delay_seconds();
private:
// Called when a request is completed.
void OnRequestCompleted(bool update_received,
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_;
const std::string channel_status_request_url_;
const std::string user_agent_;
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
std::unique_ptr<GCMChannelStatusRequest> request_;
bool started_;
bool gcm_enabled_;
int poll_interval_seconds_;
base::Time last_check_time_;
// If non-zero, |poll_interval_seconds_| is overriden by the command line
// options for testing purpose. Each time when the custom poll interval is
// used, this count is subtracted by one. When it reaches zero, the default
// poll interval will be used instead.
int custom_poll_interval_use_count_;
// 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_{this};
DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusSyncer);
};
} // namespace gcm
#endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_SYNCER_H_
...@@ -20,8 +20,6 @@ namespace gcm { ...@@ -20,8 +20,6 @@ namespace gcm {
namespace { namespace {
const char kChannelStatusRelativePath[] = "/experimentstatus";
GCMClient::ChromePlatform GetPlatform() { GCMClient::ChromePlatform GetPlatform() {
#if defined(OS_WIN) #if defined(OS_WIN)
return GCMClient::PLATFORM_WIN; return GCMClient::PLATFORM_WIN;
...@@ -74,12 +72,6 @@ GCMClient::ChromeBuildInfo GetChromeBuildInfo( ...@@ -74,12 +72,6 @@ GCMClient::ChromeBuildInfo GetChromeBuildInfo(
return chrome_build_info; return chrome_build_info;
} }
std::string GetChannelStatusRequestUrl(version_info::Channel channel) {
GURL sync_url(syncer::GetSyncServiceURL(
*base::CommandLine::ForCurrentProcess(), channel));
return sync_url.spec() + kChannelStatusRelativePath;
}
} // namespace } // namespace
std::unique_ptr<GCMDriver> CreateGCMDriverDesktop( std::unique_ptr<GCMDriver> CreateGCMDriverDesktop(
...@@ -100,7 +92,6 @@ std::unique_ptr<GCMDriver> CreateGCMDriverDesktop( ...@@ -100,7 +92,6 @@ std::unique_ptr<GCMDriver> CreateGCMDriverDesktop(
return std::unique_ptr<GCMDriver>(new GCMDriverDesktop( return std::unique_ptr<GCMDriver>(new GCMDriverDesktop(
std::move(gcm_client_factory), std::move(gcm_client_factory),
GetChromeBuildInfo(channel, product_category_for_subtypes), GetChromeBuildInfo(channel, product_category_for_subtypes),
GetChannelStatusRequestUrl(channel),
syncer::MakeUserAgentForSync(channel), prefs, store_path, syncer::MakeUserAgentForSync(channel), prefs, store_path,
remove_account_mappings_with_email_key, get_socket_factory_callback, remove_account_mappings_with_email_key, get_socket_factory_callback,
std::move(url_loader_factory), network_connection_tracker, ui_task_runner, std::move(url_loader_factory), network_connection_tracker, ui_task_runner,
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "components/gcm_driver/gcm_account_mapper.h" #include "components/gcm_driver/gcm_account_mapper.h"
#include "components/gcm_driver/gcm_app_handler.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_client_factory.h"
#include "components/gcm_driver/gcm_delayed_task_controller.h" #include "components/gcm_driver/gcm_delayed_task_controller.h"
#include "components/gcm_driver/instance_id/instance_id_impl.h" #include "components/gcm_driver/instance_id/instance_id_impl.h"
...@@ -514,7 +513,6 @@ void GCMDriverDesktop::IOWorker::RecordDecryptionFailure( ...@@ -514,7 +513,6 @@ void GCMDriverDesktop::IOWorker::RecordDecryptionFailure(
GCMDriverDesktop::GCMDriverDesktop( GCMDriverDesktop::GCMDriverDesktop(
std::unique_ptr<GCMClientFactory> gcm_client_factory, std::unique_ptr<GCMClientFactory> gcm_client_factory,
const GCMClient::ChromeBuildInfo& chrome_build_info, const GCMClient::ChromeBuildInfo& chrome_build_info,
const std::string& channel_status_request_url,
const std::string& user_agent, const std::string& user_agent,
PrefService* prefs, PrefService* prefs,
const base::FilePath& store_path, const base::FilePath& store_path,
...@@ -528,12 +526,6 @@ GCMDriverDesktop::GCMDriverDesktop( ...@@ -528,12 +526,6 @@ GCMDriverDesktop::GCMDriverDesktop(
const scoped_refptr<base::SequencedTaskRunner>& io_thread, const scoped_refptr<base::SequencedTaskRunner>& io_thread,
const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner)
: GCMDriver(store_path, blocking_task_runner, url_loader_factory_for_ui), : GCMDriver(store_path, blocking_task_runner, url_loader_factory_for_ui),
gcm_channel_status_syncer_(
new GCMChannelStatusSyncer(this,
prefs,
channel_status_request_url,
user_agent,
url_loader_factory_for_ui)),
signed_in_(false), signed_in_(false),
gcm_started_(false), gcm_started_(false),
gcm_enabled_(true), gcm_enabled_(true),
...@@ -546,8 +538,6 @@ GCMDriverDesktop::GCMDriverDesktop( ...@@ -546,8 +538,6 @@ GCMDriverDesktop::GCMDriverDesktop(
ui_thread_(ui_thread), ui_thread_(ui_thread),
io_thread_(io_thread), io_thread_(io_thread),
wake_from_suspend_enabled_(false) { wake_from_suspend_enabled_(false) {
gcm_enabled_ = gcm_channel_status_syncer_->gcm_enabled();
// Create and initialize the GCMClient. Note that this does not initiate the // Create and initialize the GCMClient. Note that this does not initiate the
// GCM check-in. // GCM check-in.
io_worker_.reset(new IOWorker(ui_thread, io_thread)); io_worker_.reset(new IOWorker(ui_thread, io_thread));
...@@ -623,11 +613,6 @@ void GCMDriverDesktop::Shutdown() { ...@@ -623,11 +613,6 @@ void GCMDriverDesktop::Shutdown() {
Stop(); Stop();
GCMDriver::Shutdown(); GCMDriver::Shutdown();
// Dispose the syncer in order to release the reference to
// URLRequestContextGetter that needs to be done before IOThread gets
// deleted.
gcm_channel_status_syncer_.reset();
io_thread_->DeleteSoon(FROM_HERE, io_worker_.release()); io_thread_->DeleteSoon(FROM_HERE, io_worker_.release());
} }
...@@ -654,10 +639,8 @@ void GCMDriverDesktop::RemoveAppHandler(const std::string& app_id) { ...@@ -654,10 +639,8 @@ void GCMDriverDesktop::RemoveAppHandler(const std::string& app_id) {
// Stops the GCM service when no app intends to consume it. Stop function will // Stops the GCM service when no app intends to consume it. Stop function will
// remove the last app handler - account mapper. // remove the last app handler - account mapper.
if (app_handlers().size() == 1) { if (app_handlers().size() == 1)
Stop(); Stop();
gcm_channel_status_syncer_->Stop();
}
} }
void GCMDriverDesktop::AddConnectionObserver(GCMConnectionObserver* observer) { void GCMDriverDesktop::AddConnectionObserver(GCMConnectionObserver* observer) {
...@@ -1262,10 +1245,6 @@ GCMClient::Result GCMDriverDesktop::EnsureStarted( ...@@ -1262,10 +1245,6 @@ GCMClient::Result GCMDriverDesktop::EnsureStarted(
if (app_handlers().empty()) if (app_handlers().empty())
return GCMClient::UNKNOWN_ERROR; return GCMClient::UNKNOWN_ERROR;
// Polling for channel status should be invoked when GCM is being requested,
// no matter whether GCM is enabled or nor.
gcm_channel_status_syncer_->EnsureStarted();
if (!gcm_enabled_) if (!gcm_enabled_)
return GCMClient::GCM_DISABLED; return GCMClient::GCM_DISABLED;
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/tuple.h" #include "base/tuple.h"
#include "components/gcm_driver/crypto/gcm_decryption_result.h" #include "components/gcm_driver/crypto/gcm_decryption_result.h"
#include "components/gcm_driver/gcm_channel_status_syncer.h"
#include "components/gcm_driver/gcm_client.h" #include "components/gcm_driver/gcm_client.h"
#include "components/gcm_driver/gcm_connection_observer.h" #include "components/gcm_driver/gcm_connection_observer.h"
#include "components/gcm_driver/gcm_driver.h" #include "components/gcm_driver/gcm_driver.h"
...@@ -55,7 +54,6 @@ class GCMDriverDesktop : public GCMDriver, ...@@ -55,7 +54,6 @@ class GCMDriverDesktop : public GCMDriver,
GCMDriverDesktop( GCMDriverDesktop(
std::unique_ptr<GCMClientFactory> gcm_client_factory, std::unique_ptr<GCMClientFactory> gcm_client_factory,
const GCMClient::ChromeBuildInfo& chrome_build_info, const GCMClient::ChromeBuildInfo& chrome_build_info,
const std::string& channel_status_request_url,
const std::string& user_agent, const std::string& user_agent,
PrefService* prefs, PrefService* prefs,
const base::FilePath& store_path, const base::FilePath& store_path,
...@@ -105,9 +103,6 @@ class GCMDriverDesktop : public GCMDriver, ...@@ -105,9 +103,6 @@ class GCMDriverDesktop : public GCMDriver,
// Exposed for testing purpose. // Exposed for testing purpose.
bool gcm_enabled() const { return gcm_enabled_; } bool gcm_enabled() const { return gcm_enabled_; }
GCMChannelStatusSyncer* gcm_channel_status_syncer_for_testing() {
return gcm_channel_status_syncer_.get();
}
protected: protected:
// GCMDriver implementation: // GCMDriver implementation:
...@@ -208,8 +203,6 @@ class GCMDriverDesktop : public GCMDriver, ...@@ -208,8 +203,6 @@ class GCMDriverDesktop : public GCMDriver,
const std::string& scope, const std::string& scope,
GCMClient::Result result); GCMClient::Result result);
std::unique_ptr<GCMChannelStatusSyncer> gcm_channel_status_syncer_;
// Flag to indicate whether the user is signed in to a GAIA account. // Flag to indicate whether the user is signed in to a GAIA account.
bool signed_in_; bool signed_in_;
......
...@@ -23,14 +23,10 @@ ...@@ -23,14 +23,10 @@
#include "components/gcm_driver/fake_gcm_client.h" #include "components/gcm_driver/fake_gcm_client.h"
#include "components/gcm_driver/fake_gcm_client_factory.h" #include "components/gcm_driver/fake_gcm_client_factory.h"
#include "components/gcm_driver/gcm_app_handler.h" #include "components/gcm_driver/gcm_app_handler.h"
#include "components/gcm_driver/gcm_channel_status_request.h"
#include "components/gcm_driver/gcm_channel_status_syncer.h"
#include "components/gcm_driver/gcm_client_factory.h" #include "components/gcm_driver/gcm_client_factory.h"
#include "components/gcm_driver/gcm_connection_observer.h" #include "components/gcm_driver/gcm_connection_observer.h"
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h" #include "components/prefs/testing_pref_service.h"
#include "components/sync/protocol/experiment_status.pb.h"
#include "components/sync/protocol/experiments_specifics.pb.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_test_util.h" #include "net/url_request/url_request_test_util.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
...@@ -43,7 +39,6 @@ namespace gcm { ...@@ -43,7 +39,6 @@ namespace gcm {
namespace { namespace {
const char kTestChannelStatusRequestURL[] = "http://channel.status.request.com";
const char kTestAppID1[] = "TestApp1"; const char kTestAppID1[] = "TestApp1";
const char kTestAppID2[] = "TestApp2"; const char kTestAppID2[] = "TestApp2";
const char kUserID1[] = "user1"; const char kUserID1[] = "user1";
...@@ -198,7 +193,6 @@ GCMDriverTest::~GCMDriverTest() { ...@@ -198,7 +193,6 @@ GCMDriverTest::~GCMDriverTest() {
} }
void GCMDriverTest::SetUp() { void GCMDriverTest::SetUp() {
GCMChannelStatusSyncer::RegisterPrefs(prefs_.registry());
io_thread_.Start(); io_thread_.Start();
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
} }
...@@ -249,8 +243,7 @@ void GCMDriverTest::CreateDriver() { ...@@ -249,8 +243,7 @@ void GCMDriverTest::CreateDriver() {
driver_ = std::make_unique<GCMDriverDesktop>( driver_ = std::make_unique<GCMDriverDesktop>(
std::unique_ptr<GCMClientFactory>(new FakeGCMClientFactory( std::unique_ptr<GCMClientFactory>(new FakeGCMClientFactory(
base::ThreadTaskRunnerHandle::Get(), io_thread_.task_runner())), base::ThreadTaskRunnerHandle::Get(), io_thread_.task_runner())),
chrome_build_info, kTestChannelStatusRequestURL, "user-agent-string", chrome_build_info, "user-agent-string", &prefs_, temp_dir_.GetPath(),
&prefs_, temp_dir_.GetPath(),
/*remove_account_mappings_with_email_key=*/true, base::DoNothing(), /*remove_account_mappings_with_email_key=*/true, base::DoNothing(),
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>( base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&test_url_loader_factory_), &test_url_loader_factory_),
...@@ -940,236 +933,6 @@ TEST_F(GCMDriverFunctionalTest, LastTokenFetchTime) { ...@@ -940,236 +933,6 @@ TEST_F(GCMDriverFunctionalTest, LastTokenFetchTime) {
EXPECT_EQ(fetch_time, driver()->GetLastTokenFetchTime()); EXPECT_EQ(fetch_time, driver()->GetLastTokenFetchTime());
} }
// Tests a single instance of GCMDriver.
class GCMChannelStatusSyncerTest : public GCMDriverTest {
public:
GCMChannelStatusSyncerTest();
~GCMChannelStatusSyncerTest() override;
// testing::Test:
void SetUp() override;
void CompleteGCMChannelStatusRequest(bool enabled, int poll_interval_seconds);
bool CompareDelaySeconds(int64_t expected_delay_seconds,
int64_t actual_delay_seconds);
GCMChannelStatusSyncer* syncer() {
return driver()->gcm_channel_status_syncer_for_testing();
}
private:
DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusSyncerTest);
};
GCMChannelStatusSyncerTest::GCMChannelStatusSyncerTest() {
}
GCMChannelStatusSyncerTest::~GCMChannelStatusSyncerTest() {
}
void GCMChannelStatusSyncerTest::SetUp() {
GCMDriverTest::SetUp();
}
void GCMChannelStatusSyncerTest::CompleteGCMChannelStatusRequest(
bool enabled, int poll_interval_seconds) {
sync_pb::ExperimentStatusResponse response_proto;
sync_pb::ExperimentsSpecifics* experiment_specifics =
response_proto.add_experiment();
experiment_specifics->mutable_gcm_channel()->set_enabled(enabled);
if (poll_interval_seconds)
response_proto.set_poll_interval_seconds(poll_interval_seconds);
syncer()->request_for_testing()->ParseResponseProto(response_proto);
}
bool GCMChannelStatusSyncerTest::CompareDelaySeconds(
int64_t expected_delay_seconds,
int64_t actual_delay_seconds) {
// Most of time, the actual delay should not be smaller than the expected
// delay.
if (actual_delay_seconds >= expected_delay_seconds)
return true;
// It is also OK that the actual delay is a bit smaller than the expected
// delay in case that the test runs slowly.
return expected_delay_seconds - actual_delay_seconds < 30;
}
TEST_F(GCMChannelStatusSyncerTest, DisableAndEnable) {
// Create GCMDriver first. By default, GCM is enabled.
CreateDriver();
EXPECT_TRUE(driver()->gcm_enabled());
EXPECT_TRUE(syncer()->gcm_enabled());
// Remove delay such that the request could be executed immediately.
syncer()->set_delay_removed_for_testing(true);
// GCM is still enabled at this point.
AddAppHandlers();
EXPECT_TRUE(driver()->gcm_enabled());
EXPECT_TRUE(syncer()->gcm_enabled());
// Wait until the GCM channel status request gets triggered.
PumpUILoop();
// Complete the request that disables the GCM.
CompleteGCMChannelStatusRequest(false, 0);
EXPECT_FALSE(driver()->gcm_enabled());
EXPECT_FALSE(syncer()->gcm_enabled());
EXPECT_FALSE(driver()->IsStarted());
// Wait until next GCM channel status request gets triggered.
PumpUILoop();
// Complete the request that enables the GCM.
CompleteGCMChannelStatusRequest(true, 0);
EXPECT_TRUE(driver()->gcm_enabled());
EXPECT_TRUE(syncer()->gcm_enabled());
}
// This test is flaky, see https://crbug.com/1010462
TEST_F(GCMChannelStatusSyncerTest, DISABLED_DisableRestartAndEnable) {
// Create GCMDriver first. By default, GCM is enabled.
CreateDriver();
EXPECT_TRUE(driver()->gcm_enabled());
EXPECT_TRUE(syncer()->gcm_enabled());
// Remove delay such that the request could be executed immediately.
syncer()->set_delay_removed_for_testing(true);
// GCM is still enabled at this point.
AddAppHandlers();
EXPECT_TRUE(driver()->gcm_enabled());
EXPECT_TRUE(syncer()->gcm_enabled());
// Wait until the GCM channel status request gets triggered.
PumpUILoop();
// Complete the request that disables the GCM.
CompleteGCMChannelStatusRequest(false, 0);
EXPECT_FALSE(driver()->gcm_enabled());
EXPECT_FALSE(syncer()->gcm_enabled());
// Simulate browser start by recreating GCMDriver.
ShutdownDriver();
CreateDriver();
// Remove delay such that the request could be executed immediately.
syncer()->set_delay_removed_for_testing(true);
// GCM is still disabled.
EXPECT_FALSE(driver()->gcm_enabled());
EXPECT_FALSE(syncer()->gcm_enabled());
AddAppHandlers();
EXPECT_FALSE(driver()->gcm_enabled());
EXPECT_FALSE(syncer()->gcm_enabled());
// Wait until the GCM channel status request gets triggered.
PumpUILoop();
// Complete the request that re-enables the GCM.
CompleteGCMChannelStatusRequest(true, 0);
EXPECT_TRUE(driver()->gcm_enabled());
EXPECT_TRUE(syncer()->gcm_enabled());
}
TEST_F(GCMChannelStatusSyncerTest, FirstTimePolling) {
// Start GCM.
CreateDriver();
AddAppHandlers();
// The 1st request should be triggered shortly without jittering.
EXPECT_EQ(GCMChannelStatusSyncer::first_time_delay_seconds(),
syncer()->current_request_delay_interval().InSeconds());
}
TEST_F(GCMChannelStatusSyncerTest, SubsequentPollingWithDefaultInterval) {
// Create GCMDriver first. GCM is not started.
CreateDriver();
// Remove delay such that the request could be executed immediately.
syncer()->set_delay_removed_for_testing(true);
// Now GCM is started.
AddAppHandlers();
// Wait until the GCM channel status request gets triggered.
PumpUILoop();
// Keep delay such that we can find out the computed delay time.
syncer()->set_delay_removed_for_testing(false);
// Complete the request. The default interval is intact.
CompleteGCMChannelStatusRequest(true, 0);
// The next request should be scheduled at the expected default interval.
int64_t actual_delay_seconds =
syncer()->current_request_delay_interval().InSeconds();
int64_t expected_delay_seconds =
GCMChannelStatusRequest::default_poll_interval_seconds();
EXPECT_TRUE(CompareDelaySeconds(expected_delay_seconds, actual_delay_seconds))
<< "expected delay: " << expected_delay_seconds
<< " actual delay: " << actual_delay_seconds;
// Simulate browser start by recreating GCMDriver.
ShutdownDriver();
CreateDriver();
AddAppHandlers();
// After start-up, the request should still be scheduled at the expected
// default interval.
actual_delay_seconds =
syncer()->current_request_delay_interval().InSeconds();
EXPECT_TRUE(CompareDelaySeconds(expected_delay_seconds, actual_delay_seconds))
<< "expected delay: " << expected_delay_seconds
<< " actual delay: " << actual_delay_seconds;
}
TEST_F(GCMChannelStatusSyncerTest, SubsequentPollingWithUpdatedInterval) {
// Create GCMDriver first. GCM is not started.
CreateDriver();
// Remove delay such that the request could be executed immediately.
syncer()->set_delay_removed_for_testing(true);
// Now GCM is started.
AddAppHandlers();
// Wait until the GCM channel status request gets triggered.
PumpUILoop();
// Keep delay such that we can find out the computed delay time.
syncer()->set_delay_removed_for_testing(false);
// Complete the request. The interval is being changed.
int new_poll_interval_seconds =
GCMChannelStatusRequest::default_poll_interval_seconds() * 2;
CompleteGCMChannelStatusRequest(true, new_poll_interval_seconds);
// The next request should be scheduled at the expected updated interval.
int64_t actual_delay_seconds =
syncer()->current_request_delay_interval().InSeconds();
int64_t expected_delay_seconds = new_poll_interval_seconds;
EXPECT_TRUE(CompareDelaySeconds(expected_delay_seconds, actual_delay_seconds))
<< "expected delay: " << expected_delay_seconds
<< " actual delay: " << actual_delay_seconds;
// Simulate browser start by recreating GCMDriver.
ShutdownDriver();
CreateDriver();
AddAppHandlers();
// After start-up, the request should still be scheduled at the expected
// updated interval.
actual_delay_seconds =
syncer()->current_request_delay_interval().InSeconds();
EXPECT_TRUE(CompareDelaySeconds(expected_delay_seconds, actual_delay_seconds))
<< "expected delay: " << expected_delay_seconds
<< " actual delay: " << actual_delay_seconds;
}
class GCMDriverInstanceIDTest : public GCMDriverTest { class GCMDriverInstanceIDTest : public GCMDriverTest {
public: public:
GCMDriverInstanceIDTest(); GCMDriverInstanceIDTest();
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include "components/gcm_driver/crypto/gcm_decryption_result.h" #include "components/gcm_driver/crypto/gcm_decryption_result.h"
#include "components/gcm_driver/crypto/gcm_encryption_provider.h" #include "components/gcm_driver/crypto/gcm_encryption_provider.h"
#include "components/gcm_driver/fake_gcm_client_factory.h" #include "components/gcm_driver/fake_gcm_client_factory.h"
#include "components/gcm_driver/gcm_channel_status_request.h"
#include "components/gcm_driver/gcm_channel_status_syncer.h"
#include "components/gcm_driver/gcm_client_factory.h" #include "components/gcm_driver/gcm_client_factory.h"
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h" #include "components/prefs/testing_pref_service.h"
...@@ -39,7 +37,6 @@ namespace gcm { ...@@ -39,7 +37,6 @@ namespace gcm {
namespace { namespace {
const char kTestChannelStatusRequestURL[] = "http://channel.status.request.com";
const char kTestAppID1[] = "TestApp1"; const char kTestAppID1[] = "TestApp1";
// PKCS #8 encoded P-256 private key. // PKCS #8 encoded P-256 private key.
...@@ -133,7 +130,6 @@ GCMDriverBaseTest::GCMDriverBaseTest() : io_thread_("IOThread") {} ...@@ -133,7 +130,6 @@ GCMDriverBaseTest::GCMDriverBaseTest() : io_thread_("IOThread") {}
GCMDriverBaseTest::~GCMDriverBaseTest() = default; GCMDriverBaseTest::~GCMDriverBaseTest() = default;
void GCMDriverBaseTest::SetUp() { void GCMDriverBaseTest::SetUp() {
GCMChannelStatusSyncer::RegisterPrefs(prefs_.registry());
io_thread_.Start(); io_thread_.Start();
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
...@@ -170,8 +166,7 @@ void GCMDriverBaseTest::CreateDriver() { ...@@ -170,8 +166,7 @@ void GCMDriverBaseTest::CreateDriver() {
driver_ = std::make_unique<GCMDriverDesktop>( driver_ = std::make_unique<GCMDriverDesktop>(
std::make_unique<FakeGCMClientFactory>( std::make_unique<FakeGCMClientFactory>(
base::ThreadTaskRunnerHandle::Get(), io_thread_.task_runner()), base::ThreadTaskRunnerHandle::Get(), io_thread_.task_runner()),
chrome_build_info, kTestChannelStatusRequestURL, "user-agent-string", chrome_build_info, "user-agent-string", &prefs_, temp_dir_.GetPath(),
&prefs_, temp_dir_.GetPath(),
/*remove_account_mappings_with_email_key=*/true, base::DoNothing(), /*remove_account_mappings_with_email_key=*/true, base::DoNothing(),
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>( base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&test_url_loader_factory_), &test_url_loader_factory_),
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "components/gcm_driver/account_tracker.h" #include "components/gcm_driver/account_tracker.h"
#include "components/gcm_driver/gcm_account_tracker.h" #include "components/gcm_driver/gcm_account_tracker.h"
#include "components/gcm_driver/gcm_channel_status_syncer.h"
#include "components/gcm_driver/gcm_client_factory.h" #include "components/gcm_driver/gcm_client_factory.h"
#include "components/gcm_driver/gcm_desktop_utils.h" #include "components/gcm_driver/gcm_desktop_utils.h"
#include "components/gcm_driver/gcm_driver_desktop.h" #include "components/gcm_driver/gcm_driver_desktop.h"
...@@ -124,11 +123,7 @@ void GCMProfileService::IdentityObserver::StartAccountTracker( ...@@ -124,11 +123,7 @@ void GCMProfileService::IdentityObserver::StartAccountTracker(
// static // static
bool GCMProfileService::IsGCMEnabled(PrefService* prefs) { bool GCMProfileService::IsGCMEnabled(PrefService* prefs) {
#if BUILDFLAG(USE_GCM_FROM_PLATFORM)
return true; return true;
#else
return prefs->GetBoolean(gcm::prefs::kGCMChannelStatus);
#endif // BUILDFLAG(USE_GCM_FROM_PLATFORM)
} }
#if BUILDFLAG(USE_GCM_FROM_PLATFORM) #if BUILDFLAG(USE_GCM_FROM_PLATFORM)
......
...@@ -17,7 +17,6 @@ sync_protocol_bases = [ ...@@ -17,7 +17,6 @@ sync_protocol_bases = [
"dictionary_specifics", "dictionary_specifics",
"encryption", "encryption",
"entity_metadata", "entity_metadata",
"experiment_status",
"experiments_specifics", "experiments_specifics",
"extension_setting_specifics", "extension_setting_specifics",
"extension_specifics", "extension_specifics",
......
...@@ -139,7 +139,9 @@ message EntitySpecifics { ...@@ -139,7 +139,9 @@ message EntitySpecifics {
SyncedNotificationAppInfoSpecifics synced_notification_app_info = 235816 SyncedNotificationAppInfoSpecifics synced_notification_app_info = 235816
[deprecated = true]; [deprecated = true];
DeviceInfoSpecifics device_info = 154522; DeviceInfoSpecifics device_info = 154522;
ExperimentsSpecifics experiments = 161496; // TODO(crbug.com/1009361): |experiments| isn't used by the client anymore,
// but the server still needs it for now.
ExperimentsSpecifics experiments = 161496 [deprecated = true];
PriorityPreferenceSpecifics priority_preference = 163425; PriorityPreferenceSpecifics priority_preference = 163425;
DictionarySpecifics dictionary = 170540; DictionarySpecifics dictionary = 170540;
FaviconTrackingSpecifics favicon_tracking = 181534; FaviconTrackingSpecifics favicon_tracking = 181534;
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/dom_distiller/core/distilled_page_prefs.h" #include "components/dom_distiller/core/distilled_page_prefs.h"
#include "components/flags_ui/pref_service_flags_storage.h" #include "components/flags_ui/pref_service_flags_storage.h"
#include "components/gcm_driver/gcm_channel_status_syncer.h"
#import "components/handoff/handoff_manager.h" #import "components/handoff/handoff_manager.h"
#include "components/history/core/common/pref_names.h" #include "components/history/core/common/pref_names.h"
#include "components/invalidation/impl/invalidator_registrar_with_memory.h" #include "components/invalidation/impl/invalidator_registrar_with_memory.h"
...@@ -76,12 +75,16 @@ const char kLastPromptedGoogleURL[] = "browser.last_prompted_google_url"; ...@@ -76,12 +75,16 @@ const char kLastPromptedGoogleURL[] = "browser.last_prompted_google_url";
// Deprecated 9/2019 // Deprecated 9/2019
const char kGoogleServicesUsername[] = "google.services.username"; const char kGoogleServicesUsername[] = "google.services.username";
const char kGoogleServicesUserAccountId[] = "google.services.user_account_id"; const char kGoogleServicesUserAccountId[] = "google.services.user_account_id";
// Deprecated 1/2020
const char kGCMChannelStatus[] = "gcm.channel_status";
const char kGCMChannelPollIntervalSeconds[] = "gcm.poll_interval";
const char kGCMChannelLastCheckTime[] = "gcm.check_time";
} }
void RegisterLocalStatePrefs(PrefRegistrySimple* registry) { void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
BrowserStateInfoCache::RegisterPrefs(registry); BrowserStateInfoCache::RegisterPrefs(registry);
flags_ui::PrefServiceFlagsStorage::RegisterPrefs(registry); flags_ui::PrefServiceFlagsStorage::RegisterPrefs(registry);
gcm::GCMChannelStatusSyncer::RegisterPrefs(registry);
signin::IdentityManager::RegisterLocalStatePrefs(registry); signin::IdentityManager::RegisterLocalStatePrefs(registry);
IOSChromeMetricsServiceClient::RegisterPrefs(registry); IOSChromeMetricsServiceClient::RegisterPrefs(registry);
network_time::NetworkTimeTracker::RegisterPrefs(registry); network_time::NetworkTimeTracker::RegisterPrefs(registry);
...@@ -113,13 +116,16 @@ void RegisterLocalStatePrefs(PrefRegistrySimple* registry) { ...@@ -113,13 +116,16 @@ void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
if (!base::FeatureList::IsEnabled(kUmaCellular)) { if (!base::FeatureList::IsEnabled(kUmaCellular)) {
registry->RegisterBooleanPref(prefs::kMetricsReportingWifiOnly, true); registry->RegisterBooleanPref(prefs::kMetricsReportingWifiOnly, true);
} }
registry->RegisterBooleanPref(kGCMChannelStatus, true);
registry->RegisterIntegerPref(kGCMChannelPollIntervalSeconds, 0);
registry->RegisterInt64Pref(kGCMChannelLastCheckTime, 0);
} }
void RegisterBrowserStatePrefs(user_prefs::PrefRegistrySyncable* registry) { void RegisterBrowserStatePrefs(user_prefs::PrefRegistrySyncable* registry) {
autofill::prefs::RegisterProfilePrefs(registry); autofill::prefs::RegisterProfilePrefs(registry);
dom_distiller::DistilledPagePrefs::RegisterProfilePrefs(registry); dom_distiller::DistilledPagePrefs::RegisterProfilePrefs(registry);
FirstRun::RegisterProfilePrefs(registry); FirstRun::RegisterProfilePrefs(registry);
gcm::GCMChannelStatusSyncer::RegisterProfilePrefs(registry);
HostContentSettingsMap::RegisterProfilePrefs(registry); HostContentSettingsMap::RegisterProfilePrefs(registry);
language::LanguagePrefs::RegisterProfilePrefs(registry); language::LanguagePrefs::RegisterProfilePrefs(registry);
FontSizeTabHelper::RegisterBrowserStatePrefs(registry); FontSizeTabHelper::RegisterBrowserStatePrefs(registry);
...@@ -188,10 +194,18 @@ void RegisterBrowserStatePrefs(user_prefs::PrefRegistrySyncable* registry) { ...@@ -188,10 +194,18 @@ void RegisterBrowserStatePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterStringPref(kLastPromptedGoogleURL, std::string()); registry->RegisterStringPref(kLastPromptedGoogleURL, std::string());
registry->RegisterStringPref(kGoogleServicesUsername, std::string()); registry->RegisterStringPref(kGoogleServicesUsername, std::string());
registry->RegisterStringPref(kGoogleServicesUserAccountId, std::string()); registry->RegisterStringPref(kGoogleServicesUserAccountId, std::string());
registry->RegisterBooleanPref(kGCMChannelStatus, true);
registry->RegisterIntegerPref(kGCMChannelPollIntervalSeconds, 0);
registry->RegisterInt64Pref(kGCMChannelLastCheckTime, 0);
} }
// This method should be periodically pruned of year+ old migrations. // This method should be periodically pruned of year+ old migrations.
void MigrateObsoleteLocalStatePrefs(PrefService* prefs) { void MigrateObsoleteLocalStatePrefs(PrefService* prefs) {
// Added 1/2020.
prefs->ClearPref(kGCMChannelStatus);
prefs->ClearPref(kGCMChannelPollIntervalSeconds);
prefs->ClearPref(kGCMChannelLastCheckTime);
} }
// This method should be periodically pruned of year+ old migrations. // This method should be periodically pruned of year+ old migrations.
...@@ -223,4 +237,9 @@ void MigrateObsoleteBrowserStatePrefs(PrefService* prefs) { ...@@ -223,4 +237,9 @@ void MigrateObsoleteBrowserStatePrefs(PrefService* prefs) {
// Added 10/2019. // Added 10/2019.
syncer::DeviceInfoPrefs::MigrateRecentLocalCacheGuidsPref(prefs); syncer::DeviceInfoPrefs::MigrateRecentLocalCacheGuidsPref(prefs);
// Added 1/2020.
prefs->ClearPref(kGCMChannelStatus);
prefs->ClearPref(kGCMChannelPollIntervalSeconds);
prefs->ClearPref(kGCMChannelLastCheckTime);
} }
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "components/autofill/core/common/autofill_prefs.h" #include "components/autofill/core/common/autofill_prefs.h"
#include "components/gcm_driver/gcm_channel_status_syncer.h"
#include "components/history/core/common/pref_names.h" #include "components/history/core/common/pref_names.h"
#include "components/keyed_service/ios/browser_state_dependency_manager.h" #include "components/keyed_service/ios/browser_state_dependency_manager.h"
#include "components/language/core/browser/language_prefs.h" #include "components/language/core/browser/language_prefs.h"
...@@ -178,7 +177,6 @@ void WebViewBrowserState::RegisterPrefs( ...@@ -178,7 +177,6 @@ void WebViewBrowserState::RegisterPrefs(
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL) #endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_SYNC) #if BUILDFLAG(IOS_WEB_VIEW_ENABLE_SYNC)
gcm::GCMChannelStatusSyncer::RegisterProfilePrefs(pref_registry);
sync_sessions::SessionSyncPrefs::RegisterProfilePrefs(pref_registry); sync_sessions::SessionSyncPrefs::RegisterProfilePrefs(pref_registry);
syncer::SyncPrefs::RegisterProfilePrefs(pref_registry); syncer::SyncPrefs::RegisterProfilePrefs(pref_registry);
syncer::DeviceInfoPrefs::RegisterProfilePrefs(pref_registry); syncer::DeviceInfoPrefs::RegisterProfilePrefs(pref_registry);
......
...@@ -120,7 +120,7 @@ Refer to README.md for content description and update process. ...@@ -120,7 +120,7 @@ Refer to README.md for content description and update process.
<item id="gaia_oauth_client_get_user_info" hash_code="83476155" type="0" content_hash_code="35159007" os_list="linux,windows" file_path="google_apis/gaia/gaia_oauth_client.cc"/> <item id="gaia_oauth_client_get_user_info" hash_code="83476155" type="0" content_hash_code="35159007" os_list="linux,windows" file_path="google_apis/gaia/gaia_oauth_client.cc"/>
<item id="gaia_oauth_client_refresh_token" hash_code="82462683" type="0" content_hash_code="22305252" os_list="linux,windows" file_path="google_apis/gaia/gaia_oauth_client.cc"/> <item id="gaia_oauth_client_refresh_token" hash_code="82462683" type="0" content_hash_code="22305252" os_list="linux,windows" file_path="google_apis/gaia/gaia_oauth_client.cc"/>
<item id="gcd_rest_client" hash_code="105985951" type="0" deprecated="2018-10-17" content_hash_code="70710803" file_path="remoting/host/gcd_rest_client.cc"/> <item id="gcd_rest_client" hash_code="105985951" type="0" deprecated="2018-10-17" content_hash_code="70710803" file_path="remoting/host/gcd_rest_client.cc"/>
<item id="gcm_channel_status_request" hash_code="18300705" type="0" content_hash_code="53862393" os_list="linux,windows" file_path="components/gcm_driver/gcm_channel_status_request.cc"/> <item id="gcm_channel_status_request" hash_code="18300705" type="0" deprecated="2020-01-24" content_hash_code="53862393" file_path=""/>
<item id="gcm_checkin" hash_code="65957842" type="0" content_hash_code="98259579" os_list="linux,windows" file_path="google_apis/gcm/engine/checkin_request.cc"/> <item id="gcm_checkin" hash_code="65957842" type="0" content_hash_code="98259579" os_list="linux,windows" file_path="google_apis/gcm/engine/checkin_request.cc"/>
<item id="gcm_connection_factory" hash_code="29057242" type="0" content_hash_code="75279835" os_list="linux,windows" file_path="google_apis/gcm/engine/connection_factory_impl.cc"/> <item id="gcm_connection_factory" hash_code="29057242" type="0" content_hash_code="75279835" os_list="linux,windows" file_path="google_apis/gcm/engine/connection_factory_impl.cc"/>
<item id="gcm_registration" hash_code="61656965" type="0" content_hash_code="113670632" os_list="linux,windows" file_path="google_apis/gcm/engine/registration_request.cc"/> <item id="gcm_registration" hash_code="61656965" type="0" content_hash_code="113670632" os_list="linux,windows" file_path="google_apis/gcm/engine/registration_request.cc"/>
......
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