OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This is an application of a minimal host process in a Chromoting | 5 // This is an application of a minimal host process in a Chromoting |
6 // system. It serves the purpose of gluing different pieces together | 6 // system. It serves the purpose of gluing different pieces together |
7 // to make a functional host process for testing. | 7 // to make a functional host process for testing. |
8 // | 8 // |
9 // It peforms the following functionality: | 9 // It peforms the following functionality: |
10 // 1. Connect to the GTalk network and register the machine as a host. | 10 // 1. Connect to the GTalk network and register the machine as a host. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 std::string path = GetEnvironmentVar(base::env_vars::kHome); | 96 std::string path = GetEnvironmentVar(base::env_vars::kHome); |
97 #endif | 97 #endif |
98 FilePath config_path(path); | 98 FilePath config_path(path); |
99 config_path = config_path.Append(kDefaultConfigPath); | 99 config_path = config_path.Append(kDefaultConfigPath); |
100 if (cmd_line->HasSwitch(kConfigSwitchName)) { | 100 if (cmd_line->HasSwitch(kConfigSwitchName)) { |
101 config_path = cmd_line->GetSwitchValuePath(kConfigSwitchName); | 101 config_path = cmd_line->GetSwitchValuePath(kConfigSwitchName); |
102 } | 102 } |
103 | 103 |
104 if (fake) { | 104 if (fake) { |
105 // Inject a fake capturer. | 105 // Inject a fake capturer. |
106 LOG(INFO) << "Usage a fake capturer."; | 106 LOG(INFO) << "Using a fake capturer."; |
107 capturer.reset(new remoting::CapturerFake()); | 107 capturer.reset(new remoting::CapturerFake()); |
108 } | 108 } |
109 | 109 |
110 base::Thread file_io_thread("FileIO"); | 110 base::Thread file_io_thread("FileIO"); |
111 file_io_thread.Start(); | 111 file_io_thread.Start(); |
112 | 112 |
113 scoped_refptr<remoting::JsonHostConfig> config( | 113 scoped_refptr<remoting::JsonHostConfig> config( |
114 new remoting::JsonHostConfig( | 114 new remoting::JsonHostConfig( |
115 config_path, file_io_thread.message_loop_proxy())); | 115 config_path, file_io_thread.message_loop_proxy())); |
116 | 116 |
117 if (!config->Read()) { | 117 if (!config->Read()) { |
118 LOG(ERROR) << "Failed to read configuration file " << config_path.value(); | 118 LOG(ERROR) << "Failed to read configuration file " << config_path.value(); |
119 return 1; | 119 return 1; |
120 } | 120 } |
121 | 121 |
122 // Allocate a chromoting context and starts it. | 122 // Allocate a chromoting context and starts it. |
123 remoting::ChromotingHostContext context; | 123 remoting::ChromotingHostContext context; |
124 context.Start(); | 124 context.Start(); |
125 | 125 |
126 // Construct a chromoting host. | 126 // Construct a chromoting host. |
127 scoped_refptr<remoting::ChromotingHost> host = | 127 scoped_refptr<remoting::ChromotingHost> host = |
128 new remoting::ChromotingHost(&context, | 128 new remoting::ChromotingHost(&context, |
129 config, | 129 config, |
130 capturer.release(), | 130 capturer.release(), |
131 encoder.release(), | 131 encoder.release(), |
132 executor.release()); | 132 executor.release()); |
133 | 133 |
134 // Let the chromoting host runs until the shutdown task is executed. | 134 // Let the chromoting host run until the shutdown task is executed. |
135 MessageLoop message_loop(MessageLoop::TYPE_UI); | 135 MessageLoop message_loop(MessageLoop::TYPE_UI); |
136 host->Start(NewRunnableFunction(&ShutdownTask, &message_loop)); | 136 host->Start(NewRunnableFunction(&ShutdownTask, &message_loop)); |
137 message_loop.Run(); | 137 message_loop.Run(); |
138 | 138 |
139 // And then stop the chromoting context. | 139 // And then stop the chromoting context. |
140 context.Stop(); | 140 context.Stop(); |
141 file_io_thread.Stop(); | 141 file_io_thread.Stop(); |
142 return 0; | 142 return 0; |
143 } | 143 } |
OLD | NEW |