diff options
author | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-25 13:54:18 +0000 |
---|---|---|
committer | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-25 13:54:18 +0000 |
commit | 7d0f9445f4ffb50dc1d72bc2f5ce329ccfec7cad (patch) | |
tree | 668755bb0e584a311f5c22e24f1c48e0e47d0c56 | |
parent | 302bdc13a9baebb21894673e7674f4e0361cfe97 (diff) | |
download | chromium_src-7d0f9445f4ffb50dc1d72bc2f5ce329ccfec7cad.zip chromium_src-7d0f9445f4ffb50dc1d72bc2f5ce329ccfec7cad.tar.gz chromium_src-7d0f9445f4ffb50dc1d72bc2f5ce329ccfec7cad.tar.bz2 |
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
-rw-r--r-- | base/platform_thread.h | 8 | ||||
-rw-r--r-- | base/platform_thread_posix.cc | 2 | ||||
-rw-r--r-- | base/platform_thread_win.cc | 4 | ||||
-rw-r--r-- | base/thread.cc | 2 | ||||
-rw-r--r-- | base/watchdog.cc | 2 | ||||
-rw-r--r-- | chrome/browser/browser_main.cc | 2 | ||||
-rw-r--r-- | chrome/browser/net/dns_slave.cc | 2 | ||||
-rw-r--r-- | chrome/renderer/renderer_main.cc | 2 | ||||
-rw-r--r-- | chrome/test/ui/run_all_unittests.cc | 2 |
9 files changed, 14 insertions, 12 deletions
diff --git a/base/platform_thread.h b/base/platform_thread.h index edb2ddc..a999e8d 100644 --- a/base/platform_thread.h +++ b/base/platform_thread.h @@ -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. diff --git a/base/platform_thread_posix.cc b/base/platform_thread_posix.cc index 79e17f3..9d65264 100644 --- a/base/platform_thread_posix.cc +++ b/base/platform_thread_posix.cc @@ -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! } diff --git a/base/platform_thread_win.cc b/base/platform_thread_win.cc index 7b62d8e..00efdc1 100644 --- a/base/platform_thread_win.cc +++ b/base/platform_thread_win.cc @@ -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 { diff --git a/base/thread.cc b/base/thread.cc index a4798e0..0fe023a 100644 --- a/base/thread.cc +++ b/base/thread.cc @@ -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; diff --git a/base/watchdog.cc b/base/watchdog.cc index 96dd9b9..06ab871 100644 --- a/base/watchdog.cc +++ b/base/watchdog.cc @@ -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; } diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 8cf86fd7..b3357f0 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -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(); diff --git a/chrome/browser/net/dns_slave.cc b/chrome/browser/net/dns_slave.cc index 95acbee..82406af 100644 --- a/chrome/browser/net/dns_slave.cc +++ b/chrome/browser/net/dns_slave.cc @@ -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(); diff --git a/chrome/renderer/renderer_main.cc b/chrome/renderer/renderer_main.cc index 6b472a6..59c4003 100644 --- a/chrome/renderer/renderer_main.cc +++ b/chrome/renderer/renderer_main.cc @@ -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); diff --git a/chrome/test/ui/run_all_unittests.cc b/chrome/test/ui/run_all_unittests.cc index 5c60d57..f4c0116 100644 --- a/chrome/test/ui/run_all_unittests.cc +++ b/chrome/test/ui/run_all_unittests.cc @@ -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(); } |