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

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

Issue 887853002: Shutdown the It2Me host cleanly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@it2me_host_dcheck
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | remoting/host/it2me/it2me_native_messaging_host_unittest.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 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"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // The files are automatically closed. 102 // The files are automatically closed.
103 base::File read_file(STDIN_FILENO); 103 base::File read_file(STDIN_FILENO);
104 base::File write_file(STDOUT_FILENO); 104 base::File write_file(STDOUT_FILENO);
105 #else 105 #else
106 #error Not implemented. 106 #error Not implemented.
107 #endif 107 #endif
108 108
109 base::MessageLoopForUI message_loop; 109 base::MessageLoopForUI message_loop;
110 base::RunLoop run_loop; 110 base::RunLoop run_loop;
111 111
112 scoped_refptr<AutoThreadTaskRunner> task_runner =
113 new remoting::AutoThreadTaskRunner(message_loop.message_loop_proxy(),
114 run_loop.QuitClosure());
115
116 scoped_ptr<It2MeHostFactory> factory(new It2MeHostFactory()); 112 scoped_ptr<It2MeHostFactory> factory(new It2MeHostFactory());
117 113
118 scoped_ptr<NativeMessagingPipe> native_messaging_pipe( 114 scoped_ptr<NativeMessagingPipe> native_messaging_pipe(
119 new NativeMessagingPipe()); 115 new NativeMessagingPipe());
120 116
121 // Set up the native messaging channel. 117 // Set up the native messaging channel.
122 scoped_ptr<extensions::NativeMessagingChannel> channel( 118 scoped_ptr<extensions::NativeMessagingChannel> channel(
123 new PipeMessagingChannel(read_file.Pass(), write_file.Pass())); 119 new PipeMessagingChannel(read_file.Pass(), write_file.Pass()));
124 120
125 scoped_ptr<extensions::NativeMessageHost> host(new It2MeNativeMessagingHost( 121 scoped_ptr<ChromotingHostContext> context =
126 ChromotingHostContext::Create(task_runner), factory.Pass())); 122 ChromotingHostContext::Create(new remoting::AutoThreadTaskRunner(
123 message_loop.message_loop_proxy(), run_loop.QuitClosure()));
124 scoped_ptr<extensions::NativeMessageHost> host(
125 new It2MeNativeMessagingHost(context.Pass(), factory.Pass()));
127 126
128 host->Start(native_messaging_pipe.get()); 127 host->Start(native_messaging_pipe.get());
129 128
130 native_messaging_pipe->Start( 129 native_messaging_pipe->Start(host.Pass(), channel.Pass());
131 host.Pass(), channel.Pass(), run_loop.QuitClosure());
132 130
133 // Run the loop until channel is alive. 131 // Run the loop until channel is alive.
134 run_loop.Run(); 132 run_loop.Run();
135 133
136 return kSuccessExitCode; 134 return kSuccessExitCode;
137 } 135 }
138 136
139 int It2MeNativeMessagingHostMain(int argc, char** argv) { 137 int It2MeNativeMessagingHostMain(int argc, char** argv) {
140 // This object instance is required by Chrome code (such as MessageLoop). 138 // This object instance is required by Chrome code (such as MessageLoop).
141 base::AtExitManager exit_manager; 139 base::AtExitManager exit_manager;
142 140
143 base::CommandLine::Init(argc, argv); 141 base::CommandLine::Init(argc, argv);
144 remoting::InitHostLogging(); 142 remoting::InitHostLogging();
145 143
146 return StartIt2MeNativeMessagingHost(); 144 return StartIt2MeNativeMessagingHost();
147 } 145 }
148 146
149 } // namespace remoting 147 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/host/it2me/it2me_native_messaging_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698