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

Side by Side Diff: remoting/host/plugin/daemon_controller_win.cc

Issue 10103010: [Chromoting] Implement UpdateConfig() for the Windows host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync. Created 8 years, 8 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 | « remoting/host/elevated_controller_win.cc ('k') | remoting/host/remoting_me2me_host.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/host/plugin/daemon_controller.h" 5 #include "remoting/host/plugin/daemon_controller.h"
6 6
7 #include <objbase.h> 7 #include <objbase.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Opens the Chromoting service returning its handle in |service_out|. 95 // Opens the Chromoting service returning its handle in |service_out|.
96 DWORD OpenService(ScopedScHandle* service_out); 96 DWORD OpenService(ScopedScHandle* service_out);
97 97
98 // The functions that actually do the work. They should be called in 98 // The functions that actually do the work. They should be called in
99 // the context of |worker_thread_|; 99 // the context of |worker_thread_|;
100 void DoGetConfig(const GetConfigCallback& callback); 100 void DoGetConfig(const GetConfigCallback& callback);
101 void DoInstallAsNeededAndStart(scoped_ptr<base::DictionaryValue> config, 101 void DoInstallAsNeededAndStart(scoped_ptr<base::DictionaryValue> config,
102 const CompletionCallback& done_callback); 102 const CompletionCallback& done_callback);
103 void DoSetConfigAndStart(scoped_ptr<base::DictionaryValue> config, 103 void DoSetConfigAndStart(scoped_ptr<base::DictionaryValue> config,
104 const CompletionCallback& done_callback); 104 const CompletionCallback& done_callback);
105 void DoUpdateConfig(scoped_ptr<base::DictionaryValue> config,
106 const CompletionCallback& done_callback);
105 void DoStop(const CompletionCallback& done_callback); 107 void DoStop(const CompletionCallback& done_callback);
106 108
107 // The worker thread used for servicing long running operations. 109 // The worker thread used for servicing long running operations.
108 ComThread worker_thread_; 110 ComThread worker_thread_;
109 111
110 scoped_ptr<DaemonInstallerWin> installer_; 112 scoped_ptr<DaemonInstallerWin> installer_;
111 113
112 DISALLOW_COPY_AND_ASSIGN(DaemonControllerWin); 114 DISALLOW_COPY_AND_ASSIGN(DaemonControllerWin);
113 }; 115 };
114 116
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 void DaemonControllerWin::GetConfig(const GetConfigCallback& callback) { 197 void DaemonControllerWin::GetConfig(const GetConfigCallback& callback) {
196 worker_thread_.message_loop_proxy()->PostTask( 198 worker_thread_.message_loop_proxy()->PostTask(
197 FROM_HERE, 199 FROM_HERE,
198 base::Bind(&DaemonControllerWin::DoGetConfig, 200 base::Bind(&DaemonControllerWin::DoGetConfig,
199 base::Unretained(this), callback)); 201 base::Unretained(this), callback));
200 } 202 }
201 203
202 void DaemonControllerWin::SetConfigAndStart( 204 void DaemonControllerWin::SetConfigAndStart(
203 scoped_ptr<base::DictionaryValue> config, 205 scoped_ptr<base::DictionaryValue> config,
204 const CompletionCallback& done_callback) { 206 const CompletionCallback& done_callback) {
205
206 worker_thread_.message_loop_proxy()->PostTask( 207 worker_thread_.message_loop_proxy()->PostTask(
207 FROM_HERE, base::Bind( 208 FROM_HERE, base::Bind(
208 &DaemonControllerWin::DoInstallAsNeededAndStart, 209 &DaemonControllerWin::DoInstallAsNeededAndStart,
209 base::Unretained(this), base::Passed(&config), done_callback)); 210 base::Unretained(this), base::Passed(&config), done_callback));
210 } 211 }
211 212
212 void DaemonControllerWin::UpdateConfig( 213 void DaemonControllerWin::UpdateConfig(
213 scoped_ptr<base::DictionaryValue> config, 214 scoped_ptr<base::DictionaryValue> config,
214 const CompletionCallback& done_callback) { 215 const CompletionCallback& done_callback) {
215 NOTIMPLEMENTED(); 216 worker_thread_.message_loop_proxy()->PostTask(
216 done_callback.Run(RESULT_FAILED); 217 FROM_HERE, base::Bind(
218 &DaemonControllerWin::DoUpdateConfig,
219 base::Unretained(this), base::Passed(&config), done_callback));
217 } 220 }
218 221
219 void DaemonControllerWin::Stop(const CompletionCallback& done_callback) { 222 void DaemonControllerWin::Stop(const CompletionCallback& done_callback) {
220 worker_thread_.message_loop_proxy()->PostTask( 223 worker_thread_.message_loop_proxy()->PostTask(
221 FROM_HERE, base::Bind( 224 FROM_HERE, base::Bind(
222 &DaemonControllerWin::DoStop, base::Unretained(this), 225 &DaemonControllerWin::DoStop, base::Unretained(this),
223 done_callback)); 226 done_callback));
224 } 227 }
225 228
226 // static 229 // static
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (FAILED(hr)) { 401 if (FAILED(hr)) {
399 done_callback.Run(HResultToAsyncResult(hr)); 402 done_callback.Run(HResultToAsyncResult(hr));
400 return; 403 return;
401 } 404 }
402 405
403 // Start daemon. 406 // Start daemon.
404 hr = control->StartDaemon(); 407 hr = control->StartDaemon();
405 done_callback.Run(HResultToAsyncResult(hr)); 408 done_callback.Run(HResultToAsyncResult(hr));
406 } 409 }
407 410
411 void DaemonControllerWin::DoUpdateConfig(
412 scoped_ptr<base::DictionaryValue> config,
413 const CompletionCallback& done_callback) {
414 // TODO(simonmorris): Much of this code was copied from DoSetConfigAndStart().
415 // Refactor.
416 DCHECK(worker_thread_.message_loop_proxy()->BelongsToCurrentThread());
417
418 IDaemonControl* control = NULL;
419 HRESULT hr = worker_thread_.ActivateElevatedController(&control);
420 if (FAILED(hr)) {
421 done_callback.Run(HResultToAsyncResult(hr));
422 return;
423 }
424
425 // Store the configuration.
426 std::string file_content;
427 base::JSONWriter::Write(config.get(), &file_content);
428
429 ScopedBstr host_config(UTF8ToUTF16(file_content).c_str());
430 if (host_config == NULL) {
431 done_callback.Run(HResultToAsyncResult(E_OUTOFMEMORY));
432 return;
433 }
434
435 hr = control->UpdateConfig(host_config);
436 done_callback.Run(HResultToAsyncResult(hr));
437 }
438
408 void DaemonControllerWin::DoStop(const CompletionCallback& done_callback) { 439 void DaemonControllerWin::DoStop(const CompletionCallback& done_callback) {
409 DCHECK(worker_thread_.message_loop_proxy()->BelongsToCurrentThread()); 440 DCHECK(worker_thread_.message_loop_proxy()->BelongsToCurrentThread());
410 441
411 IDaemonControl* control = NULL; 442 IDaemonControl* control = NULL;
412 HRESULT hr = worker_thread_.ActivateElevatedController(&control); 443 HRESULT hr = worker_thread_.ActivateElevatedController(&control);
413 if (FAILED(hr)) { 444 if (FAILED(hr)) {
414 done_callback.Run(HResultToAsyncResult(hr)); 445 done_callback.Run(HResultToAsyncResult(hr));
415 return; 446 return;
416 } 447 }
417 448
418 hr = control->StopDaemon(); 449 hr = control->StopDaemon();
419 done_callback.Run(HResultToAsyncResult(hr)); 450 done_callback.Run(HResultToAsyncResult(hr));
420 } 451 }
421 452
422 } // namespace 453 } // namespace
423 454
424 scoped_ptr<DaemonController> remoting::DaemonController::Create() { 455 scoped_ptr<DaemonController> remoting::DaemonController::Create() {
425 return scoped_ptr<DaemonController>(new DaemonControllerWin()); 456 return scoped_ptr<DaemonController>(new DaemonControllerWin());
426 } 457 }
427 458
428 } // namespace remoting 459 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/elevated_controller_win.cc ('k') | remoting/host/remoting_me2me_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698