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

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

Issue 12741012: base: Support setting thread priorities generically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove static initializers. Created 7 years, 7 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
« no previous file with comments | « media/filters/video_renderer_base.cc ('k') | 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) 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 delete thread; 85 delete thread;
86 return task_runner; 86 return task_runner;
87 } 87 }
88 #endif 88 #endif
89 89
90 AutoThread::AutoThread(const char* name) 90 AutoThread::AutoThread(const char* name)
91 : startup_data_(NULL), 91 : startup_data_(NULL),
92 #if defined(OS_WIN) 92 #if defined(OS_WIN)
93 com_init_type_(COM_INIT_NONE), 93 com_init_type_(COM_INIT_NONE),
94 #endif 94 #endif
95 thread_(0), 95 thread_(),
96 name_(name), 96 name_(name),
97 was_quit_properly_(false) { 97 was_quit_properly_(false) {
98 } 98 }
99 99
100 AutoThread::AutoThread(const char* name, AutoThreadTaskRunner* joiner) 100 AutoThread::AutoThread(const char* name, AutoThreadTaskRunner* joiner)
101 : startup_data_(NULL), 101 : startup_data_(NULL),
102 #if defined(OS_WIN) 102 #if defined(OS_WIN)
103 com_init_type_(COM_INIT_NONE), 103 com_init_type_(COM_INIT_NONE),
104 #endif 104 #endif
105 thread_(0), 105 thread_(),
106 name_(name), 106 name_(name),
107 was_quit_properly_(false), 107 was_quit_properly_(false),
108 joiner_(joiner) { 108 joiner_(joiner) {
109 } 109 }
110 110
111 AutoThread::~AutoThread() { 111 AutoThread::~AutoThread() {
112 DCHECK(!startup_data_); 112 DCHECK(!startup_data_);
113 113
114 // Wait for the thread to exit. 114 // Wait for the thread to exit.
115 if (thread_) { 115 if (!thread_.is_null()) {
116 base::PlatformThread::Join(thread_); 116 base::PlatformThread::Join(thread_);
117 } 117 }
118 } 118 }
119 119
120 scoped_refptr<AutoThreadTaskRunner> AutoThread::StartWithType( 120 scoped_refptr<AutoThreadTaskRunner> AutoThread::StartWithType(
121 base::MessageLoop::Type type) { 121 base::MessageLoop::Type type) {
122 DCHECK(!thread_); 122 DCHECK(thread_.is_null());
123 #if defined(OS_WIN) 123 #if defined(OS_WIN)
124 DCHECK(com_init_type_ != COM_INIT_STA || type == base::MessageLoop::TYPE_UI); 124 DCHECK(com_init_type_ != COM_INIT_STA || type == base::MessageLoop::TYPE_UI);
125 #endif 125 #endif
126 126
127 StartupData startup_data(type); 127 StartupData startup_data(type);
128 startup_data_ = &startup_data; 128 startup_data_ = &startup_data;
129 129
130 if (!base::PlatformThread::Create(0, this, &thread_)) { 130 if (!base::PlatformThread::Create(0, this, &thread_)) {
131 DLOG(ERROR) << "failed to create thread"; 131 DLOG(ERROR) << "failed to create thread";
132 startup_data_ = NULL; 132 startup_data_ = NULL;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 CreateComInitializer(com_init_type_)); 204 CreateComInitializer(com_init_type_));
205 #endif 205 #endif
206 206
207 message_loop.Run(); 207 message_loop.Run();
208 208
209 // Assert that MessageLoop::Quit was called by AutoThread::QuitThread. 209 // Assert that MessageLoop::Quit was called by AutoThread::QuitThread.
210 DCHECK(was_quit_properly_); 210 DCHECK(was_quit_properly_);
211 } 211 }
212 212
213 } // namespace base 213 } // namespace base
OLDNEW
« no previous file with comments | « media/filters/video_renderer_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698