Commit dbafbc61 authored by yurys@chromium.org's avatar yurys@chromium.org

Expose platform thread id on 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.

BUG=401895

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

git-svn-id: svn://svn.chromium.org/blink/trunk@181562 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent d283b776
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "public/platform/WebThread.h"
#include "wtf/Assertions.h"
#if OS(WIN)
#include <windows.h>
#elif OS(POSIX)
#include <unistd.h>
#endif
namespace {
#if OS(WIN)
COMPILE_ASSERT(sizeof(blink::PlatformThreadId) >= sizeof(DWORD), Size_of_platform_thread_id_is_too_small);
#elif OS(POSIX)
COMPILE_ASSERT(sizeof(blink::PlatformThreadId) >= sizeof(pid_t), Size_of_platform_thread_id_is_too_small);
#else
#error Unexpected platform
#endif
}
...@@ -141,6 +141,7 @@ ...@@ -141,6 +141,7 @@
'URLPatternMatcher.h', 'URLPatternMatcher.h',
'UUID.cpp', 'UUID.cpp',
'UUID.h', 'UUID.h',
'WebThread.cpp',
'Widget.cpp', 'Widget.cpp',
'Widget.h', 'Widget.h',
'WindowsKeyboardCodes.h', 'WindowsKeyboardCodes.h',
......
...@@ -242,6 +242,11 @@ private: ...@@ -242,6 +242,11 @@ private:
virtual void postDelayedTask(Task*, long long delayMs) OVERRIDE { ASSERT_NOT_REACHED(); }; virtual void postDelayedTask(Task*, long long delayMs) OVERRIDE { ASSERT_NOT_REACHED(); };
virtual bool isCurrentThread() const OVERRIDE { return true; } virtual bool isCurrentThread() const OVERRIDE { return true; }
virtual PlatformThreadId threadId() const OVERRIDE
{
ASSERT_NOT_REACHED();
return 0;
}
virtual void addTaskObserver(TaskObserver* taskObserver) OVERRIDE virtual void addTaskObserver(TaskObserver* taskObserver) OVERRIDE
{ {
......
...@@ -37,6 +37,12 @@ public: ...@@ -37,6 +37,12 @@ public:
return true; return true;
} }
virtual blink::PlatformThreadId threadId() const OVERRIDE
{
ASSERT_NOT_REACHED();
return 0;
}
virtual void enterRunLoop() OVERRIDE virtual void enterRunLoop() OVERRIDE
{ {
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
......
...@@ -26,9 +26,13 @@ ...@@ -26,9 +26,13 @@
#define WebThread_h #define WebThread_h
#include "WebCommon.h" #include "WebCommon.h"
#include <stdint.h>
namespace blink { namespace blink {
// Always an integer value.
typedef uintptr_t PlatformThreadId;
// Provides an interface to an embedder-defined thread implementation. // Provides an interface to an embedder-defined thread implementation.
// //
// Deleting the thread blocks until all pending, non-delayed tasks have been // Deleting the thread blocks until all pending, non-delayed tasks have been
...@@ -55,6 +59,7 @@ public: ...@@ -55,6 +59,7 @@ public:
virtual void postDelayedTask(Task*, long long delayMs) = 0; virtual void postDelayedTask(Task*, long long delayMs) = 0;
virtual bool isCurrentThread() const = 0; virtual bool isCurrentThread() const = 0;
virtual PlatformThreadId threadId() const { return 0; }
virtual void addTaskObserver(TaskObserver*) { } virtual void addTaskObserver(TaskObserver*) { }
virtual void removeTaskObserver(TaskObserver*) { } virtual void removeTaskObserver(TaskObserver*) { }
......
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