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( | |
40 new It2MeNativeMessagingHost(task_runner, factory.Pass())); | |
41 | |
42 NativeMessagingChannel::Delegate* host_ptr = host.get(); | |
43 | 39 |
44 // Set up the native messaging channel. | 40 // Set up the native messaging channel. |
45 scoped_ptr<NativeMessagingChannel> channel( | 41 scoped_ptr<NativeMessagingChannel> channel( |
46 new NativeMessagingChannel(host.Pass(), read_file, write_file)); | 42 new NativeMessagingChannel(read_file, write_file)); |
47 channel->Start(base::Bind(&It2MeNativeMessagingHost::ShutDownHost, | 43 |
48 base::Unretained(host_ptr))); | 44 scoped_ptr<It2MeNativeMessagingHost> host( |
| 45 new It2MeNativeMessagingHost( |
| 46 task_runner, channel.Pass(), factory.Pass())); |
| 47 host->Start(run_loop.QuitClosure()); |
49 | 48 |
50 // Run the loop until channel is alive. | 49 // Run the loop until channel is alive. |
51 run_loop.Run(); | 50 run_loop.Run(); |
52 return kSuccessExitCode; | 51 return kSuccessExitCode; |
53 } | 52 } |
54 | 53 |
55 } // namespace remoting | 54 } // namespace remoting |
56 | 55 |
57 int main(int argc, char** argv) { | 56 int main(int argc, char** argv) { |
58 // This object instance is required by Chrome code (such as MessageLoop). | 57 // This object instance is required by Chrome code (such as MessageLoop). |
59 base::AtExitManager exit_manager; | 58 base::AtExitManager exit_manager; |
60 | 59 |
61 CommandLine::Init(argc, argv); | 60 CommandLine::Init(argc, argv); |
62 remoting::InitHostLogging(); | 61 remoting::InitHostLogging(); |
63 | 62 |
64 return remoting::It2MeNativeMessagingHostMain(); | 63 return remoting::It2MeNativeMessagingHostMain(); |
65 } | 64 } |
OLD | NEW |