Commit 7d1191c8 authored by François Doray's avatar François Doray Committed by Chromium LUCI CQ

Revert "[blink scheduler] Add blink::Thread::ThreadHandle."

This reverts commit e66dcc06.

Reason for revert: Thread handle != thread id on Linux
crbug.com/1158103

Original change's description:
> [blink scheduler] Add blink::Thread::ThreadHandle.
>
> The thread handle should be used instead of the thread id for thread
> manipulations. It is available immediately after thread creation,
> unlike the thread id which is available only after the main function
> is entered. Also, on Windows, the thread handle remains valid after the
> thread has exited.
>
> This is a prerequisite to remove the wait after compositor thread
> initialization
> https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/platform/scheduler/common/thread.cc;l=96;drc=5b1ca7b1087e13d963bc4058d9406a838fb7f9ca
>
> Bug: 1080709
> Change-Id: Ia0b72aa1b3a86454cffa774131944db87ced0843
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2578172
> Reviewed-by: Alexander Timin <altimin@chromium.org>
> Reviewed-by: Kentaro Hara <haraken@chromium.org>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Commit-Queue: Kentaro Hara <haraken@chromium.org>
> Auto-Submit: François Doray <fdoray@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#835544}

TBR=gab@chromium.org,fdoray@chromium.org,haraken@chromium.org,altimin@chromium.org,chromium-scoped@luci-project-accounts.iam.gserviceaccount.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1080709, 1158103
Change-Id: Ib4bd9113ad8a72fe4e9215989e07986d3b357c20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2593833Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837302}
parent 4a67dcea
......@@ -60,11 +60,6 @@ PlatformThreadId SimpleThread::tid() {
return tid_;
}
PlatformThreadHandle SimpleThread::handle() const {
DCHECK(!thread_.is_null());
return thread_;
}
bool SimpleThread::HasBeenStarted() {
return event_.IsSignaled();
}
......
......@@ -112,10 +112,6 @@ class BASE_EXPORT SimpleThread : public PlatformThread::Delegate {
// be called before HasBeenStarted() returns True.
PlatformThreadId tid();
// Returns the thread handle. Valid only if the thread is joinable, started
// and not yet joined.
PlatformThreadHandle handle() const;
// Returns True if the thread has been started and initialized (i.e. if
// ThreadMain() has run). If the thread was started with StartAsync(), but it
// hasn't been initialized yet (i.e. ThreadMain() has not run), then this will
......
......@@ -234,12 +234,11 @@ RendererBlinkPlatformImpl::WrapSharedURLLoaderFactory(
}
void RendererBlinkPlatformImpl::SetDisplayThreadPriority(
base::PlatformThreadHandle thread_handle) {
base::PlatformThreadId thread_id) {
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
if (RenderThreadImpl* render_thread = RenderThreadImpl::current()) {
// On Linux and ChromeOS, the thread handle is equivalent to the thread id.
render_thread->render_message_filter()->SetThreadPriority(
thread_handle.platform_handle(), base::ThreadPriority::DISPLAY);
thread_id, base::ThreadPriority::DISPLAY);
}
#endif
}
......
......@@ -183,8 +183,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
const blink::WebURL& top_document_web_url) override;
gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
blink::WebString ConvertIDNToUnicode(const blink::WebString& host) override;
void SetDisplayThreadPriority(
base::PlatformThreadHandle thread_handle) override;
void SetDisplayThreadPriority(base::PlatformThreadId thread_id) override;
blink::BlameContext* GetTopLevelBlameContext() override;
std::unique_ptr<blink::WebDedicatedWorkerHostFactoryClient>
CreateDedicatedWorkerHostFactoryClient(
......
......@@ -392,7 +392,7 @@ class BLINK_PLATFORM_EXPORT Platform {
// increase the nice value, so we need to ask the browser process). This
// function is only called from the main thread (where InitializeCompositor-
// Thread() is called).
virtual void SetDisplayThreadPriority(base::PlatformThreadHandle) {}
virtual void SetDisplayThreadPriority(base::PlatformThreadId) {}
// Returns a blame context for attributing top-level work which does not
// belong to a particular frame scope.
......
......@@ -102,7 +102,7 @@ void Thread::CreateAndSetCompositorThread() {
// This is not possible inside the sandbox, so ask the browser to do it.
// TODO(spang): Check if we can remove this on non-Chrome OS builds.
Platform::Current()->SetDisplayThreadPriority(
GetCompositorThread()->ThreadHandle());
GetCompositorThread()->ThreadId());
}
}
......
......@@ -14,8 +14,7 @@ namespace scheduler {
MainThread::MainThread(MainThreadSchedulerImpl* scheduler)
: task_runner_(scheduler->DefaultTaskRunner()),
scheduler_(scheduler),
thread_id_(base::PlatformThread::CurrentId()),
thread_handle_(base::PlatformThread::CurrentHandle()) {}
thread_id_(base::PlatformThread::CurrentId()) {}
MainThread::~MainThread() = default;
......@@ -23,10 +22,6 @@ blink::PlatformThreadId MainThread::ThreadId() const {
return thread_id_;
}
base::PlatformThreadHandle MainThread::ThreadHandle() const {
return thread_handle_;
}
blink::ThreadScheduler* MainThread::Scheduler() {
return scheduler_;
}
......
......@@ -7,7 +7,6 @@
#include "base/memory/scoped_refptr.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/platform_thread.h"
#include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
......@@ -27,7 +26,6 @@ class PLATFORM_EXPORT MainThread : public Thread {
// Thread implementation.
ThreadScheduler* Scheduler() override;
PlatformThreadId ThreadId() const override;
base::PlatformThreadHandle ThreadHandle() const override;
scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() const override;
void AddTaskTimeObserver(base::sequence_manager::TaskTimeObserver*) override;
......@@ -35,10 +33,9 @@ class PLATFORM_EXPORT MainThread : public Thread {
base::sequence_manager::TaskTimeObserver*) override;
private:
const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
MainThreadSchedulerImpl* const scheduler_; // Not owned.
const PlatformThreadId thread_id_;
const base::PlatformThreadHandle thread_handle_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
MainThreadSchedulerImpl* scheduler_; // Not owned.
PlatformThreadId thread_id_;
};
} // namespace scheduler
......
......@@ -26,12 +26,10 @@
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_PUBLIC_THREAD_H_
#include <stdint.h>
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "base/task/task_observer.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread.h"
#include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_type.h"
......@@ -128,10 +126,7 @@ class PLATFORM_EXPORT Thread {
}
bool IsCurrentThread() const;
virtual PlatformThreadId ThreadId() const { return base::kInvalidThreadId; }
virtual base::PlatformThreadHandle ThreadHandle() const {
return base::PlatformThreadHandle();
}
virtual PlatformThreadId ThreadId() const { return 0; }
// TaskObserver is an object that receives task notifications from the
// MessageLoop.
......
......@@ -76,10 +76,6 @@ blink::PlatformThreadId WorkerThread::ThreadId() const {
return thread_->tid();
}
base::PlatformThreadHandle WorkerThread::ThreadHandle() const {
return thread_->handle();
}
blink::ThreadScheduler* WorkerThread::Scheduler() {
return thread_->GetNonMainThreadScheduler();
}
......
......@@ -42,7 +42,6 @@ class PLATFORM_EXPORT WorkerThread : public Thread {
void Init() override;
ThreadScheduler* Scheduler() override;
PlatformThreadId ThreadId() const override;
base::PlatformThreadHandle ThreadHandle() const override;
scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() const override;
scheduler::NonMainThreadSchedulerImpl* GetNonMainThreadScheduler() {
......
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