Make PlatformThread::SetName operate only on the current thread.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1306 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -2,6 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// WARNING: You should *NOT* be using this class directly. PlatformThread is
|
||||
// the low-level platform-specific abstraction to the OS's threading interface.
|
||||
// You should instead be using a message-loop driven Thread, see thread.h.
|
||||
|
||||
#ifndef BASE_PLATFORM_THREAD_H_
|
||||
#define BASE_PLATFORM_THREAD_H_
|
||||
|
||||
@ -31,9 +35,7 @@ class PlatformThread {
|
||||
static void Sleep(int duration_ms);
|
||||
|
||||
// Sets the thread name visible to a debugger. This has no effect otherwise.
|
||||
// To set the name of the current thread, pass PlatformThread::CurrentId() as
|
||||
// the thread_id parameter.
|
||||
static void SetName(int thread_id, const char* name);
|
||||
static void SetName(const char* name);
|
||||
|
||||
// Implement this interface to run code on a background thread. Your
|
||||
// ThreadMain method will be called on the newly created thread.
|
||||
|
@ -53,7 +53,7 @@ void PlatformThread::Sleep(int duration_ms) {
|
||||
}
|
||||
|
||||
// static
|
||||
void PlatformThread::SetName(int thread_id, const char* name) {
|
||||
void PlatformThread::SetName(const char* name) {
|
||||
// TODO(darin): implement me!
|
||||
}
|
||||
|
||||
|
@ -47,11 +47,11 @@ void PlatformThread::Sleep(int duration_ms) {
|
||||
}
|
||||
|
||||
// static
|
||||
void PlatformThread::SetName(int thread_id, const char* name) {
|
||||
void PlatformThread::SetName(const char* name) {
|
||||
THREADNAME_INFO info;
|
||||
info.dwType = 0x1000;
|
||||
info.szName = name;
|
||||
info.dwThreadID = thread_id;
|
||||
info.dwThreadID = CurrentId();
|
||||
info.dwFlags = 0;
|
||||
|
||||
__try {
|
||||
|
@ -123,7 +123,7 @@ void Thread::ThreadMain() {
|
||||
|
||||
// Complete the initialization of our Thread object.
|
||||
thread_id_ = PlatformThread::CurrentId();
|
||||
PlatformThread::SetName(thread_id_, name_.c_str());
|
||||
PlatformThread::SetName(name_.c_str());
|
||||
message_loop.set_thread_name(name_);
|
||||
message_loop_ = &message_loop;
|
||||
thread_created_ = true;
|
||||
|
@ -135,7 +135,7 @@ unsigned Watchdog::Run() {
|
||||
void Watchdog::SetThreadName() const {
|
||||
std::string name = StringPrintf("%s Watchdog",
|
||||
WideToASCII(thread_watched_name_).c_str());
|
||||
PlatformThread::SetName(thread_id_, name.c_str());
|
||||
PlatformThread::SetName(name.c_str());
|
||||
DLOG(INFO) << "Watchdog active: " << name;
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ int BrowserMain(CommandLine &parsed_command_line, int show_command,
|
||||
// defined roles (e.g. pre/post-profile startup, etc).
|
||||
|
||||
const char* main_thread_name = "Chrome_BrowserMain";
|
||||
PlatformThread::SetName(PlatformThread::CurrentId(), main_thread_name);
|
||||
PlatformThread::SetName(main_thread_name);
|
||||
MessageLoop::current()->set_thread_name(main_thread_name);
|
||||
bool already_running = CreateUniqueChromeEvent();
|
||||
|
||||
|
@ -54,7 +54,7 @@ unsigned DnsSlave::Run() {
|
||||
std::string name = StringPrintf(
|
||||
"dns_prefetcher_%d_of_%d", slave_index_ + 1, DnsMaster::kSlaveCountMax);
|
||||
DLOG(INFO) << "Now Running " << name;
|
||||
PlatformThread::SetName(PlatformThread::CurrentId(), name.c_str());
|
||||
PlatformThread::SetName(name.c_str());
|
||||
|
||||
while (master_->GetNextAssignment(&hostname_)) {
|
||||
BlockingDnsLookup();
|
||||
|
@ -48,7 +48,7 @@ int RendererMain(CommandLine &parsed_command_line, int show_command,
|
||||
StatsScope<StatsCounterTimer>
|
||||
startup_timer(chrome::Counters::renderer_main());
|
||||
|
||||
PlatformThread::SetName(PlatformThread::CurrentId(), "Chrome_RendererMain");
|
||||
PlatformThread::SetName("Chrome_RendererMain");
|
||||
|
||||
CoInitialize(NULL);
|
||||
|
||||
|
@ -11,7 +11,7 @@ int main(int argc, char **argv) {
|
||||
// the AtExitManager or else we will leak objects.
|
||||
base::AtExitManager at_exit_manager;
|
||||
|
||||
PlatformThread::SetName(PlatformThread::CurrentId(), "Tests_Main");
|
||||
PlatformThread::SetName("Tests_Main");
|
||||
return UITestSuite(argc, argv).Run();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user