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

Side by Side Diff: remoting/base/auto_thread.cc

Issue 15782010: Update remoting/ and jingle/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | « jingle/glue/pseudotcp_adapter_unittest.cc ('k') | remoting/base/compound_buffer.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/base/auto_thread.h" 5 #include "remoting/base/auto_thread.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
10 #include "base/threading/thread_local.h" 10 #include "base/threading/thread_local.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 explicit StartupData(base::MessageLoop::Type type) 51 explicit StartupData(base::MessageLoop::Type type)
52 : loop_type(type), event(false, false) {} 52 : loop_type(type), event(false, false) {}
53 }; 53 };
54 54
55 // static 55 // static
56 scoped_refptr<AutoThreadTaskRunner> AutoThread::CreateWithType( 56 scoped_refptr<AutoThreadTaskRunner> AutoThread::CreateWithType(
57 const char* name, 57 const char* name,
58 scoped_refptr<AutoThreadTaskRunner> joiner, 58 scoped_refptr<AutoThreadTaskRunner> joiner,
59 base::MessageLoop::Type type) { 59 base::MessageLoop::Type type) {
60 AutoThread* thread = new AutoThread(name, joiner); 60 AutoThread* thread = new AutoThread(name, joiner.get());
61 scoped_refptr<AutoThreadTaskRunner> task_runner = thread->StartWithType(type); 61 scoped_refptr<AutoThreadTaskRunner> task_runner = thread->StartWithType(type);
62 if (!task_runner) 62 if (!task_runner.get())
63 delete thread; 63 delete thread;
64 return task_runner; 64 return task_runner;
65 } 65 }
66 66
67 // static 67 // static
68 scoped_refptr<AutoThreadTaskRunner> AutoThread::Create( 68 scoped_refptr<AutoThreadTaskRunner> AutoThread::Create(
69 const char* name, scoped_refptr<AutoThreadTaskRunner> joiner) { 69 const char* name, scoped_refptr<AutoThreadTaskRunner> joiner) {
70 return CreateWithType(name, joiner, base::MessageLoop::TYPE_DEFAULT); 70 return CreateWithType(name, joiner, base::MessageLoop::TYPE_DEFAULT);
71 } 71 }
72 72
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (!task_runner->BelongsToCurrentThread()) { 160 if (!task_runner->BelongsToCurrentThread()) {
161 task_runner->PostTask(FROM_HERE, base::Bind(&AutoThread::QuitThread, 161 task_runner->PostTask(FROM_HERE, base::Bind(&AutoThread::QuitThread,
162 base::Unretained(this), 162 base::Unretained(this),
163 task_runner)); 163 task_runner));
164 return; 164 return;
165 } 165 }
166 166
167 base::MessageLoop::current()->Quit(); 167 base::MessageLoop::current()->Quit();
168 was_quit_properly_ = true; 168 was_quit_properly_ = true;
169 169
170 if (joiner_) { 170 if (joiner_.get()) {
171 joiner_->PostTask(FROM_HERE, base::Bind(&AutoThread::JoinAndDeleteThread, 171 joiner_->PostTask(
172 base::Unretained(this))); 172 FROM_HERE,
173 base::Bind(&AutoThread::JoinAndDeleteThread, base::Unretained(this)));
173 } 174 }
174 } 175 }
175 176
176 void AutoThread::JoinAndDeleteThread() { 177 void AutoThread::JoinAndDeleteThread() {
177 delete this; 178 delete this;
178 } 179 }
179 180
180 void AutoThread::ThreadMain() { 181 void AutoThread::ThreadMain() {
181 // The message loop for this thread. 182 // The message loop for this thread.
182 base::MessageLoop message_loop(startup_data_->loop_type); 183 base::MessageLoop message_loop(startup_data_->loop_type);
(...skipping 21 matching lines...) Expand all
204 CreateComInitializer(com_init_type_)); 205 CreateComInitializer(com_init_type_));
205 #endif 206 #endif
206 207
207 message_loop.Run(); 208 message_loop.Run();
208 209
209 // Assert that MessageLoop::Quit was called by AutoThread::QuitThread. 210 // Assert that MessageLoop::Quit was called by AutoThread::QuitThread.
210 DCHECK(was_quit_properly_); 211 DCHECK(was_quit_properly_);
211 } 212 }
212 213
213 } // namespace base 214 } // namespace base
OLDNEW
« no previous file with comments | « jingle/glue/pseudotcp_adapter_unittest.cc ('k') | remoting/base/compound_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698