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

Side by Side Diff: base/thread.cc

Issue 199065: Revert r25770 due to valgrind failures on Linux. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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 | « base/thread.h ('k') | chrome/browser/history/history.cc » ('j') | 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/string_util.h" 8 #include "base/string_util.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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 DCHECK_NE(thread_id_, PlatformThread::CurrentId()); 128 DCHECK_NE(thread_id_, PlatformThread::CurrentId());
129 129
130 // We had better have a message loop at this point! If we do not, then it 130 // We had better have a message loop at this point! If we do not, then it
131 // most likely means that the thread terminated unexpectedly, probably due 131 // most likely means that the thread terminated unexpectedly, probably due
132 // to someone calling Quit() on our message loop directly. 132 // to someone calling Quit() on our message loop directly.
133 DCHECK(message_loop_); 133 DCHECK(message_loop_);
134 134
135 message_loop_->PostTask(FROM_HERE, new ThreadQuitTask()); 135 message_loop_->PostTask(FROM_HERE, new ThreadQuitTask());
136 } 136 }
137 137
138 void Thread::Run(MessageLoop* message_loop) {
139 message_loop->Run();
140 }
141
142 void Thread::ThreadMain() { 138 void Thread::ThreadMain() {
143 // The message loop for this thread. 139 // The message loop for this thread.
144 MessageLoop message_loop(startup_data_->options.message_loop_type); 140 MessageLoop message_loop(startup_data_->options.message_loop_type);
145 141
146 // Complete the initialization of our Thread object. 142 // Complete the initialization of our Thread object.
147 thread_id_ = PlatformThread::CurrentId(); 143 thread_id_ = PlatformThread::CurrentId();
148 PlatformThread::SetName(name_.c_str()); 144 PlatformThread::SetName(name_.c_str());
149 message_loop.set_thread_name(name_); 145 message_loop.set_thread_name(name_);
150 message_loop_ = &message_loop; 146 message_loop_ = &message_loop;
151 147
152 // Let the thread do extra initialization. 148 // Let the thread do extra initialization.
153 // Let's do this before signaling we are started. 149 // Let's do this before signaling we are started.
154 Init(); 150 Init();
155 151
156 startup_data_->event.Signal(); 152 startup_data_->event.Signal();
157 // startup_data_ can't be touched anymore since the starting thread is now 153 // startup_data_ can't be touched anymore since the starting thread is now
158 // unlocked. 154 // unlocked.
159 155
160 Run(message_loop_); 156 message_loop.Run();
161 157
162 // Let the thread do extra cleanup. 158 // Let the thread do extra cleanup.
163 CleanUp(); 159 CleanUp();
164 160
165 // Assert that MessageLoop::Quit was called by ThreadQuitTask. 161 // Assert that MessageLoop::Quit was called by ThreadQuitTask.
166 DCHECK(GetThreadWasQuitProperly()); 162 DCHECK(GetThreadWasQuitProperly());
167 163
168 // We can't receive messages anymore. 164 // We can't receive messages anymore.
169 message_loop_ = NULL; 165 message_loop_ = NULL;
170 thread_id_ = 0; 166 thread_id_ = 0;
171 } 167 }
172 168
173 } // namespace base 169 } // namespace base
OLDNEW
« no previous file with comments | « base/thread.h ('k') | chrome/browser/history/history.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698