OLD | NEW |
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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "remoting/host/it2me/it2me_native_messaging_host.h" | 9 #include "remoting/host/it2me/it2me_native_messaging_host.h" |
10 #include "remoting/host/logging.h" | 10 #include "remoting/host/logging.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #endif | 29 #endif |
30 | 30 |
31 base::MessageLoopForUI message_loop; | 31 base::MessageLoopForUI message_loop; |
32 base::RunLoop run_loop; | 32 base::RunLoop run_loop; |
33 | 33 |
34 scoped_refptr<AutoThreadTaskRunner> task_runner = | 34 scoped_refptr<AutoThreadTaskRunner> task_runner = |
35 new remoting::AutoThreadTaskRunner(message_loop.message_loop_proxy(), | 35 new remoting::AutoThreadTaskRunner(message_loop.message_loop_proxy(), |
36 run_loop.QuitClosure()); | 36 run_loop.QuitClosure()); |
37 | 37 |
38 scoped_ptr<It2MeHostFactory> factory(new It2MeHostFactory()); | 38 scoped_ptr<It2MeHostFactory> factory(new It2MeHostFactory()); |
39 scoped_ptr<NativeMessagingChannel::Delegate> host( | 39 scoped_ptr<It2MeNativeMessagingHost> host( |
40 new It2MeNativeMessagingHost(task_runner, factory.Pass())); | 40 new It2MeNativeMessagingHost(task_runner, factory.Pass())); |
41 | 41 host->Start(read_file, write_file, run_loop.QuitClosure()); |
42 NativeMessagingChannel::Delegate* host_ptr = host.get(); | |
43 | |
44 // Set up the native messaging channel. | |
45 scoped_ptr<NativeMessagingChannel> channel( | |
46 new NativeMessagingChannel(host.Pass(), read_file, write_file)); | |
47 channel->Start(base::Bind(&It2MeNativeMessagingHost::ShutDownHost, | |
48 base::Unretained(host_ptr))); | |
49 | 42 |
50 // Run the loop until channel is alive. | 43 // Run the loop until channel is alive. |
51 run_loop.Run(); | 44 run_loop.Run(); |
52 return kSuccessExitCode; | 45 return kSuccessExitCode; |
53 } | 46 } |
54 | 47 |
55 } // namespace remoting | 48 } // namespace remoting |
56 | 49 |
57 int main(int argc, char** argv) { | 50 int main(int argc, char** argv) { |
58 // This object instance is required by Chrome code (such as MessageLoop). | 51 // This object instance is required by Chrome code (such as MessageLoop). |
59 base::AtExitManager exit_manager; | 52 base::AtExitManager exit_manager; |
60 | 53 |
61 CommandLine::Init(argc, argv); | 54 CommandLine::Init(argc, argv); |
62 remoting::InitHostLogging(); | 55 remoting::InitHostLogging(); |
63 | 56 |
64 return remoting::It2MeNativeMessagingHostMain(); | 57 return remoting::It2MeNativeMessagingHostMain(); |
65 } | 58 } |
OLD | NEW |