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

Side by Side Diff: shell/launcher_main.cc

Issue 775343004: Move //mojo/shell to //shell (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « shell/init.cc ('k') | shell/mojo_url_resolver.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "mojo/edk/embedder/embedder.h" 11 #include "mojo/edk/embedder/embedder.h"
12 #include "mojo/edk/embedder/simple_platform_support.h" 12 #include "mojo/edk/embedder/simple_platform_support.h"
13 #include "mojo/shell/external_application_registrar_connection.h" 13 #include "shell/external_application_registrar_connection.h"
14 #include "mojo/shell/in_process_dynamic_service_runner.h" 14 #include "shell/in_process_dynamic_service_runner.h"
15 #include "mojo/shell/init.h" 15 #include "shell/init.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace { 18 namespace {
19 const char kAppPath[] = "app-path"; 19 const char kAppPath[] = "app-path";
20 const char kAppURL[] = "app-url"; 20 const char kAppURL[] = "app-url";
21 const char kShellPath[] = "shell-path"; 21 const char kShellPath[] = "shell-path";
22 } 22 }
23 23
24 class Launcher { 24 class Launcher {
25 public: 25 public:
(...skipping 26 matching lines...) Expand all
52 run_loop_.reset(); 52 run_loop_.reset();
53 return shell_handle_.is_valid(); 53 return shell_handle_.is_valid();
54 } 54 }
55 55
56 void Run() { 56 void Run() {
57 DCHECK(!run_loop_.get()); 57 DCHECK(!run_loop_.get());
58 DCHECK(shell_handle_.is_valid()); 58 DCHECK(shell_handle_.is_valid());
59 mojo::shell::InProcessDynamicServiceRunner service_runner(nullptr); 59 mojo::shell::InProcessDynamicServiceRunner service_runner(nullptr);
60 run_loop_.reset(new base::RunLoop); 60 run_loop_.reset(new base::RunLoop);
61 service_runner.Start( 61 service_runner.Start(
62 app_path_, 62 app_path_, shell_handle_.Pass(),
63 shell_handle_.Pass(),
64 base::Bind(&Launcher::OnAppCompleted, base::Unretained(this))); 63 base::Bind(&Launcher::OnAppCompleted, base::Unretained(this)));
65 run_loop_->Run(); 64 run_loop_->Run();
66 run_loop_.reset(); 65 run_loop_.reset();
67 } 66 }
68 67
69 private: 68 private:
70 void OnConnected(int result) { 69 void OnConnected(int result) {
71 connect_result_ = result; 70 connect_result_ = result;
72 run_loop_->Quit(); 71 run_loop_->Quit();
73 } 72 }
74 73
75 void OnRegistered(mojo::ShellPtr shell) { 74 void OnRegistered(mojo::ShellPtr shell) {
76 shell_handle_ = shell.PassMessagePipe(); 75 shell_handle_ = shell.PassMessagePipe();
77 run_loop_->Quit(); 76 run_loop_->Quit();
78 } 77 }
79 78
80 void OnAppCompleted() { 79 void OnAppCompleted() { run_loop_->Quit(); }
81 run_loop_->Quit();
82 }
83 80
84 const base::FilePath app_path_; 81 const base::FilePath app_path_;
85 const GURL app_url_; 82 const GURL app_url_;
86 base::MessageLoop loop_; 83 base::MessageLoop loop_;
87 mojo::shell::ExternalApplicationRegistrarConnection connection_; 84 mojo::shell::ExternalApplicationRegistrarConnection connection_;
88 int connect_result_; 85 int connect_result_;
89 mojo::ScopedMessagePipeHandle shell_handle_; 86 mojo::ScopedMessagePipeHandle shell_handle_;
90 scoped_ptr<base::RunLoop> run_loop_; 87 scoped_ptr<base::RunLoop> run_loop_;
91 }; 88 };
92 89
(...skipping 20 matching lines...) Expand all
113 110
114 if (!launcher.Register()) { 111 if (!launcher.Register()) {
115 LOG(ERROR) << "Error registering " 112 LOG(ERROR) << "Error registering "
116 << command_line->GetSwitchValueASCII(kAppURL); 113 << command_line->GetSwitchValueASCII(kAppURL);
117 return MOJO_RESULT_INVALID_ARGUMENT; 114 return MOJO_RESULT_INVALID_ARGUMENT;
118 } 115 }
119 116
120 launcher.Run(); 117 launcher.Run();
121 return MOJO_RESULT_OK; 118 return MOJO_RESULT_OK;
122 } 119 }
OLDNEW
« no previous file with comments | « shell/init.cc ('k') | shell/mojo_url_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698