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

Side by Side Diff: remoting/host/it2me/it2me_native_messaging_host_main.cc

Issue 639233002: Remote assistance on Chrome OS Part IV - It2MeHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ChromotingHostContext cleanup Created 6 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/it2me/it2me_native_messaging_host_main.h" 5 #include "remoting/host/it2me/it2me_native_messaging_host_main.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/i18n/icu_util.h" 9 #include "base/i18n/icu_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "media/base/media.h"
13 #include "net/socket/ssl_server_socket.h" 12 #include "net/socket/ssl_server_socket.h"
14 #include "remoting/base/breakpad.h" 13 #include "remoting/base/breakpad.h"
15 #include "remoting/base/resources.h" 14 #include "remoting/base/resources.h"
15 #include "remoting/host/chromoting_host_context.h"
16 #include "remoting/host/host_exit_codes.h" 16 #include "remoting/host/host_exit_codes.h"
17 #include "remoting/host/it2me/it2me_native_messaging_host.h" 17 #include "remoting/host/it2me/it2me_native_messaging_host.h"
18 #include "remoting/host/logging.h" 18 #include "remoting/host/logging.h"
19 #include "remoting/host/native_messaging/native_messaging_pipe.h" 19 #include "remoting/host/native_messaging/native_messaging_pipe.h"
20 #include "remoting/host/native_messaging/pipe_messaging_channel.h" 20 #include "remoting/host/native_messaging/pipe_messaging_channel.h"
21 #include "remoting/host/usage_stats_consent.h" 21 #include "remoting/host/usage_stats_consent.h"
22 22
23 #if defined(OS_LINUX) 23 #if defined(OS_LINUX)
24 #include <gtk/gtk.h> 24 #include <gtk/gtk.h>
25 #include <X11/Xlib.h> 25 #include <X11/Xlib.h>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // Required for any calls into GTK functions, such as the Disconnect and 73 // Required for any calls into GTK functions, such as the Disconnect and
74 // Continue windows. Calling with NULL arguments because we don't have 74 // Continue windows. Calling with NULL arguments because we don't have
75 // any command line arguments for gtk to consume. 75 // any command line arguments for gtk to consume.
76 gtk_init(NULL, NULL); 76 gtk_init(NULL, NULL);
77 #endif // OS_LINUX 77 #endif // OS_LINUX
78 78
79 // Enable support for SSL server sockets, which must be done while still 79 // Enable support for SSL server sockets, which must be done while still
80 // single-threaded. 80 // single-threaded.
81 net::EnableSSLServerSockets(); 81 net::EnableSSLServerSockets();
82 82
83 // Ensures runtime specific CPU features are initialized.
84 media::InitializeCPUSpecificMediaFeatures();
85
86 #if defined(OS_WIN) 83 #if defined(OS_WIN)
87 // GetStdHandle() returns pseudo-handles for stdin and stdout even if 84 // GetStdHandle() returns pseudo-handles for stdin and stdout even if
88 // the hosting executable specifies "Windows" subsystem. However the returned 85 // the hosting executable specifies "Windows" subsystem. However the returned
89 // handles are invalid in that case unless standard input and output are 86 // handles are invalid in that case unless standard input and output are
90 // redirected to a pipe or file. 87 // redirected to a pipe or file.
91 base::File read_file(GetStdHandle(STD_INPUT_HANDLE)); 88 base::File read_file(GetStdHandle(STD_INPUT_HANDLE));
92 base::File write_file(GetStdHandle(STD_OUTPUT_HANDLE)); 89 base::File write_file(GetStdHandle(STD_OUTPUT_HANDLE));
93 90
94 // After the native messaging channel starts the native messaging reader 91 // After the native messaging channel starts the native messaging reader
95 // will keep doing blocking read operations on the input named pipe. 92 // will keep doing blocking read operations on the input named pipe.
(...skipping 13 matching lines...) Expand all
109 #error Not implemented. 106 #error Not implemented.
110 #endif 107 #endif
111 108
112 base::MessageLoopForUI message_loop; 109 base::MessageLoopForUI message_loop;
113 base::RunLoop run_loop; 110 base::RunLoop run_loop;
114 111
115 scoped_refptr<AutoThreadTaskRunner> task_runner = 112 scoped_refptr<AutoThreadTaskRunner> task_runner =
116 new remoting::AutoThreadTaskRunner(message_loop.message_loop_proxy(), 113 new remoting::AutoThreadTaskRunner(message_loop.message_loop_proxy(),
117 run_loop.QuitClosure()); 114 run_loop.QuitClosure());
118 115
119 scoped_ptr<It2MeHostFactory> factory(new It2MeHostFactory()); 116 scoped_ptr<It2MeHostFactory> factory(new It2MeHostFactory(nullptr));
Wez 2014/10/24 00:28:48 nit: Add a comment to explain the nullptr
kelvinp 2014/10/24 21:39:42 Done.
120 117
121 scoped_ptr<NativeMessagingPipe> native_messaging_pipe( 118 scoped_ptr<NativeMessagingPipe> native_messaging_pipe(
122 new NativeMessagingPipe()); 119 new NativeMessagingPipe());
123 120
124 // Set up the native messaging channel. 121 // Set up the native messaging channel.
125 scoped_ptr<extensions::NativeMessagingChannel> channel( 122 scoped_ptr<extensions::NativeMessagingChannel> channel(
126 new PipeMessagingChannel(read_file.Pass(), write_file.Pass())); 123 new PipeMessagingChannel(read_file.Pass(), write_file.Pass()));
127 124
128 scoped_ptr<extensions::NativeMessageHost> host(new It2MeNativeMessagingHost( 125 scoped_ptr<extensions::NativeMessageHost> host(new It2MeNativeMessagingHost(
129 task_runner, 126 ChromotingHostContext::Create(task_runner), factory.Pass()));
130 factory.Pass()));
131 127
132 host->Start(native_messaging_pipe.get()); 128 host->Start(native_messaging_pipe.get());
133 129
134 native_messaging_pipe->Start( 130 native_messaging_pipe->Start(
135 host.Pass(), channel.Pass(), run_loop.QuitClosure()); 131 host.Pass(), channel.Pass(), run_loop.QuitClosure());
136 132
137 // Run the loop until channel is alive. 133 // Run the loop until channel is alive.
138 run_loop.Run(); 134 run_loop.Run();
139 135
140 return kSuccessExitCode; 136 return kSuccessExitCode;
141 } 137 }
142 138
143 int It2MeNativeMessagingHostMain(int argc, char** argv) { 139 int It2MeNativeMessagingHostMain(int argc, char** argv) {
144 // This object instance is required by Chrome code (such as MessageLoop). 140 // This object instance is required by Chrome code (such as MessageLoop).
145 base::AtExitManager exit_manager; 141 base::AtExitManager exit_manager;
146 142
147 base::CommandLine::Init(argc, argv); 143 base::CommandLine::Init(argc, argv);
148 remoting::InitHostLogging(); 144 remoting::InitHostLogging();
149 145
150 return StartIt2MeNativeMessagingHost(); 146 return StartIt2MeNativeMessagingHost();
151 } 147 }
152 148
153 } // namespace remoting 149 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698