OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/host/setup/daemon_controller.h" | 5 #include "remoting/host/setup/daemon_controller.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/location.h" | 10 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
10 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
11 #include "base/values.h" | 13 #include "base/values.h" |
12 #include "build/build_config.h" | 14 #include "build/build_config.h" |
13 #include "remoting/base/auto_thread.h" | 15 #include "remoting/base/auto_thread.h" |
14 #include "remoting/base/auto_thread_task_runner.h" | 16 #include "remoting/base/auto_thread_task_runner.h" |
15 | 17 |
16 namespace remoting { | 18 namespace remoting { |
17 | 19 |
18 // Name of the Daemon Controller's worker thread. | 20 // Name of the Daemon Controller's worker thread. |
19 const char kDaemonControllerThreadName[] = "Daemon Controller thread"; | 21 const char kDaemonControllerThreadName[] = "Daemon Controller thread"; |
20 | 22 |
21 DaemonController::DaemonController(scoped_ptr<Delegate> delegate) | 23 DaemonController::DaemonController(scoped_ptr<Delegate> delegate) |
22 : caller_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 24 : caller_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
23 delegate_(delegate.Pass()) { | 25 delegate_(std::move(delegate)) { |
24 // Launch the delegate thread. | 26 // Launch the delegate thread. |
25 delegate_thread_.reset(new AutoThread(kDaemonControllerThreadName)); | 27 delegate_thread_.reset(new AutoThread(kDaemonControllerThreadName)); |
26 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
27 delegate_thread_->SetComInitType(AutoThread::COM_INIT_STA); | 29 delegate_thread_->SetComInitType(AutoThread::COM_INIT_STA); |
28 delegate_task_runner_ = | 30 delegate_task_runner_ = |
29 delegate_thread_->StartWithType(base::MessageLoop::TYPE_UI); | 31 delegate_thread_->StartWithType(base::MessageLoop::TYPE_UI); |
30 #else | 32 #else |
31 delegate_task_runner_ = | 33 delegate_task_runner_ = |
32 delegate_thread_->StartWithType(base::MessageLoop::TYPE_DEFAULT); | 34 delegate_thread_->StartWithType(base::MessageLoop::TYPE_DEFAULT); |
33 #endif | 35 #endif |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 caller_task_runner_->PostTask(FROM_HERE, | 113 caller_task_runner_->PostTask(FROM_HERE, |
112 base::Bind(done, base::Passed(&config))); | 114 base::Bind(done, base::Passed(&config))); |
113 } | 115 } |
114 | 116 |
115 void DaemonController::DoSetConfigAndStart( | 117 void DaemonController::DoSetConfigAndStart( |
116 scoped_ptr<base::DictionaryValue> config, | 118 scoped_ptr<base::DictionaryValue> config, |
117 bool consent, | 119 bool consent, |
118 const CompletionCallback& done) { | 120 const CompletionCallback& done) { |
119 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); | 121 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); |
120 | 122 |
121 delegate_->SetConfigAndStart(config.Pass(), consent, done); | 123 delegate_->SetConfigAndStart(std::move(config), consent, done); |
122 } | 124 } |
123 | 125 |
124 void DaemonController::DoUpdateConfig( | 126 void DaemonController::DoUpdateConfig( |
125 scoped_ptr<base::DictionaryValue> config, | 127 scoped_ptr<base::DictionaryValue> config, |
126 const CompletionCallback& done) { | 128 const CompletionCallback& done) { |
127 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); | 129 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); |
128 | 130 |
129 delegate_->UpdateConfig(config.Pass(), done); | 131 delegate_->UpdateConfig(std::move(config), done); |
130 } | 132 } |
131 | 133 |
132 void DaemonController::DoStop(const CompletionCallback& done) { | 134 void DaemonController::DoStop(const CompletionCallback& done) { |
133 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); | 135 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); |
134 | 136 |
135 delegate_->Stop(done); | 137 delegate_->Stop(done); |
136 } | 138 } |
137 | 139 |
138 void DaemonController::DoGetUsageStatsConsent( | 140 void DaemonController::DoGetUsageStatsConsent( |
139 const GetUsageStatsConsentCallback& done) { | 141 const GetUsageStatsConsentCallback& done) { |
(...skipping 17 matching lines...) Expand all Loading... |
157 | 159 |
158 done.Run(result); | 160 done.Run(result); |
159 ScheduleNext(); | 161 ScheduleNext(); |
160 } | 162 } |
161 | 163 |
162 void DaemonController::InvokeConfigCallbackAndScheduleNext( | 164 void DaemonController::InvokeConfigCallbackAndScheduleNext( |
163 const GetConfigCallback& done, | 165 const GetConfigCallback& done, |
164 scoped_ptr<base::DictionaryValue> config) { | 166 scoped_ptr<base::DictionaryValue> config) { |
165 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 167 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
166 | 168 |
167 done.Run(config.Pass()); | 169 done.Run(std::move(config)); |
168 ScheduleNext(); | 170 ScheduleNext(); |
169 } | 171 } |
170 | 172 |
171 void DaemonController::InvokeConsentCallbackAndScheduleNext( | 173 void DaemonController::InvokeConsentCallbackAndScheduleNext( |
172 const GetUsageStatsConsentCallback& done, | 174 const GetUsageStatsConsentCallback& done, |
173 const UsageStatsConsent& consent) { | 175 const UsageStatsConsent& consent) { |
174 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 176 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
175 | 177 |
176 done.Run(consent); | 178 done.Run(consent); |
177 ScheduleNext(); | 179 ScheduleNext(); |
(...skipping 12 matching lines...) Expand all Loading... |
190 if (!servicing_request) | 192 if (!servicing_request) |
191 ServiceNextRequest(); | 193 ServiceNextRequest(); |
192 } | 194 } |
193 | 195 |
194 void DaemonController::ServiceNextRequest() { | 196 void DaemonController::ServiceNextRequest() { |
195 if (!pending_requests_.empty()) | 197 if (!pending_requests_.empty()) |
196 delegate_task_runner_->PostTask(FROM_HERE, pending_requests_.front()); | 198 delegate_task_runner_->PostTask(FROM_HERE, pending_requests_.front()); |
197 } | 199 } |
198 | 200 |
199 } // namespace remoting | 201 } // namespace remoting |
OLD | NEW |