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

Side by Side Diff: remoting/host/desktop_session_win.cc

Issue 15077010: [Chromoting] Refactored worker process launching code and speeded up the desktop process launch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/daemon_process_win.cc ('k') | remoting/host/host_main.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/desktop_session_win.h" 5 #include "remoting/host/desktop_session_win.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <sddl.h> 8 #include <sddl.h>
9 9
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/stringprintf.h" 17 #include "base/stringprintf.h"
18 #include "base/threading/thread_checker.h" 18 #include "base/threading/thread_checker.h"
19 #include "base/timer.h" 19 #include "base/timer.h"
20 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
21 #include "base/win/scoped_comptr.h" 21 #include "base/win/scoped_comptr.h"
22 #include "base/win/scoped_handle.h" 22 #include "base/win/scoped_handle.h"
23 #include "base/win/windows_version.h"
23 #include "ipc/ipc_message_macros.h" 24 #include "ipc/ipc_message_macros.h"
24 #include "ipc/ipc_platform_file.h" 25 #include "ipc/ipc_platform_file.h"
25 #include "net/base/ip_endpoint.h" 26 #include "net/base/ip_endpoint.h"
26 #include "remoting/base/auto_thread_task_runner.h" 27 #include "remoting/base/auto_thread_task_runner.h"
27 // MIDL-generated declarations and definitions. 28 // MIDL-generated declarations and definitions.
28 #include "remoting/host/chromoting_lib.h" 29 #include "remoting/host/chromoting_lib.h"
29 #include "remoting/host/chromoting_messages.h" 30 #include "remoting/host/chromoting_messages.h"
30 #include "remoting/host/daemon_process.h" 31 #include "remoting/host/daemon_process.h"
31 #include "remoting/host/desktop_session.h" 32 #include "remoting/host/desktop_session.h"
32 #include "remoting/host/host_main.h" 33 #include "remoting/host/host_main.h"
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 daemon_process()->CloseDesktopSession(id()); 506 daemon_process()->CloseDesktopSession(id());
506 } 507 }
507 508
508 void DesktopSessionWin::OnSessionAttached(uint32 session_id) { 509 void DesktopSessionWin::OnSessionAttached(uint32 session_id) {
509 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 510 DCHECK(caller_task_runner_->BelongsToCurrentThread());
510 DCHECK(!launcher_); 511 DCHECK(!launcher_);
511 DCHECK(monitoring_notifications_); 512 DCHECK(monitoring_notifications_);
512 513
513 ReportElapsedTime("attached"); 514 ReportElapsedTime("attached");
514 515
515 // Get the name of the executable the desktop process will run. 516 // Launch elevated on Win8 to be able to inject Alt+Tab.
517 bool launch_elevated = base::win::GetVersion() >= base::win::VERSION_WIN8;
518
519 // Get the name of the executable to run. |kDesktopBinaryName| specifies
520 // uiAccess="true" in it's manifest.
516 base::FilePath desktop_binary; 521 base::FilePath desktop_binary;
517 if (!GetInstalledBinaryPath(kDesktopBinaryName, &desktop_binary)) { 522 bool result;
523 if (launch_elevated) {
524 result = GetInstalledBinaryPath(kDesktopBinaryName, &desktop_binary);
525 } else {
526 result = GetInstalledBinaryPath(kHostBinaryName, &desktop_binary);
527 }
528
529 if (!result) {
518 OnPermanentError(); 530 OnPermanentError();
519 return; 531 return;
520 } 532 }
521 533
522 session_attach_timer_.Stop(); 534 session_attach_timer_.Stop();
523 535
524 scoped_ptr<CommandLine> target(new CommandLine(desktop_binary)); 536 scoped_ptr<CommandLine> target(new CommandLine(desktop_binary));
525 target->AppendSwitchASCII(kProcessTypeSwitchName, kProcessTypeDesktop); 537 target->AppendSwitchASCII(kProcessTypeSwitchName, kProcessTypeDesktop);
526 // Copy the command line switches enabling verbose logging. 538 // Copy the command line switches enabling verbose logging.
527 target->CopySwitchesFrom(*CommandLine::ForCurrentProcess(), 539 target->CopySwitchesFrom(*CommandLine::ForCurrentProcess(),
528 kCopiedSwitchNames, 540 kCopiedSwitchNames,
529 arraysize(kCopiedSwitchNames)); 541 arraysize(kCopiedSwitchNames));
530 542
531 // Create a delegate capable of launching a process in a different session. 543 // Create a delegate capable of launching a process in a different session.
532 scoped_ptr<WtsSessionProcessDelegate> delegate( 544 scoped_ptr<WtsSessionProcessDelegate> delegate(
533 new WtsSessionProcessDelegate( 545 new WtsSessionProcessDelegate(io_task_runner_,
534 caller_task_runner_, io_task_runner_, target.Pass(), session_id, true, 546 target.Pass(),
535 WideToUTF8(kDaemonIpcSecurityDescriptor))); 547 launch_elevated,
548 WideToUTF8(kDaemonIpcSecurityDescriptor)));
549 if (!delegate->Initialize(session_id)) {
550 OnPermanentError();
551 return;
552 }
536 553
537 // Create a launcher for the desktop process, using the per-session delegate. 554 // Create a launcher for the desktop process, using the per-session delegate.
538 launcher_.reset(new WorkerProcessLauncher( 555 launcher_.reset(new WorkerProcessLauncher(delegate.Pass(), this));
539 caller_task_runner_, delegate.Pass(), this));
540 } 556 }
541 557
542 void DesktopSessionWin::OnSessionDetached() { 558 void DesktopSessionWin::OnSessionDetached() {
543 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 559 DCHECK(caller_task_runner_->BelongsToCurrentThread());
544 560
545 launcher_.reset(); 561 launcher_.reset();
546 562
547 if (monitoring_notifications_) { 563 if (monitoring_notifications_) {
548 ReportElapsedTime("detached"); 564 ReportElapsedTime("detached");
549 565
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 exploded.hour, 602 exploded.hour,
587 exploded.minute, 603 exploded.minute,
588 exploded.second, 604 exploded.second,
589 exploded.millisecond, 605 exploded.millisecond,
590 passed.c_str()); 606 passed.c_str());
591 607
592 last_timestamp_ = now; 608 last_timestamp_ = now;
593 } 609 }
594 610
595 } // namespace remoting 611 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/daemon_process_win.cc ('k') | remoting/host/host_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698