Commit 6a7e9d36 authored by Mark Pilgrim's avatar Mark Pilgrim Committed by Commit Bot

Migrate GCMNetworkChannel to SimpleURLLoader

TBR=bartfab@chromium.org

Bug: 844936
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;luci.chromium.try:linux_mojo;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I573698e0994b6dc6e70f0d17e6dcbbb83aa1a142
Reviewed-on: https://chromium-review.googlesource.com/1102725
Commit-Queue: Mark Pilgrim <pilgrim@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571533}
parent 7da098a1
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "chrome/browser/chromeos/settings/device_identity_provider.h" #include "chrome/browser/chromeos/settings/device_identity_provider.h"
#include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h" #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h"
#include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_content_client.h" #include "chrome/common/chrome_content_client.h"
...@@ -33,6 +34,7 @@ ...@@ -33,6 +34,7 @@
#include "components/user_manager/user.h" #include "components/user_manager/user.h"
#include "content/public/browser/notification_details.h" #include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace policy { namespace policy {
...@@ -300,6 +302,12 @@ AffiliatedInvalidationServiceProviderImpl::FindConnectedInvalidationService() { ...@@ -300,6 +302,12 @@ AffiliatedInvalidationServiceProviderImpl::FindConnectedInvalidationService() {
} }
if (!device_invalidation_service_) { if (!device_invalidation_service_) {
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory;
if (g_browser_process->system_network_context_manager()) {
// system_network_context_manager() can be null during unit tests.
url_loader_factory = g_browser_process->system_network_context_manager()
->GetSharedURLLoaderFactory();
}
// If no other connected invalidation service was found and no device-global // If no other connected invalidation service was found and no device-global
// invalidation service exists, create one. // invalidation service exists, create one.
device_invalidation_service_.reset( device_invalidation_service_.reset(
...@@ -310,7 +318,8 @@ AffiliatedInvalidationServiceProviderImpl::FindConnectedInvalidationService() { ...@@ -310,7 +318,8 @@ AffiliatedInvalidationServiceProviderImpl::FindConnectedInvalidationService() {
std::unique_ptr<invalidation::TiclSettingsProvider>( std::unique_ptr<invalidation::TiclSettingsProvider>(
new TiclDeviceSettingsProvider), new TiclDeviceSettingsProvider),
g_browser_process->gcm_driver(), g_browser_process->gcm_driver(),
g_browser_process->system_request_context())); g_browser_process->system_request_context(),
std::move(url_loader_factory)));
device_invalidation_service_->Init( device_invalidation_service_->Init(
std::unique_ptr<syncer::InvalidationStateTracker>( std::unique_ptr<syncer::InvalidationStateTracker>(
new invalidation::InvalidatorStorage( new invalidation::InvalidatorStorage(
......
...@@ -29,7 +29,9 @@ ...@@ -29,7 +29,9 @@
#include "components/prefs/pref_registry.h" #include "components/prefs/pref_registry.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h" #include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h" #include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/storage_partition.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "components/invalidation/impl/invalidation_service_android.h" #include "components/invalidation/impl/invalidation_service_android.h"
...@@ -127,7 +129,9 @@ KeyedService* ProfileInvalidationProviderFactory::BuildServiceInstanceFor( ...@@ -127,7 +129,9 @@ KeyedService* ProfileInvalidationProviderFactory::BuildServiceInstanceFor(
std::unique_ptr<TiclSettingsProvider>( std::unique_ptr<TiclSettingsProvider>(
new TiclProfileSettingsProvider(profile->GetPrefs())), new TiclProfileSettingsProvider(profile->GetPrefs())),
gcm::GCMProfileServiceFactory::GetForProfile(profile)->driver(), gcm::GCMProfileServiceFactory::GetForProfile(profile)->driver(),
profile->GetRequestContext())); profile->GetRequestContext(),
content::BrowserContext::GetDefaultStoragePartition(profile)
->GetURLLoaderFactoryForBrowserProcess()));
service->Init(std::unique_ptr<syncer::InvalidationStateTracker>( service->Init(std::unique_ptr<syncer::InvalidationStateTracker>(
new InvalidatorStorage(profile->GetPrefs()))); new InvalidatorStorage(profile->GetPrefs())));
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "mojo/public/cpp/bindings/associated_interface_ptr.h" #include "mojo/public/cpp/bindings/associated_interface_ptr.h"
#include "net/net_buildflags.h" #include "net/net_buildflags.h"
#include "services/network/network_service.h" #include "services/network/network_service.h"
#include "services/network/public/cpp/cross_thread_shared_url_loader_factory_info.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -220,9 +221,8 @@ class SystemNetworkContextManager::URLLoaderFactoryForSystem ...@@ -220,9 +221,8 @@ class SystemNetworkContextManager::URLLoaderFactoryForSystem
// SharedURLLoaderFactory implementation: // SharedURLLoaderFactory implementation:
std::unique_ptr<network::SharedURLLoaderFactoryInfo> Clone() override { std::unique_ptr<network::SharedURLLoaderFactoryInfo> Clone() override {
NOTREACHED() << "This isn't supported. SharedURLLoaderFactory can only be" return std::make_unique<network::CrossThreadSharedURLLoaderFactoryInfo>(
" used on the UI thread."; this);
return nullptr;
} }
void Shutdown() { manager_ = nullptr; } void Shutdown() { manager_ = nullptr; }
......
...@@ -22,8 +22,9 @@ ...@@ -22,8 +22,9 @@
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
#include "net/http/http_status_code.h" #include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation.h" #include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/url_request/url_fetcher.h" #include "services/network/public/cpp/resource_request.h"
#include "net/url_request/url_request_status.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
// channel_common.proto defines ANDROID constant that conflicts with Android // channel_common.proto defines ANDROID constant that conflicts with Android
...@@ -113,9 +114,9 @@ void RecordOutgoingMessageStatus(OutgoingMessageStatus status) { ...@@ -113,9 +114,9 @@ void RecordOutgoingMessageStatus(OutgoingMessageStatus status) {
} // namespace } // namespace
GCMNetworkChannel::GCMNetworkChannel( GCMNetworkChannel::GCMNetworkChannel(
scoped_refptr<net::URLRequestContextGetter> request_context_getter, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
std::unique_ptr<GCMNetworkChannelDelegate> delegate) std::unique_ptr<GCMNetworkChannelDelegate> delegate)
: request_context_getter_(request_context_getter), : url_loader_factory_(std::move(url_loader_factory)),
delegate_(std::move(delegate)), delegate_(std::move(delegate)),
register_backoff_entry_(new net::BackoffEntry(&kRegisterBackoffPolicy)), register_backoff_entry_(new net::BackoffEntry(&kRegisterBackoffPolicy)),
gcm_channel_online_(false), gcm_channel_online_(false),
...@@ -256,46 +257,55 @@ void GCMNetworkChannel::OnGetTokenComplete( ...@@ -256,46 +257,55 @@ void GCMNetworkChannel::OnGetTokenComplete(
"features that depend on it. It makes sense to control top level " "features that depend on it. It makes sense to control top level "
"features that use InvalidationService." "features that use InvalidationService."
})"); })");
fetcher_ =
net::URLFetcher::Create(BuildUrl(registration_id_), net::URLFetcher::POST, auto resource_request = std::make_unique<network::ResourceRequest>();
this, traffic_annotation); resource_request->url = BuildUrl(registration_id_);
data_use_measurement::DataUseUserData::AttachToFetcher( resource_request->load_flags =
fetcher_.get(), data_use_measurement::DataUseUserData::INVALIDATION); net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES;
fetcher_->SetRequestContext(request_context_getter_.get()); resource_request->method = "POST";
fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | resource_request->headers.SetHeader(net::HttpRequestHeaders::kAuthorization,
net::LOAD_DO_NOT_SAVE_COOKIES); "Bearer " + access_token_);
const std::string auth_header("Authorization: Bearer " + access_token_);
fetcher_->AddExtraRequestHeader(auth_header);
if (!echo_token_.empty()) { if (!echo_token_.empty()) {
const std::string echo_header("echo-token: " + echo_token_); resource_request->headers.SetHeader("echo-token", echo_token_);
fetcher_->AddExtraRequestHeader(echo_header);
} }
fetcher_->SetUploadData("application/x-protobuffer", cached_message_); simple_url_loader_ = network::SimpleURLLoader::Create(
fetcher_->Start(); std::move(resource_request), traffic_annotation);
simple_url_loader_->AttachStringForUpload(cached_message_,
"application/x-protobuffer");
// TODO(https://crbug.com/808498): Re-add data use measurement once
// SimpleURLLoader supports it.
// ID=data_use_measurement::DataUseUserData::INVALIDATION
simple_url_loader_->DownloadToStringOfUnboundedSizeUntilCrashAndDie(
url_loader_factory_.get(),
base::BindOnce(&GCMNetworkChannel::OnSimpleLoaderComplete,
base::Unretained(this)));
// Clear message to prevent accidentally resending it in the future. // Clear message to prevent accidentally resending it in the future.
cached_message_.clear(); cached_message_.clear();
} }
void GCMNetworkChannel::OnURLFetchComplete(const net::URLFetcher* source) { void GCMNetworkChannel::OnSimpleLoaderComplete(
std::unique_ptr<std::string> response_body) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(fetcher_.get(), source);
// Free fetcher at the end of function.
std::unique_ptr<net::URLFetcher> fetcher = std::move(fetcher_);
net::URLRequestStatus status = fetcher->GetStatus(); int net_error = simple_url_loader_->NetError();
bool is_success = (net_error == net::OK);
int response_code = -1;
if (simple_url_loader_->ResponseInfo() &&
simple_url_loader_->ResponseInfo()->headers) {
response_code =
simple_url_loader_->ResponseInfo()->headers->response_code();
}
simple_url_loader_.reset();
diagnostic_info_.last_post_response_code_ = diagnostic_info_.last_post_response_code_ =
status.is_success() ? source->GetResponseCode() : status.error(); (response_code / 100 != 2 || is_success) ? response_code : net_error;
if (status.is_success() && if (response_code == net::HTTP_UNAUTHORIZED) {
fetcher->GetResponseCode() == net::HTTP_UNAUTHORIZED) { DVLOG(1) << "SimpleURLLoader failure: HTTP_UNAUTHORIZED";
DVLOG(1) << "URLFetcher failure: HTTP_UNAUTHORIZED";
delegate_->InvalidateToken(access_token_); delegate_->InvalidateToken(access_token_);
} }
if (!status.is_success() || if (!response_body) {
(fetcher->GetResponseCode() != net::HTTP_OK && DVLOG(1) << "SimpleURLLoader failure";
fetcher->GetResponseCode() != net::HTTP_NO_CONTENT)) {
DVLOG(1) << "URLFetcher failure";
RecordOutgoingMessageStatus(POST_FAILURE); RecordOutgoingMessageStatus(POST_FAILURE);
// POST failed. Notify that http channel doesn't work. // POST failed. Notify that http channel doesn't work.
UpdateHttpChannelState(false); UpdateHttpChannelState(false);
...@@ -305,7 +315,7 @@ void GCMNetworkChannel::OnURLFetchComplete(const net::URLFetcher* source) { ...@@ -305,7 +315,7 @@ void GCMNetworkChannel::OnURLFetchComplete(const net::URLFetcher* source) {
RecordOutgoingMessageStatus(OUTGOING_MESSAGE_SUCCESS); RecordOutgoingMessageStatus(OUTGOING_MESSAGE_SUCCESS);
// Successfully sent message. Http channel works. // Successfully sent message. Http channel works.
UpdateHttpChannelState(true); UpdateHttpChannelState(true);
DVLOG(2) << "URLFetcher success"; DVLOG(2) << "SimpleURLLoader success";
} }
void GCMNetworkChannel::OnIncomingMessage(const std::string& message, void GCMNetworkChannel::OnIncomingMessage(const std::string& message,
......
...@@ -16,11 +16,15 @@ ...@@ -16,11 +16,15 @@
#include "components/invalidation/public/invalidation_export.h" #include "components/invalidation/public/invalidation_export.h"
#include "net/base/backoff_entry.h" #include "net/base/backoff_entry.h"
#include "net/base/network_change_notifier.h" #include "net/base/network_change_notifier.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "url/gurl.h" #include "url/gurl.h"
class GoogleServiceAuthError; class GoogleServiceAuthError;
namespace network {
class SharedURLLoaderFactory;
class SimpleURLLoader;
} // namespace network
namespace syncer { namespace syncer {
class GCMNetworkChannel; class GCMNetworkChannel;
...@@ -48,11 +52,10 @@ struct GCMNetworkChannelDiagnostic { ...@@ -48,11 +52,10 @@ struct GCMNetworkChannelDiagnostic {
// messages through GCMService. // messages through GCMService.
class INVALIDATION_EXPORT GCMNetworkChannel class INVALIDATION_EXPORT GCMNetworkChannel
: public SyncNetworkChannel, : public SyncNetworkChannel,
public net::URLFetcherDelegate,
public net::NetworkChangeNotifier::NetworkChangeObserver { public net::NetworkChangeNotifier::NetworkChangeObserver {
public: public:
GCMNetworkChannel( GCMNetworkChannel(
scoped_refptr<net::URLRequestContextGetter> request_context_getter, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
std::unique_ptr<GCMNetworkChannelDelegate> delegate); std::unique_ptr<GCMNetworkChannelDelegate> delegate);
~GCMNetworkChannel() override; ~GCMNetworkChannel() override;
...@@ -69,9 +72,6 @@ class INVALIDATION_EXPORT GCMNetworkChannel ...@@ -69,9 +72,6 @@ class INVALIDATION_EXPORT GCMNetworkChannel
void RequestDetailedStatus( void RequestDetailedStatus(
base::Callback<void(const base::DictionaryValue&)> callback) override; base::Callback<void(const base::DictionaryValue&)> callback) override;
// URLFetcherDelegate implementation.
void OnURLFetchComplete(const net::URLFetcher* source) override;
// NetworkChangeObserver implementation. // NetworkChangeObserver implementation.
void OnNetworkChanged( void OnNetworkChanged(
net::NetworkChangeNotifier::ConnectionType connection_type) override; net::NetworkChangeNotifier::ConnectionType connection_type) override;
...@@ -97,7 +97,10 @@ class INVALIDATION_EXPORT GCMNetworkChannel ...@@ -97,7 +97,10 @@ class INVALIDATION_EXPORT GCMNetworkChannel
void UpdateGcmChannelState(bool online); void UpdateGcmChannelState(bool online);
void UpdateHttpChannelState(bool online); void UpdateHttpChannelState(bool online);
scoped_refptr<net::URLRequestContextGetter> request_context_getter_; // Callback is called when |simple_url_loader_| completes a network request.
void OnSimpleLoaderComplete(std::unique_ptr<std::string> response_body);
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
std::unique_ptr<GCMNetworkChannelDelegate> delegate_; std::unique_ptr<GCMNetworkChannelDelegate> delegate_;
// Message is saved until all conditions are met: there is valid // Message is saved until all conditions are met: there is valid
...@@ -113,7 +116,7 @@ class INVALIDATION_EXPORT GCMNetworkChannel ...@@ -113,7 +116,7 @@ class INVALIDATION_EXPORT GCMNetworkChannel
std::string registration_id_; std::string registration_id_;
std::unique_ptr<net::BackoffEntry> register_backoff_entry_; std::unique_ptr<net::BackoffEntry> register_backoff_entry_;
std::unique_ptr<net::URLFetcher> fetcher_; std::unique_ptr<network::SimpleURLLoader> simple_url_loader_;
// cacheinvalidation client receives echo_token with incoming message from // cacheinvalidation client receives echo_token with incoming message from
// GCM and shuld include it in headers with outgoing message over http. // GCM and shuld include it in headers with outgoing message over http.
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "components/invalidation/public/invalidation_handler.h" #include "components/invalidation/public/invalidation_handler.h"
#include "components/invalidation/public/object_id_invalidation_map.h" #include "components/invalidation/public/object_id_invalidation_map.h"
#include "jingle/notifier/listener/push_client.h" #include "jingle/notifier/listener/push_client.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace syncer { namespace syncer {
...@@ -324,10 +325,11 @@ NetworkChannelCreator ...@@ -324,10 +325,11 @@ NetworkChannelCreator
} }
NetworkChannelCreator NonBlockingInvalidator::MakeGCMNetworkChannelCreator( NetworkChannelCreator NonBlockingInvalidator::MakeGCMNetworkChannelCreator(
scoped_refptr<net::URLRequestContextGetter> request_context_getter, std::unique_ptr<network::SharedURLLoaderFactoryInfo>
url_loader_factory_info,
std::unique_ptr<GCMNetworkChannelDelegate> delegate) { std::unique_ptr<GCMNetworkChannelDelegate> delegate) {
return base::Bind(&SyncNetworkChannel::CreateGCMNetworkChannel, return base::Bind(&SyncNetworkChannel::CreateGCMNetworkChannel,
request_context_getter, base::Passed(&url_loader_factory_info),
base::Passed(&delegate)); base::Passed(&delegate));
} }
......
...@@ -28,6 +28,10 @@ namespace base { ...@@ -28,6 +28,10 @@ namespace base {
class SingleThreadTaskRunner; class SingleThreadTaskRunner;
} // namespace base } // namespace base
namespace network {
class SharedURLLoaderFactoryInfo;
} // namespace network
namespace syncer { namespace syncer {
class SyncNetworkChannel; class SyncNetworkChannel;
class GCMNetworkChannelDelegate; class GCMNetworkChannelDelegate;
...@@ -72,7 +76,8 @@ class INVALIDATION_EXPORT NonBlockingInvalidator ...@@ -72,7 +76,8 @@ class INVALIDATION_EXPORT NonBlockingInvalidator
static NetworkChannelCreator MakePushClientChannelCreator( static NetworkChannelCreator MakePushClientChannelCreator(
const notifier::NotifierOptions& notifier_options); const notifier::NotifierOptions& notifier_options);
static NetworkChannelCreator MakeGCMNetworkChannelCreator( static NetworkChannelCreator MakeGCMNetworkChannelCreator(
scoped_refptr<net::URLRequestContextGetter> request_context_getter, std::unique_ptr<network::SharedURLLoaderFactoryInfo>
url_loader_factory_info,
std::unique_ptr<GCMNetworkChannelDelegate> delegate); std::unique_ptr<GCMNetworkChannelDelegate> delegate);
// These methods are forwarded to the invalidation_state_tracker_. // These methods are forwarded to the invalidation_state_tracker_.
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "google/cacheinvalidation/deps/callback.h" #include "google/cacheinvalidation/deps/callback.h"
#include "google/cacheinvalidation/include/types.h" #include "google/cacheinvalidation/include/types.h"
#include "jingle/notifier/listener/push_client.h" #include "jingle/notifier/listener/push_client.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace syncer { namespace syncer {
...@@ -179,10 +180,14 @@ std::unique_ptr<SyncNetworkChannel> SyncNetworkChannel::CreatePushClientChannel( ...@@ -179,10 +180,14 @@ std::unique_ptr<SyncNetworkChannel> SyncNetworkChannel::CreatePushClientChannel(
} }
std::unique_ptr<SyncNetworkChannel> SyncNetworkChannel::CreateGCMNetworkChannel( std::unique_ptr<SyncNetworkChannel> SyncNetworkChannel::CreateGCMNetworkChannel(
scoped_refptr<net::URLRequestContextGetter> request_context_getter, std::unique_ptr<network::SharedURLLoaderFactoryInfo>
url_loader_factory_info,
std::unique_ptr<GCMNetworkChannelDelegate> delegate) { std::unique_ptr<GCMNetworkChannelDelegate> delegate) {
return std::make_unique<GCMNetworkChannel>(request_context_getter, DCHECK(url_loader_factory_info);
std::move(delegate)); return std::make_unique<GCMNetworkChannel>(
network::SharedURLLoaderFactory::Create(
std::move(url_loader_factory_info)),
std::move(delegate));
} }
void SyncNetworkChannel::NotifyNetworkStatusChange(bool online) { void SyncNetworkChannel::NotifyNetworkStatusChange(bool online) {
......
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
#include "google/cacheinvalidation/include/system-resources.h" #include "google/cacheinvalidation/include/system-resources.h"
#include "jingle/notifier/base/notifier_options.h" #include "jingle/notifier/base/notifier_options.h"
namespace network {
class SharedURLLoaderFactoryInfo;
} // namespace network
namespace syncer { namespace syncer {
class GCMNetworkChannelDelegate; class GCMNetworkChannelDelegate;
...@@ -135,7 +139,8 @@ class INVALIDATION_EXPORT SyncNetworkChannel ...@@ -135,7 +139,8 @@ class INVALIDATION_EXPORT SyncNetworkChannel
static std::unique_ptr<SyncNetworkChannel> CreatePushClientChannel( static std::unique_ptr<SyncNetworkChannel> CreatePushClientChannel(
const notifier::NotifierOptions& notifier_options); const notifier::NotifierOptions& notifier_options);
static std::unique_ptr<SyncNetworkChannel> CreateGCMNetworkChannel( static std::unique_ptr<SyncNetworkChannel> CreateGCMNetworkChannel(
scoped_refptr<net::URLRequestContextGetter> request_context_getter, std::unique_ptr<network::SharedURLLoaderFactoryInfo>
url_loader_factory_info,
std::unique_ptr<GCMNetworkChannelDelegate> delegate); std::unique_ptr<GCMNetworkChannelDelegate> delegate);
// Get the count of how many valid received messages were received. // Get the count of how many valid received messages were received.
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "components/invalidation/public/object_id_invalidation_map.h" #include "components/invalidation/public/object_id_invalidation_map.h"
#include "google_apis/gaia/gaia_constants.h" #include "google_apis/gaia/gaia_constants.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
static const char* kOAuth2Scopes[] = { static const char* kOAuth2Scopes[] = {
GaiaConstants::kGoogleTalkOAuth2Scope GaiaConstants::kGoogleTalkOAuth2Scope
...@@ -60,7 +61,8 @@ TiclInvalidationService::TiclInvalidationService( ...@@ -60,7 +61,8 @@ TiclInvalidationService::TiclInvalidationService(
std::unique_ptr<IdentityProvider> identity_provider, std::unique_ptr<IdentityProvider> identity_provider,
std::unique_ptr<TiclSettingsProvider> settings_provider, std::unique_ptr<TiclSettingsProvider> settings_provider,
gcm::GCMDriver* gcm_driver, gcm::GCMDriver* gcm_driver,
const scoped_refptr<net::URLRequestContextGetter>& request_context) const scoped_refptr<net::URLRequestContextGetter>& request_context,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory)
: user_agent_(user_agent), : user_agent_(user_agent),
identity_provider_(std::move(identity_provider)), identity_provider_(std::move(identity_provider)),
settings_provider_(std::move(settings_provider)), settings_provider_(std::move(settings_provider)),
...@@ -68,7 +70,8 @@ TiclInvalidationService::TiclInvalidationService( ...@@ -68,7 +70,8 @@ TiclInvalidationService::TiclInvalidationService(
request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy), request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy),
network_channel_type_(GCM_NETWORK_CHANNEL), network_channel_type_(GCM_NETWORK_CHANNEL),
gcm_driver_(gcm_driver), gcm_driver_(gcm_driver),
request_context_(request_context) {} request_context_(request_context),
url_loader_factory_(std::move(url_loader_factory)) {}
TiclInvalidationService::~TiclInvalidationService() { TiclInvalidationService::~TiclInvalidationService() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
...@@ -368,7 +371,8 @@ void TiclInvalidationService::StartInvalidator( ...@@ -368,7 +371,8 @@ void TiclInvalidationService::StartInvalidator(
gcm_driver_, identity_provider_.get())); gcm_driver_, identity_provider_.get()));
network_channel_creator = network_channel_creator =
syncer::NonBlockingInvalidator::MakeGCMNetworkChannelCreator( syncer::NonBlockingInvalidator::MakeGCMNetworkChannelCreator(
request_context_, gcm_invalidation_bridge_->CreateDelegate()); url_loader_factory_->Clone(),
gcm_invalidation_bridge_->CreateDelegate());
break; break;
} }
default: { default: {
......
...@@ -31,6 +31,10 @@ namespace net { ...@@ -31,6 +31,10 @@ namespace net {
class URLRequestContextGetter; class URLRequestContextGetter;
} }
namespace network {
class SharedURLLoaderFactory;
}
namespace syncer { namespace syncer {
class InvalidationStateTracker; class InvalidationStateTracker;
class Invalidator; class Invalidator;
...@@ -60,7 +64,8 @@ class TiclInvalidationService : public InvalidationService, ...@@ -60,7 +64,8 @@ class TiclInvalidationService : public InvalidationService,
std::unique_ptr<IdentityProvider> identity_provider, std::unique_ptr<IdentityProvider> identity_provider,
std::unique_ptr<TiclSettingsProvider> settings_provider, std::unique_ptr<TiclSettingsProvider> settings_provider,
gcm::GCMDriver* gcm_driver, gcm::GCMDriver* gcm_driver,
const scoped_refptr<net::URLRequestContextGetter>& request_context); const scoped_refptr<net::URLRequestContextGetter>& request_context,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
~TiclInvalidationService() override; ~TiclInvalidationService() override;
void Init(std::unique_ptr<syncer::InvalidationStateTracker> void Init(std::unique_ptr<syncer::InvalidationStateTracker>
...@@ -143,6 +148,7 @@ class TiclInvalidationService : public InvalidationService, ...@@ -143,6 +148,7 @@ class TiclInvalidationService : public InvalidationService,
gcm::GCMDriver* gcm_driver_; gcm::GCMDriver* gcm_driver_;
std::unique_ptr<GCMInvalidationBridge> gcm_invalidation_bridge_; std::unique_ptr<GCMInvalidationBridge> gcm_invalidation_bridge_;
scoped_refptr<net::URLRequestContextGetter> request_context_; scoped_refptr<net::URLRequestContextGetter> request_context_;
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
// The invalidation logger object we use to record state changes // The invalidation logger object we use to record state changes
// and invalidations. // and invalidations.
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "components/invalidation/impl/profile_identity_provider.h" #include "components/invalidation/impl/profile_identity_provider.h"
#include "components/signin/core/browser/fake_profile_oauth2_token_service.h" #include "components/signin/core/browser/fake_profile_oauth2_token_service.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace invalidation { namespace invalidation {
...@@ -70,7 +71,7 @@ class TiclInvalidationServiceTestDelegate { ...@@ -70,7 +71,7 @@ class TiclInvalidationServiceTestDelegate {
"TestUserAgent", "TestUserAgent",
std::make_unique<ProfileIdentityProvider>(&token_service_), std::make_unique<ProfileIdentityProvider>(&token_service_),
std::unique_ptr<TiclSettingsProvider>(new FakeTiclSettingsProvider), std::unique_ptr<TiclSettingsProvider>(new FakeTiclSettingsProvider),
gcm_driver_.get(), nullptr)); gcm_driver_.get(), nullptr, nullptr));
} }
void InitializeInvalidationService() { void InitializeInvalidationService() {
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/sync_preferences/testing_pref_service_syncable.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 "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace invalidation { namespace invalidation {
...@@ -67,7 +68,7 @@ void TiclProfileSettingsProviderTest::SetUp() { ...@@ -67,7 +68,7 @@ void TiclProfileSettingsProviderTest::SetUp() {
new ProfileIdentityProvider(&token_service_)), new ProfileIdentityProvider(&token_service_)),
std::unique_ptr<TiclSettingsProvider>( std::unique_ptr<TiclSettingsProvider>(
new TiclProfileSettingsProvider(&pref_service_)), new TiclProfileSettingsProvider(&pref_service_)),
&gcm_driver_, request_context_getter_)); &gcm_driver_, request_context_getter_, nullptr /* url_loader_factory */));
invalidation_service_->Init(std::unique_ptr<syncer::InvalidationStateTracker>( invalidation_service_->Init(std::unique_ptr<syncer::InvalidationStateTracker>(
new syncer::FakeInvalidationStateTracker)); new syncer::FakeInvalidationStateTracker));
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "ios/chrome/browser/signin/signin_manager_factory.h" #include "ios/chrome/browser/signin/signin_manager_factory.h"
#include "ios/web/public/web_client.h" #include "ios/web/public/web_client.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
...@@ -76,7 +77,8 @@ IOSChromeProfileInvalidationProviderFactory::BuildServiceInstanceFor( ...@@ -76,7 +77,8 @@ IOSChromeProfileInvalidationProviderFactory::BuildServiceInstanceFor(
browser_state->GetPrefs()), browser_state->GetPrefs()),
IOSChromeGCMProfileServiceFactory::GetForBrowserState(browser_state) IOSChromeGCMProfileServiceFactory::GetForBrowserState(browser_state)
->driver(), ->driver(),
browser_state->GetRequestContext())); browser_state->GetRequestContext(),
browser_state->GetSharedURLLoaderFactory()));
service->Init( service->Init(
std::make_unique<InvalidatorStorage>(browser_state->GetPrefs())); std::make_unique<InvalidatorStorage>(browser_state->GetPrefs()));
......
...@@ -9,6 +9,7 @@ namespace network { ...@@ -9,6 +9,7 @@ namespace network {
// static // static
scoped_refptr<SharedURLLoaderFactory> SharedURLLoaderFactory::Create( scoped_refptr<SharedURLLoaderFactory> SharedURLLoaderFactory::Create(
std::unique_ptr<SharedURLLoaderFactoryInfo> info) { std::unique_ptr<SharedURLLoaderFactoryInfo> info) {
DCHECK(info);
return info->CreateFactory(); return info->CreateFactory();
} }
......
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