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

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

Issue 10828203: Reverting r148671, r149866 (broke VS2008 builder) and r150361 (broke ninja). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Let's try GYP r1446. 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
« no previous file with comments | « DEPS ('k') | remoting/host/win/chromoting.wxs » ('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 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 duration of keeping a reference to a privileged instance of 54 // The maximum interval between showing UAC prompts.
55 // the Daemon Controller. This effectively reduces number of UAC prompts a user 55 const int kUacTimeoutSec = 15 * 60;
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;
65 56
66 // A base::Thread implementation that initializes COM on the new thread. 57 // A base::Thread implementation that initializes COM on the new thread.
67 class ComThread : public base::Thread { 58 class ComThread : public base::Thread {
68 public: 59 public:
69 explicit ComThread(const char* name); 60 explicit ComThread(const char* name);
70 61
71 bool Start(); 62 bool Start();
72 63
73 protected: 64 protected:
74 virtual void Init() OVERRIDE; 65 virtual void Init() OVERRIDE;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 289 }
299 290
300 hr = CoCreateInstance(class_id, NULL, CLSCTX_LOCAL_SERVER, 291 hr = CoCreateInstance(class_id, NULL, CLSCTX_LOCAL_SERVER,
301 IID_IDaemonControl, control_.ReceiveVoid()); 292 IID_IDaemonControl, control_.ReceiveVoid());
302 if (FAILED(hr)) { 293 if (FAILED(hr)) {
303 return hr; 294 return hr;
304 } 295 }
305 296
306 // Ignore the error. IID_IDaemonControl2 is optional. 297 // Ignore the error. IID_IDaemonControl2 is optional.
307 control_.QueryInterface(IID_IDaemonControl2, control2_.ReceiveVoid()); 298 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);
315 } 299 }
316 300
317 return S_OK; 301 return S_OK;
318 } 302 }
319 303
320 HRESULT DaemonControllerWin::ActivateElevatedController() { 304 HRESULT DaemonControllerWin::ActivateElevatedController() {
321 DCHECK(worker_thread_.message_loop_proxy()->BelongsToCurrentThread()); 305 DCHECK(worker_thread_.message_loop_proxy()->BelongsToCurrentThread());
322 306
323 // The COM elevation is supported on Vista and above. 307 // The COM elevation is supported on Vista and above.
324 if (base::win::GetVersion() < base::win::VERSION_VISTA) { 308 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
(...skipping 23 matching lines...) Expand all
348 332
349 // Ignore the error. IID_IDaemonControl2 is optional. 333 // Ignore the error. IID_IDaemonControl2 is optional.
350 control_.QueryInterface(IID_IDaemonControl2, control2_.ReceiveVoid()); 334 control_.QueryInterface(IID_IDaemonControl2, control2_.ReceiveVoid());
351 335
352 // Note that we hold a reference to an elevated instance now. 336 // Note that we hold a reference to an elevated instance now.
353 control_is_elevated_ = true; 337 control_is_elevated_ = true;
354 338
355 // Release |control_| upon expiration of the timeout. 339 // Release |control_| upon expiration of the timeout.
356 release_timer_.reset(new base::OneShotTimer<DaemonControllerWin>()); 340 release_timer_.reset(new base::OneShotTimer<DaemonControllerWin>());
357 release_timer_->Start(FROM_HERE, 341 release_timer_->Start(FROM_HERE,
358 base::TimeDelta::FromSeconds(kPrivilegedTimeoutSec), 342 base::TimeDelta::FromSeconds(kUacTimeoutSec),
359 this, 343 this,
360 &DaemonControllerWin::ReleaseController); 344 &DaemonControllerWin::ReleaseController);
361 } 345 }
362 346
363 return S_OK; 347 return S_OK;
364 } 348 }
365 349
366 void DaemonControllerWin::ReleaseController() { 350 void DaemonControllerWin::ReleaseController() {
367 DCHECK(worker_thread_.message_loop_proxy()->BelongsToCurrentThread()); 351 DCHECK(worker_thread_.message_loop_proxy()->BelongsToCurrentThread());
368 352
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 done.Run(true, !!allowed, !!set_by_policy); 673 done.Run(true, !!allowed, !!set_by_policy);
690 } 674 }
691 675
692 } // namespace 676 } // namespace
693 677
694 scoped_ptr<DaemonController> remoting::DaemonController::Create() { 678 scoped_ptr<DaemonController> remoting::DaemonController::Create() {
695 return scoped_ptr<DaemonController>(new DaemonControllerWin()); 679 return scoped_ptr<DaemonController>(new DaemonControllerWin());
696 } 680 }
697 681
698 } // namespace remoting 682 } // namespace remoting
OLDNEW
« no previous file with comments | « DEPS ('k') | remoting/host/win/chromoting.wxs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698