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

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

Issue 10831037: Avoid potential conflicts leading to pending reboots while upgrading the me2me host: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 L"ChromotingElevatedController.ElevatedController"; 44 L"ChromotingElevatedController.ElevatedController";
45 45
46 // The COM elevation moniker for the Elevated Controller. 46 // The COM elevation moniker for the Elevated Controller.
47 const wchar_t kDaemonControllerElevationMoniker[] = 47 const wchar_t kDaemonControllerElevationMoniker[] =
48 L"Elevation:Administrator!new:" 48 L"Elevation:Administrator!new:"
49 L"ChromotingElevatedController.ElevatedController"; 49 L"ChromotingElevatedController.ElevatedController";
50 50
51 // Name of the Daemon Controller's worker thread. 51 // Name of the Daemon Controller's worker thread.
52 const char kDaemonControllerThreadName[] = "Daemon Controller thread"; 52 const char kDaemonControllerThreadName[] = "Daemon Controller thread";
53 53
54 // The maximum interval between showing UAC prompts. 54 // The maximum duration of keeping a reference to a privileged instance of
55 const int kUacTimeoutSec = 15 * 60; 55 // the Daemon Controller. This effectively reduces number of UAC prompts a user
56 // sees.
57 const int kPrivilegedTimeoutSec = 5 * 60;
58
59 // The maximum duration of keeping a reference to an unprivileged instance of
60 // the Daemon Controller. This interval should not be too long. If upgrade
61 // happens while there is a live reference to a Daemon Controller instance
62 // the old binary still can be used. So dropping the references often makes sure
63 // that the old binary will go away sooner.
64 const int kUnprivilegedTimeoutSec = 60;
Jamie 2012/07/26 19:40:59 Why keep a reference at all? Could we do this by s
alexeypa (please no reviews) 2012/07/26 20:37:27 It is an optimization t avoid launching a process
56 65
57 // A base::Thread implementation that initializes COM on the new thread. 66 // A base::Thread implementation that initializes COM on the new thread.
58 class ComThread : public base::Thread { 67 class ComThread : public base::Thread {
59 public: 68 public:
60 explicit ComThread(const char* name); 69 explicit ComThread(const char* name);
61 70
62 bool Start(); 71 bool Start();
63 72
64 protected: 73 protected:
65 virtual void Init() OVERRIDE; 74 virtual void Init() OVERRIDE;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } 298 }
290 299
291 hr = CoCreateInstance(class_id, NULL, CLSCTX_LOCAL_SERVER, 300 hr = CoCreateInstance(class_id, NULL, CLSCTX_LOCAL_SERVER,
292 IID_IDaemonControl, control_.ReceiveVoid()); 301 IID_IDaemonControl, control_.ReceiveVoid());
293 if (FAILED(hr)) { 302 if (FAILED(hr)) {
294 return hr; 303 return hr;
295 } 304 }
296 305
297 // Ignore the error. IID_IDaemonControl2 is optional. 306 // Ignore the error. IID_IDaemonControl2 is optional.
298 control_.QueryInterface(IID_IDaemonControl2, control2_.ReceiveVoid()); 307 control_.QueryInterface(IID_IDaemonControl2, control2_.ReceiveVoid());
308
309 // Release |control_| upon expiration of the timeout.
310 release_timer_.reset(new base::OneShotTimer<DaemonControllerWin>());
311 release_timer_->Start(FROM_HERE,
312 base::TimeDelta::FromSeconds(kUnprivilegedTimeoutSec),
313 this,
314 &DaemonControllerWin::ReleaseController);
299 } 315 }
300 316
301 return S_OK; 317 return S_OK;
302 } 318 }
303 319
304 HRESULT DaemonControllerWin::ActivateElevatedController() { 320 HRESULT DaemonControllerWin::ActivateElevatedController() {
305 DCHECK(worker_thread_.message_loop_proxy()->BelongsToCurrentThread()); 321 DCHECK(worker_thread_.message_loop_proxy()->BelongsToCurrentThread());
306 322
307 // The COM elevation is supported on Vista and above. 323 // The COM elevation is supported on Vista and above.
308 if (base::win::GetVersion() < base::win::VERSION_VISTA) { 324 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
(...skipping 23 matching lines...) Expand all
332 348
333 // Ignore the error. IID_IDaemonControl2 is optional. 349 // Ignore the error. IID_IDaemonControl2 is optional.
334 control_.QueryInterface(IID_IDaemonControl2, control2_.ReceiveVoid()); 350 control_.QueryInterface(IID_IDaemonControl2, control2_.ReceiveVoid());
335 351
336 // Note that we hold a reference to an elevated instance now. 352 // Note that we hold a reference to an elevated instance now.
337 control_is_elevated_ = true; 353 control_is_elevated_ = true;
338 354
339 // Release |control_| upon expiration of the timeout. 355 // Release |control_| upon expiration of the timeout.
340 release_timer_.reset(new base::OneShotTimer<DaemonControllerWin>()); 356 release_timer_.reset(new base::OneShotTimer<DaemonControllerWin>());
341 release_timer_->Start(FROM_HERE, 357 release_timer_->Start(FROM_HERE,
342 base::TimeDelta::FromSeconds(kUacTimeoutSec), 358 base::TimeDelta::FromSeconds(kPrivilegedTimeoutSec),
343 this, 359 this,
344 &DaemonControllerWin::ReleaseController); 360 &DaemonControllerWin::ReleaseController);
345 } 361 }
346 362
347 return S_OK; 363 return S_OK;
348 } 364 }
349 365
350 void DaemonControllerWin::ReleaseController() { 366 void DaemonControllerWin::ReleaseController() {
351 DCHECK(worker_thread_.message_loop_proxy()->BelongsToCurrentThread()); 367 DCHECK(worker_thread_.message_loop_proxy()->BelongsToCurrentThread());
352 368
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 done.Run(true, !!allowed, !!set_by_policy); 689 done.Run(true, !!allowed, !!set_by_policy);
674 } 690 }
675 691
676 } // namespace 692 } // namespace
677 693
678 scoped_ptr<DaemonController> remoting::DaemonController::Create() { 694 scoped_ptr<DaemonController> remoting::DaemonController::Create() {
679 return scoped_ptr<DaemonController>(new DaemonControllerWin()); 695 return scoped_ptr<DaemonController>(new DaemonControllerWin());
680 } 696 }
681 697
682 } // namespace remoting 698 } // namespace remoting
OLDNEW
« remoting/host/installer/chromoting.wxs ('K') | « remoting/host/installer/chromoting.wxs ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698