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

Cleanup: Remove CancelationSignal from HttpBridgeFactory

Since crrev.com/c/1174655 landed (more than a year ago),
HttpBridgeFactory doesn't actually need the CancelationSignal anymore.
Removing it also lets us remove a bunch of plumbing.

Bug: 951350
Change-Id: Ic4332320845747aacae43bc7062094f6da77b13b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1912715
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714921}
parent 2d099192
...@@ -356,8 +356,7 @@ void SyncEngineBackend::DoInitialize(SyncEngine::InitParams params) { ...@@ -356,8 +356,7 @@ void SyncEngineBackend::DoInitialize(SyncEngine::InitParams params) {
args.service_url = params.service_url; args.service_url = params.service_url;
args.enable_local_sync_backend = params.enable_local_sync_backend; args.enable_local_sync_backend = params.enable_local_sync_backend;
args.local_sync_backend_folder = params.local_sync_backend_folder; args.local_sync_backend_folder = params.local_sync_backend_folder;
args.post_factory = std::move(params.http_factory_getter) args.post_factory = std::move(params.http_factory_getter).Run();
.Run(&release_request_context_signal_);
// Finish initializing the HttpBridgeFactory. We do this here because // Finish initializing the HttpBridgeFactory. We do this here because
// building the user agent may block on some platforms. // building the user agent may block on some platforms.
args.post_factory->Init(params.sync_user_agent); args.post_factory->Init(params.sync_user_agent);
...@@ -491,14 +490,6 @@ void SyncEngineBackend::ShutdownOnUIThread() { ...@@ -491,14 +490,6 @@ void SyncEngineBackend::ShutdownOnUIThread() {
// initialized yet. Those classes will receive the message when the sync // initialized yet. Those classes will receive the message when the sync
// thread finally getes around to constructing them. // thread finally getes around to constructing them.
stop_syncing_signal_.Signal(); stop_syncing_signal_.Signal();
// This will drop the HttpBridgeFactory's reference to the
// RequestContextGetter. Once this has been called, the HttpBridgeFactory can
// no longer be used to create new HttpBridge instances. We can get away with
// this because the stop_syncing_signal_ has already been signalled, which
// guarantees that the ServerConnectionManager will no longer attempt to
// create new connections.
release_request_context_signal_.Signal();
} }
void SyncEngineBackend::DoShutdown(ShutdownReason reason) { void SyncEngineBackend::DoShutdown(ShutdownReason reason) {
......
...@@ -249,12 +249,11 @@ class SyncEngineBackend : public base::RefCountedThreadSafe<SyncEngineBackend>, ...@@ -249,12 +249,11 @@ class SyncEngineBackend : public base::RefCountedThreadSafe<SyncEngineBackend>,
WeakHandle<JsBackend> js_backend_; WeakHandle<JsBackend> js_backend_;
WeakHandle<DataTypeDebugInfoListener> debug_info_listener_; WeakHandle<DataTypeDebugInfoListener> debug_info_listener_;
// These signals allow us to send requests to shut down the HttpBridgeFactory // This signal allows us to send requests to shut down the
// and ServerConnectionManager without having to wait for those classes to // ServerConnectionManager without having to wait for it to finish
// finish initializing first. // initializing first.
// //
// See comments in SyncEngineBackend::ShutdownOnUIThread() for more details. // See comment in ShutdownOnUIThread() for more details.
CancelationSignal release_request_context_signal_;
CancelationSignal stop_syncing_signal_; CancelationSignal stop_syncing_signal_;
// Set when we've been asked to forward sync protocol events to the frontend. // Set when we've been asked to forward sync protocol events to the frontend.
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#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/sync/base/cancelation_signal.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/http/http_cache.h" #include "net/http/http_cache.h"
...@@ -55,30 +54,16 @@ base::LazyInstance<scoped_refptr<base::SequencedTaskRunner>>::Leaky ...@@ -55,30 +54,16 @@ base::LazyInstance<scoped_refptr<base::SequencedTaskRunner>>::Leaky
HttpBridgeFactory::HttpBridgeFactory( HttpBridgeFactory::HttpBridgeFactory(
std::unique_ptr<network::SharedURLLoaderFactoryInfo> std::unique_ptr<network::SharedURLLoaderFactoryInfo>
url_loader_factory_info, url_loader_factory_info,
const NetworkTimeUpdateCallback& network_time_update_callback, const NetworkTimeUpdateCallback& network_time_update_callback)
CancelationSignal* cancelation_signal) : network_time_update_callback_(network_time_update_callback) {
: network_time_update_callback_(network_time_update_callback),
cancelation_signal_(cancelation_signal) {
// Some tests pass null'ed out url_loader_factory_info instances. // Some tests pass null'ed out url_loader_factory_info instances.
if (url_loader_factory_info) { if (url_loader_factory_info) {
url_loader_factory_ = network::SharedURLLoaderFactory::Create( url_loader_factory_ = network::SharedURLLoaderFactory::Create(
std::move(url_loader_factory_info)); std::move(url_loader_factory_info));
} }
// This registration is happening on the Sync thread, while signalling occurs
// on the UI thread. We must handle the possibility signalling has already
// occurred.
if (cancelation_signal_->TryRegisterHandler(this)) {
registered_for_cancelation_ = true;
} else {
OnSignalReceived();
}
} }
HttpBridgeFactory::~HttpBridgeFactory() { HttpBridgeFactory::~HttpBridgeFactory() = default;
if (registered_for_cancelation_) {
cancelation_signal_->UnregisterHandler(this);
}
}
void HttpBridgeFactory::Init(const std::string& user_agent) { void HttpBridgeFactory::Init(const std::string& user_agent) {
user_agent_ = user_agent; user_agent_ = user_agent;
...@@ -97,16 +82,6 @@ void HttpBridgeFactory::Destroy(HttpPostProviderInterface* http) { ...@@ -97,16 +82,6 @@ void HttpBridgeFactory::Destroy(HttpPostProviderInterface* http) {
static_cast<HttpBridge*>(http)->Release(); static_cast<HttpBridge*>(http)->Release();
} }
void HttpBridgeFactory::OnSignalReceived() {
// TODO(tonikitoo): Remove this method.
//
// Prior to the URLLoader conversion the sync code was holding on to a
// scoped_refptr of a URLRequestContextGetter it was changing the lifetime
// of net objects. With URLLoader, it's only holding on to mojo pipes
// that issue doesn't exist.
NOTIMPLEMENTED();
}
HttpBridge::URLFetchState::URLFetchState() HttpBridge::URLFetchState::URLFetchState()
: aborted(false), : aborted(false),
request_completed(false), request_completed(false),
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "components/sync/base/cancelation_observer.h"
#include "components/sync/engine/net/http_post_provider_factory.h" #include "components/sync/engine/net/http_post_provider_factory.h"
#include "components/sync/engine/net/http_post_provider_interface.h" #include "components/sync/engine/net/http_post_provider_interface.h"
#include "components/sync/engine/net/network_time_update_callback.h" #include "components/sync/engine/net/network_time_update_callback.h"
...@@ -36,8 +35,6 @@ class SimpleURLLoader; ...@@ -36,8 +35,6 @@ class SimpleURLLoader;
namespace syncer { namespace syncer {
class CancelationSignal;
// A bridge between the syncer and Chromium HTTP layers. // A bridge between the syncer and Chromium HTTP layers.
// Provides a way for the sync backend to use Chromium directly for HTTP // Provides a way for the sync backend to use Chromium directly for HTTP
// requests rather than depending on a third party provider (e.g libcurl). // requests rather than depending on a third party provider (e.g libcurl).
...@@ -196,14 +193,12 @@ class HttpBridge : public base::RefCountedThreadSafe<HttpBridge>, ...@@ -196,14 +193,12 @@ class HttpBridge : public base::RefCountedThreadSafe<HttpBridge>,
DISALLOW_COPY_AND_ASSIGN(HttpBridge); DISALLOW_COPY_AND_ASSIGN(HttpBridge);
}; };
class HttpBridgeFactory : public HttpPostProviderFactory, class HttpBridgeFactory : public HttpPostProviderFactory {
public CancelationObserver {
public: public:
HttpBridgeFactory( HttpBridgeFactory(
std::unique_ptr<network::SharedURLLoaderFactoryInfo> std::unique_ptr<network::SharedURLLoaderFactoryInfo>
url_loader_factory_info, url_loader_factory_info,
const NetworkTimeUpdateCallback& network_time_update_callback, const NetworkTimeUpdateCallback& network_time_update_callback);
CancelationSignal* cancelation_signal);
~HttpBridgeFactory() override; ~HttpBridgeFactory() override;
// HttpPostProviderFactory: // HttpPostProviderFactory:
...@@ -211,9 +206,6 @@ class HttpBridgeFactory : public HttpPostProviderFactory, ...@@ -211,9 +206,6 @@ class HttpBridgeFactory : public HttpPostProviderFactory,
HttpPostProviderInterface* Create() override; HttpPostProviderInterface* Create() override;
void Destroy(HttpPostProviderInterface* http) override; void Destroy(HttpPostProviderInterface* http) override;
// CancelationObserver implementation:
void OnSignalReceived() override;
private: private:
// The user agent to use in all requests. // The user agent to use in all requests.
std::string user_agent_; std::string user_agent_;
...@@ -223,9 +215,6 @@ class HttpBridgeFactory : public HttpPostProviderFactory, ...@@ -223,9 +215,6 @@ class HttpBridgeFactory : public HttpPostProviderFactory,
NetworkTimeUpdateCallback network_time_update_callback_; NetworkTimeUpdateCallback network_time_update_callback_;
CancelationSignal* const cancelation_signal_;
bool registered_for_cancelation_ = false;
DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory);
}; };
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#include <utility> #include <utility>
#include "base/memory/ptr_util.h"
#include "components/sync/base/cancelation_signal.h"
#include "components/sync/engine/net/http_bridge.h" #include "components/sync/engine/net/http_bridge.h"
#include "components/sync/engine/net/http_post_provider_factory.h" #include "components/sync/engine/net/http_post_provider_factory.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
...@@ -20,11 +18,9 @@ std::unique_ptr<HttpPostProviderFactory> ...@@ -20,11 +18,9 @@ std::unique_ptr<HttpPostProviderFactory>
HttpBridgeNetworkResources::GetHttpPostProviderFactory( HttpBridgeNetworkResources::GetHttpPostProviderFactory(
std::unique_ptr<network::SharedURLLoaderFactoryInfo> std::unique_ptr<network::SharedURLLoaderFactoryInfo>
url_loader_factory_info, url_loader_factory_info,
const NetworkTimeUpdateCallback& network_time_update_callback, const NetworkTimeUpdateCallback& network_time_update_callback) {
CancelationSignal* cancelation_signal) { return std::make_unique<HttpBridgeFactory>(std::move(url_loader_factory_info),
return base::WrapUnique<HttpPostProviderFactory>( network_time_update_callback);
new HttpBridgeFactory(std::move(url_loader_factory_info),
network_time_update_callback, cancelation_signal));
} }
} // namespace syncer } // namespace syncer
...@@ -16,7 +16,6 @@ class SharedURLLoaderFactoryInfo; ...@@ -16,7 +16,6 @@ class SharedURLLoaderFactoryInfo;
namespace syncer { namespace syncer {
class CancelationSignal;
class HttpPostProviderFactory; class HttpPostProviderFactory;
class HttpBridgeNetworkResources : public NetworkResources { class HttpBridgeNetworkResources : public NetworkResources {
...@@ -27,8 +26,7 @@ class HttpBridgeNetworkResources : public NetworkResources { ...@@ -27,8 +26,7 @@ class HttpBridgeNetworkResources : public NetworkResources {
std::unique_ptr<HttpPostProviderFactory> GetHttpPostProviderFactory( std::unique_ptr<HttpPostProviderFactory> GetHttpPostProviderFactory(
std::unique_ptr<network::SharedURLLoaderFactoryInfo> std::unique_ptr<network::SharedURLLoaderFactoryInfo>
url_loader_factory_info, url_loader_factory_info,
const NetworkTimeUpdateCallback& network_time_update_callback, const NetworkTimeUpdateCallback& network_time_update_callback) override;
CancelationSignal* cancelation_signal) override;
}; };
} // namespace syncer } // namespace syncer
......
...@@ -15,7 +15,6 @@ class SharedURLLoaderFactoryInfo; ...@@ -15,7 +15,6 @@ class SharedURLLoaderFactoryInfo;
namespace syncer { namespace syncer {
class CancelationSignal;
class HttpPostProviderFactory; class HttpPostProviderFactory;
class NetworkResources { class NetworkResources {
...@@ -25,8 +24,7 @@ class NetworkResources { ...@@ -25,8 +24,7 @@ class NetworkResources {
virtual std::unique_ptr<HttpPostProviderFactory> GetHttpPostProviderFactory( virtual std::unique_ptr<HttpPostProviderFactory> GetHttpPostProviderFactory(
std::unique_ptr<network::SharedURLLoaderFactoryInfo> std::unique_ptr<network::SharedURLLoaderFactoryInfo>
url_loader_factory_info, url_loader_factory_info,
const NetworkTimeUpdateCallback& network_time_update_callback, const NetworkTimeUpdateCallback& network_time_update_callback) = 0;
CancelationSignal* cancelation_signal) = 0;
}; };
} // namespace syncer } // namespace syncer
......
...@@ -32,7 +32,6 @@ class GURL; ...@@ -32,7 +32,6 @@ class GURL;
namespace syncer { namespace syncer {
class CancelationSignal;
class HttpPostProviderFactory; class HttpPostProviderFactory;
class SyncEngineHost; class SyncEngineHost;
class SyncManagerFactory; class SyncManagerFactory;
...@@ -47,8 +46,7 @@ class SyncEngine : public ModelTypeConfigurer { ...@@ -47,8 +46,7 @@ class SyncEngine : public ModelTypeConfigurer {
using AllNodesCallback = using AllNodesCallback =
base::OnceCallback<void(ModelType, std::unique_ptr<base::ListValue>)>; base::OnceCallback<void(ModelType, std::unique_ptr<base::ListValue>)>;
using HttpPostProviderFactoryGetter = using HttpPostProviderFactoryGetter =
base::OnceCallback<std::unique_ptr<HttpPostProviderFactory>( base::OnceCallback<std::unique_ptr<HttpPostProviderFactory>()>;
CancelationSignal*)>;
// Utility struct for holding initialization options. // Utility struct for holding initialization options.
struct InitParams { struct InitParams {
......
...@@ -5,13 +5,11 @@ ...@@ -5,13 +5,11 @@
#include "components/sync/test/fake_server/fake_server_network_resources.h" #include "components/sync/test/fake_server/fake_server_network_resources.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "components/sync/base/cancelation_signal.h"
#include "components/sync/engine/net/http_post_provider_factory.h" #include "components/sync/engine/net/http_post_provider_factory.h"
#include "components/sync/test/fake_server/fake_server.h" #include "components/sync/test/fake_server/fake_server.h"
#include "components/sync/test/fake_server/fake_server_http_post_provider.h" #include "components/sync/test/fake_server/fake_server_http_post_provider.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
using syncer::CancelationSignal;
using syncer::HttpPostProviderFactory; using syncer::HttpPostProviderFactory;
using syncer::NetworkTimeUpdateCallback; using syncer::NetworkTimeUpdateCallback;
...@@ -28,8 +26,7 @@ std::unique_ptr<syncer::HttpPostProviderFactory> ...@@ -28,8 +26,7 @@ std::unique_ptr<syncer::HttpPostProviderFactory>
FakeServerNetworkResources::GetHttpPostProviderFactory( FakeServerNetworkResources::GetHttpPostProviderFactory(
std::unique_ptr<network::SharedURLLoaderFactoryInfo> std::unique_ptr<network::SharedURLLoaderFactoryInfo>
url_loader_factory_info, url_loader_factory_info,
const NetworkTimeUpdateCallback& network_time_update_callback, const NetworkTimeUpdateCallback& network_time_update_callback) {
CancelationSignal* cancelation_signal) {
return std::make_unique<FakeServerHttpPostProviderFactory>( return std::make_unique<FakeServerHttpPostProviderFactory>(
fake_server_, fake_server_task_runner_); fake_server_, fake_server_task_runner_);
} }
......
...@@ -32,8 +32,8 @@ class FakeServerNetworkResources : public syncer::NetworkResources { ...@@ -32,8 +32,8 @@ class FakeServerNetworkResources : public syncer::NetworkResources {
std::unique_ptr<syncer::HttpPostProviderFactory> GetHttpPostProviderFactory( std::unique_ptr<syncer::HttpPostProviderFactory> GetHttpPostProviderFactory(
std::unique_ptr<network::SharedURLLoaderFactoryInfo> std::unique_ptr<network::SharedURLLoaderFactoryInfo>
url_loader_factory_info, url_loader_factory_info,
const syncer::NetworkTimeUpdateCallback& network_time_update_callback, const syncer::NetworkTimeUpdateCallback& network_time_update_callback)
syncer::CancelationSignal* cancelation_signal) override; override;
private: private:
base::WeakPtr<FakeServer> fake_server_; base::WeakPtr<FakeServer> fake_server_;
......
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