Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: base/thread.cc

Issue 3322020: Revert 58786 - Adding debugging info for thread name.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/thread.h" 5 #include "base/thread.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 8 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
9 #include "base/thread_local.h" 9 #include "base/thread_local.h"
10 #include "base/waitable_event.h" 10 #include "base/waitable_event.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // with ThreadMain, so we annotate it to stay silent under ThreadSanitizer. 129 // with ThreadMain, so we annotate it to stay silent under ThreadSanitizer.
130 DCHECK_NE(ANNOTATE_UNPROTECTED_READ(thread_id_), PlatformThread::CurrentId()); 130 DCHECK_NE(ANNOTATE_UNPROTECTED_READ(thread_id_), PlatformThread::CurrentId());
131 131
132 if (stopping_ || !message_loop_) 132 if (stopping_ || !message_loop_)
133 return; 133 return;
134 134
135 stopping_ = true; 135 stopping_ = true;
136 message_loop_->PostTask(FROM_HERE, new ThreadQuitTask()); 136 message_loop_->PostTask(FROM_HERE, new ThreadQuitTask());
137 } 137 }
138 138
139 #if defined(OS_WIN)
140 #pragma warning (disable: 4748)
141 #pragma optimize( "", off )
142 #endif
143
144 void Thread::Run(MessageLoop* message_loop) { 139 void Thread::Run(MessageLoop* message_loop) {
145 #if defined(OS_WIN)
146 // Logging the thread name for debugging.
147 // TODO(huanr): remove after done.
148 // http://code.google.com/p/chromium/issues/detail?id=54307
149 char name[16];
150 strncpy(name, name_.c_str(), arraysize(name) - 1);
151 name[arraysize(name) - 1] = '\0';
152 #endif
153 message_loop->Run(); 140 message_loop->Run();
154 } 141 }
155 142
156 #if defined(OS_WIN)
157 #pragma optimize( "", on )
158 #pragma warning (default: 4748)
159 #endif
160
161 void Thread::ThreadMain() { 143 void Thread::ThreadMain() {
162 { 144 {
163 // The message loop for this thread. 145 // The message loop for this thread.
164 MessageLoop message_loop(startup_data_->options.message_loop_type); 146 MessageLoop message_loop(startup_data_->options.message_loop_type);
165 147
166 // Complete the initialization of our Thread object. 148 // Complete the initialization of our Thread object.
167 thread_id_ = PlatformThread::CurrentId(); 149 thread_id_ = PlatformThread::CurrentId();
168 PlatformThread::SetName(name_.c_str()); 150 PlatformThread::SetName(name_.c_str());
169 ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. 151 ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector.
170 message_loop.set_thread_name(name_); 152 message_loop.set_thread_name(name_);
(...skipping 18 matching lines...) Expand all
189 171
190 // We can't receive messages anymore. 172 // We can't receive messages anymore.
191 message_loop_ = NULL; 173 message_loop_ = NULL;
192 message_loop_proxy_ = NULL; 174 message_loop_proxy_ = NULL;
193 } 175 }
194 CleanUpAfterMessageLoopDestruction(); 176 CleanUpAfterMessageLoopDestruction();
195 thread_id_ = 0; 177 thread_id_ = 0;
196 } 178 }
197 179
198 } // namespace base 180 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698