Skip to content

Commit

Permalink
Remove RendererScheduler::LoadingTaskRunner()
Browse files Browse the repository at this point in the history
There was only one usage of RendererScheduler::LoadingTaskRunner() and
now it was removed (https://chromium-review.googlesource.com/c/chromium/src/+/866620
and https://chromium-review.googlesource.com/c/chromium/src/+/870010).
This CL removes RendererScheduler::LoadingTaskRunner().

This is part of efforts to replace thread-local task runners with other
appropriate per-frame task runners in the renderer.

Bug: 801476
Change-Id: If0ca8962f2367688f87619a10463c2b7475d6b35
Reviewed-on: https://chromium-review.googlesource.com/868110
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Alex Clarke <alexclarke@chromium.org>
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#530473}
  • Loading branch information
Hajime Hoshi authored and Commit Bot committed Jan 19, 2018
1 parent b75026f commit 1711b52
Show file tree
Hide file tree
Showing 20 changed files with 18 additions and 83 deletions.
7 changes: 2 additions & 5 deletions content/renderer/loader/resource_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,8 @@ int ResourceDispatcher::MakeRequestID() {
return sequence.GetNext(); // We start at zero.
}

ResourceDispatcher::ResourceDispatcher(
scoped_refptr<base::SingleThreadTaskRunner> thread_task_runner)
: delegate_(nullptr),
thread_task_runner_(thread_task_runner),
weak_factory_(this) {}
ResourceDispatcher::ResourceDispatcher()
: delegate_(nullptr), weak_factory_(this) {}

ResourceDispatcher::~ResourceDispatcher() {
}
Expand Down
10 changes: 1 addition & 9 deletions content/renderer/loader/resource_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ class CONTENT_EXPORT ResourceDispatcher {
// CORS preflight requests.
static int MakeRequestID();

explicit ResourceDispatcher(
scoped_refptr<base::SingleThreadTaskRunner> thread_task_runner);
ResourceDispatcher();
virtual ~ResourceDispatcher();

// Call this method to load the resource synchronously (i.e., in one shot).
Expand Down Expand Up @@ -138,11 +137,6 @@ class CONTENT_EXPORT ResourceDispatcher {
delegate_ = delegate;
}

void SetThreadTaskRunner(
scoped_refptr<base::SingleThreadTaskRunner> thread_task_runner) {
thread_task_runner_ = thread_task_runner;
}

base::WeakPtr<ResourceDispatcher> GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
Expand Down Expand Up @@ -233,8 +227,6 @@ class CONTENT_EXPORT ResourceDispatcher {

ResourceDispatcherDelegate* delegate_;

scoped_refptr<base::SingleThreadTaskRunner> thread_task_runner_;

base::WeakPtrFactory<ResourceDispatcher> weak_factory_;

DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher);
Expand Down
3 changes: 1 addition & 2 deletions content/renderer/loader/resource_dispatcher_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ static constexpr char kTestPageContents[] =
class ResourceDispatcherTest : public testing::Test,
public network::mojom::URLLoaderFactory {
public:
ResourceDispatcherTest()
: dispatcher_(new ResourceDispatcher(message_loop_.task_runner())) {}
ResourceDispatcherTest() : dispatcher_(new ResourceDispatcher()) {}

~ResourceDispatcherTest() override {
dispatcher_.reset();
Expand Down
3 changes: 1 addition & 2 deletions content/renderer/loader/sync_load_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ SyncLoadContext::SyncLoadContext(
SharedURLLoaderFactory::Create(std::move(url_loader_factory));

// Constructs a new ResourceDispatcher specifically for this request.
resource_dispatcher_ =
std::make_unique<ResourceDispatcher>(base::ThreadTaskRunnerHandle::Get());
resource_dispatcher_ = std::make_unique<ResourceDispatcher>();

// Initialize the final URL with the original request URL. It will be
// overwritten on redirects.
Expand Down
3 changes: 1 addition & 2 deletions content/renderer/loader/url_loader_client_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ namespace content {
class URLLoaderClientImplTest : public ::testing::Test,
public network::mojom::URLLoaderFactory {
protected:
URLLoaderClientImplTest()
: dispatcher_(new ResourceDispatcher(message_loop_.task_runner())) {
URLLoaderClientImplTest() : dispatcher_(new ResourceDispatcher()) {
request_id_ = dispatcher_->StartAsync(
std::make_unique<network::ResourceRequest>(), 0,
blink::scheduler::GetSingleThreadTaskRunnerForTesting(), url::Origin(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ class URLResponseBodyConsumerTest : public ::testing::Test {
std::vector<network::mojom::URLLoaderClientPtr> clients_;
};

URLResponseBodyConsumerTest()
: dispatcher_(new ResourceDispatcher(message_loop_.task_runner())) {}
URLResponseBodyConsumerTest() : dispatcher_(new ResourceDispatcher()) {}

~URLResponseBodyConsumerTest() override {
dispatcher_.reset();
Expand Down
3 changes: 1 addition & 2 deletions content/renderer/loader/web_url_loader_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ const char kFtpDirListing[] =

class TestResourceDispatcher : public ResourceDispatcher {
public:
TestResourceDispatcher()
: ResourceDispatcher(nullptr), canceled_(false), defers_loading_(false) {}
TestResourceDispatcher() : canceled_(false), defers_loading_(false) {}

~TestResourceDispatcher() override {}

Expand Down
13 changes: 1 addition & 12 deletions content/renderer/render_thread_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,7 @@ void RenderThreadImpl::Init(
new NotificationDispatcher(thread_safe_sender());
AddFilter(notification_dispatcher_->GetFilter());

resource_dispatcher_.reset(
new ResourceDispatcher(message_loop()->task_runner()));
resource_dispatcher_.reset(new ResourceDispatcher());
quota_dispatcher_.reset(new QuotaDispatcher(message_loop()->task_runner()));
url_loader_throttle_provider_ =
GetContentClient()->renderer()->CreateURLLoaderThrottleProvider(
Expand Down Expand Up @@ -1250,16 +1249,6 @@ void RenderThreadImpl::InitializeWebKit(
base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived),
base::Unretained(this)));

scoped_refptr<base::SingleThreadTaskRunner> resource_task_queue2;
if (resource_task_queue) {
resource_task_queue2 = resource_task_queue;
} else {
resource_task_queue2 = renderer_scheduler_->LoadingTaskRunner();
}
// The ResourceDispatcher needs to use the same queue to ensure tasks are
// executed in the expected order.
resource_dispatcher_->SetThreadTaskRunner(resource_task_queue2);

if (!command_line.HasSwitch(switches::kDisableThreadedCompositing))
InitializeCompositorThread();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ ServiceWorkerFetchContextImpl::ServiceWorkerFetchContextImpl(

ServiceWorkerFetchContextImpl::~ServiceWorkerFetchContextImpl() {}

void ServiceWorkerFetchContextImpl::InitializeOnWorkerThread(
scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner) {
resource_dispatcher_ =
std::make_unique<ResourceDispatcher>(std::move(loading_task_runner));
void ServiceWorkerFetchContextImpl::InitializeOnWorkerThread() {
resource_dispatcher_ = std::make_unique<ResourceDispatcher>();

url_loader_factory_getter_ = url_loader_factory_getter_info_.Bind();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
#include "third_party/WebKit/public/platform/WebWorkerFetchContext.h"
#include "url/gurl.h"

namespace base {
class SingleThreadTaskRunner;
} // namespace base

namespace content {
class ResourceDispatcher;
class URLLoaderThrottleProvider;
Expand All @@ -28,8 +24,7 @@ class ServiceWorkerFetchContextImpl : public blink::WebWorkerFetchContext {
~ServiceWorkerFetchContextImpl() override;

// blink::WebWorkerFetchContext implementation:
void InitializeOnWorkerThread(
scoped_refptr<base::SingleThreadTaskRunner>) override;
void InitializeOnWorkerThread() override;
std::unique_ptr<blink::WebURLLoaderFactory> CreateURLLoaderFactory() override;
void WillSendRequest(blink::WebURLRequest&) override;
bool IsControlledByServiceWorker() const override;
Expand Down
7 changes: 2 additions & 5 deletions content/renderer/service_worker/worker_fetch_context_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,10 @@ WorkerFetchContextImpl::WorkerFetchContextImpl(

WorkerFetchContextImpl::~WorkerFetchContextImpl() {}

void WorkerFetchContextImpl::InitializeOnWorkerThread(
scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner) {
DCHECK(loading_task_runner->RunsTasksInCurrentSequence());
void WorkerFetchContextImpl::InitializeOnWorkerThread() {
DCHECK(!resource_dispatcher_);
DCHECK(!binding_.is_bound());
resource_dispatcher_ =
std::make_unique<ResourceDispatcher>(std::move(loading_task_runner));
resource_dispatcher_ = std::make_unique<ResourceDispatcher>();

url_loader_factory_getter_ = url_loader_factory_getter_info_.Bind();
if (service_worker_client_request_.is_pending())
Expand Down
7 changes: 1 addition & 6 deletions content/renderer/service_worker/worker_fetch_context_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
#include "third_party/WebKit/public/platform/WebWorkerFetchContext.h"
#include "url/gurl.h"

namespace base {
class SingleThreadTaskRunner;
} // namespace base

namespace IPC {
class Message;
} // namespace IPC
Expand All @@ -48,8 +44,7 @@ class WorkerFetchContextImpl : public blink::WebWorkerFetchContext,
~WorkerFetchContextImpl() override;

// blink::WebWorkerFetchContext implementation:
void InitializeOnWorkerThread(
scoped_refptr<base::SingleThreadTaskRunner>) override;
void InitializeOnWorkerThread() override;
std::unique_ptr<blink::WebURLLoaderFactory> CreateURLLoaderFactory() override;
void WillSendRequest(blink::WebURLRequest&) override;
bool IsControlledByServiceWorker() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ class WebWorkerFetchContextForTest : public WebWorkerFetchContext {
public:
WebWorkerFetchContextForTest(KURL site_for_cookies)
: site_for_cookies_(site_for_cookies.Copy()) {}
void InitializeOnWorkerThread(
scoped_refptr<base::SingleThreadTaskRunner>) override {}
void InitializeOnWorkerThread() override {}

std::unique_ptr<WebURLLoaderFactory> CreateURLLoaderFactory() override {
return std::make_unique<WebURLLoaderFactoryWithMock>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ WorkerFetchContext::WorkerFetchContext(
loading_task_runner_(
global_scope_->GetTaskRunner(TaskType::kUnspecedLoading)),
save_data_enabled_(GetNetworkStateNotifier().SaveDataEnabled()) {
web_context_->InitializeOnWorkerThread(loading_task_runner_);
web_context_->InitializeOnWorkerThread();
std::unique_ptr<blink::WebDocumentSubresourceFilter> web_filter =
web_context_->TakeSubresourceFilter();
if (web_filter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,6 @@ RendererSchedulerImpl::IPCTaskRunner() {
return ipc_task_queue_;
}

scoped_refptr<base::SingleThreadTaskRunner>
RendererSchedulerImpl::LoadingTaskRunner() {
helper_.CheckOnValidThread();
return default_loading_task_queue_;
}

scoped_refptr<MainThreadTaskQueue> RendererSchedulerImpl::DefaultTaskQueue() {
return helper_.DefaultMainThreadTaskQueue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ class PLATFORM_EXPORT RendererSchedulerImpl
// Use *TaskQueue internally.
scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner() override;
scoped_refptr<base::SingleThreadTaskRunner> CompositorTaskRunner() override;
scoped_refptr<base::SingleThreadTaskRunner> LoadingTaskRunner() override;

private:
friend class RenderWidgetSchedulingState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ FakeRendererScheduler::CompositorTaskRunner() {
return nullptr;
}

scoped_refptr<base::SingleThreadTaskRunner>
FakeRendererScheduler::LoadingTaskRunner() {
return nullptr;
}

scoped_refptr<SingleThreadIdleTaskRunner>
FakeRendererScheduler::IdleTaskRunner() {
return nullptr;
Expand Down
7 changes: 1 addition & 6 deletions third_party/WebKit/public/platform/WebWorkerFetchContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
#include "public/platform/WebDocumentSubresourceFilter.h"
#include "public/platform/WebURL.h"

namespace base {
class SingleThreadTaskRunner;
}

namespace blink {

class WebURLLoaderFactory;
Expand All @@ -31,8 +27,7 @@ class WebWorkerFetchContext {
public:
virtual ~WebWorkerFetchContext() = default;

virtual void InitializeOnWorkerThread(
scoped_refptr<base::SingleThreadTaskRunner>) = 0;
virtual void InitializeOnWorkerThread() = 0;

// Returns a new WebURLLoaderFactory which is associated with the worker
// context. It can be called only once.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ class BLINK_PLATFORM_EXPORT RendererScheduler : public ChildScheduler {
// Creates a WebThread implementation for the renderer main thread.
virtual std::unique_ptr<WebThread> CreateMainThread() = 0;

// Returns the loading task runner. This queue is intended for tasks related
// to resource dispatch, foreground HTML parsing, etc...
virtual scoped_refptr<base::SingleThreadTaskRunner> LoadingTaskRunner() = 0;

// Returns a new RenderWidgetSchedulingState. The signals from this will be
// used to make scheduling decisions.
virtual std::unique_ptr<RenderWidgetSchedulingState>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class FakeRendererScheduler : public RendererScheduler {
std::unique_ptr<WebThread> CreateMainThread() override;
scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner() override;
scoped_refptr<base::SingleThreadTaskRunner> CompositorTaskRunner() override;
scoped_refptr<base::SingleThreadTaskRunner> LoadingTaskRunner() override;
scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() override;
scoped_refptr<base::SingleThreadTaskRunner> IPCTaskRunner() override;
std::unique_ptr<RenderWidgetSchedulingState> NewRenderWidgetSchedulingState()
Expand Down

0 comments on commit 1711b52

Please sign in to comment.