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

Side by Side Diff: mojo/shell/launcher_main.cc

Issue 700763002: More Windows build fixes, some tidying in mojo_main (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: reland: fix sense in mojo/shell Created 6 years, 1 month 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 | « mojo/shell/incoming_connection_listener_unittest.cc ('k') | no next file » | 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 "mojo/shell/external_application_registrar_connection.h"
14 #include "mojo/shell/in_process_dynamic_service_runner.h" 14 #include "mojo/shell/in_process_dynamic_service_runner.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 16
17 namespace { 17 namespace {
18 const char kAppPath[] = "app-path"; 18 const char kAppPath[] = "app-path";
19 const char kAppURL[] = "app-url"; 19 const char kAppURL[] = "app-url";
20 const char kShellPath[] = "shell-path"; 20 const char kShellPath[] = "shell-path";
21 } 21 }
22 22
23 class Launcher { 23 class Launcher {
24 public: 24 public:
25 explicit Launcher(base::CommandLine* command_line) 25 explicit Launcher(base::CommandLine* command_line)
26 : app_path_(command_line->GetSwitchValueASCII(kAppPath)), 26 : app_path_(command_line->GetSwitchValuePath(kAppPath)),
27 app_url_(command_line->GetSwitchValueASCII(kAppURL)), 27 app_url_(command_line->GetSwitchValueASCII(kAppURL)),
28 loop_(base::MessageLoop::TYPE_IO), 28 loop_(base::MessageLoop::TYPE_IO),
29 connection_(base::FilePath( 29 connection_(
30 command_line->GetSwitchValueASCII(kShellPath))), 30 base::FilePath(command_line->GetSwitchValuePath(kShellPath))),
31 connect_result_(0) {} 31 connect_result_(0) {}
32 ~Launcher() {} 32 ~Launcher() {}
33 33
34 int Connect() { 34 int Connect() {
35 DCHECK(!run_loop_.get()); 35 DCHECK(!run_loop_.get());
36 run_loop_.reset(new base::RunLoop); 36 run_loop_.reset(new base::RunLoop);
37 connection_.Connect( 37 connection_.Connect(
38 base::Bind(&Launcher::OnConnected, base::Unretained(this))); 38 base::Bind(&Launcher::OnConnected, base::Unretained(this)));
39 run_loop_->Run(); 39 run_loop_->Run();
40 run_loop_.reset(); 40 run_loop_.reset();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 const base::FilePath app_path_; 83 const base::FilePath app_path_;
84 const GURL app_url_; 84 const GURL app_url_;
85 base::MessageLoop loop_; 85 base::MessageLoop loop_;
86 mojo::shell::ExternalApplicationRegistrarConnection connection_; 86 mojo::shell::ExternalApplicationRegistrarConnection connection_;
87 int connect_result_; 87 int connect_result_;
88 mojo::ScopedMessagePipeHandle shell_handle_; 88 mojo::ScopedMessagePipeHandle shell_handle_;
89 scoped_ptr<base::RunLoop> run_loop_; 89 scoped_ptr<base::RunLoop> run_loop_;
90 }; 90 };
91 91
92 #if defined(OS_WIN)
93 int main(int argc, wchar_t** argv) {
94 #else
92 int main(int argc, char** argv) { 95 int main(int argc, char** argv) {
96 #endif
93 base::AtExitManager at_exit; 97 base::AtExitManager at_exit;
94 mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( 98 mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>(
95 new mojo::embedder::SimplePlatformSupport())); 99 new mojo::embedder::SimplePlatformSupport()));
96 base::CommandLine command_line(argc, argv); 100 base::CommandLine command_line(argc, argv);
97 Launcher launcher(&command_line); 101 Launcher launcher(&command_line);
98 int result = launcher.Connect(); 102 int result = launcher.Connect();
99 if (result < 0) { 103 if (result < 0) {
100 LOG(ERROR) << "Error(" << result << ") connecting on socket " 104 LOG(ERROR) << "Error(" << result << ") connecting on socket "
101 << command_line.GetSwitchValueASCII(kShellPath); 105 << command_line.GetSwitchValueASCII(kShellPath);
102 return MOJO_RESULT_INVALID_ARGUMENT; 106 return MOJO_RESULT_INVALID_ARGUMENT;
103 } 107 }
104 108
105 if (!launcher.Register()) { 109 if (!launcher.Register()) {
106 LOG(ERROR) << "Error registering " 110 LOG(ERROR) << "Error registering "
107 << command_line.GetSwitchValueASCII(kAppURL); 111 << command_line.GetSwitchValueASCII(kAppURL);
108 return MOJO_RESULT_INVALID_ARGUMENT; 112 return MOJO_RESULT_INVALID_ARGUMENT;
109 } 113 }
110 114
111 launcher.Run(); 115 launcher.Run();
112 return MOJO_RESULT_OK; 116 return MOJO_RESULT_OK;
113 } 117 }
OLDNEW
« no previous file with comments | « mojo/shell/incoming_connection_listener_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698