Commit 07e7a118 authored by yurys's avatar yurys Committed by Commit bot

Expose platform thread id on blink::WebThread

DevTools code needs access to platform thread id in order to collect Worker thread ids and based on them differentiate worker threads in recorded trace events.

Blink part of the change: https://codereview.chromium.org/514193002/

BUG=401895

Review URL: https://codereview.chromium.org/515243002

Cr-Commit-Position: refs/heads/master@{#294345}
parent 1b75265c
......@@ -88,13 +88,18 @@ bool WebThreadImpl::isCurrentThread() const {
return thread_->thread_id() == base::PlatformThread::CurrentId();
}
blink::PlatformThreadId WebThreadImpl::threadId() const {
return thread_->thread_id();
}
WebThreadImpl::~WebThreadImpl() {
thread_->Stop();
}
WebThreadImplForMessageLoop::WebThreadImplForMessageLoop(
base::MessageLoopProxy* message_loop)
: message_loop_(message_loop) {}
: message_loop_(message_loop),
thread_id_(base::PlatformThread::CurrentId()) {}
void WebThreadImplForMessageLoop::postTask(Task* task) {
message_loop_->PostTask(
......@@ -126,6 +131,10 @@ bool WebThreadImplForMessageLoop::isCurrentThread() const {
return message_loop_->BelongsToCurrentThread();
}
blink::PlatformThreadId WebThreadImplForMessageLoop::threadId() const {
return thread_id_;
}
WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() {}
} // namespace content
......@@ -22,6 +22,7 @@ class CONTENT_EXPORT WebThreadBase : public blink::WebThread {
virtual void removeTaskObserver(TaskObserver* observer);
virtual bool isCurrentThread() const = 0;
virtual blink::PlatformThreadId threadId() const = 0;
protected:
WebThreadBase();
......@@ -47,6 +48,7 @@ class CONTENT_EXPORT WebThreadImpl : public WebThreadBase {
base::MessageLoop* message_loop() const { return thread_->message_loop(); }
virtual bool isCurrentThread() const OVERRIDE;
virtual blink::PlatformThreadId threadId() const OVERRIDE;
private:
scoped_ptr<base::Thread> thread_;
......@@ -66,7 +68,10 @@ class WebThreadImplForMessageLoop : public WebThreadBase {
private:
virtual bool isCurrentThread() const OVERRIDE;
virtual blink::PlatformThreadId threadId() const OVERRIDE;
scoped_refptr<base::MessageLoopProxy> message_loop_;
blink::PlatformThreadId thread_id_;
};
} // namespace content
......
......@@ -88,6 +88,10 @@ bool WebThreadImpl::isCurrentThread() const {
return thread_->thread_id() == base::PlatformThread::CurrentId();
}
blink::PlatformThreadId WebThreadImpl::threadId() const {
return thread_->thread_id();
}
WebThreadImpl::~WebThreadImpl() {
thread_->Stop();
}
......@@ -126,6 +130,10 @@ bool WebThreadImplForMessageLoop::isCurrentThread() const {
return message_loop_->BelongsToCurrentThread();
}
blink::PlatformThreadId WebThreadImplForMessageLoop::threadId() const {
return thread_id_;
}
WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() {}
} // namespace mojo
......@@ -21,6 +21,7 @@ class WebThreadBase : public blink::WebThread {
virtual void removeTaskObserver(TaskObserver* observer);
virtual bool isCurrentThread() const = 0;
virtual blink::PlatformThreadId threadId() const = 0;
protected:
WebThreadBase();
......@@ -46,6 +47,7 @@ class WebThreadImpl : public WebThreadBase {
base::MessageLoop* message_loop() const { return thread_->message_loop(); }
virtual bool isCurrentThread() const;
virtual blink::PlatformThreadId threadId() const;
private:
scoped_ptr<base::Thread> thread_;
......@@ -65,7 +67,10 @@ class WebThreadImplForMessageLoop : public WebThreadBase {
private:
virtual bool isCurrentThread() const;
virtual blink::PlatformThreadId threadId() const;
scoped_refptr<base::MessageLoopProxy> message_loop_;
blink::PlatformThreadId thread_id_;
};
} // namespace mojo
......
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