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

Side by Side Diff: remoting/host/chromoting_host.cc

Issue 10538091: [Chromoting] Make ChromotingHost's dependency on libjingle injected, instead of hard-coded. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch for Windows. Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/chromoting_host.h ('k') | remoting/host/chromoting_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chromoting_host.h" 5 #include "remoting/host/chromoting_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "remoting/base/constants.h" 12 #include "remoting/base/constants.h"
13 #include "remoting/base/encoder.h" 13 #include "remoting/base/encoder.h"
14 #include "remoting/base/encoder_row_based.h" 14 #include "remoting/base/encoder_row_based.h"
15 #include "remoting/base/encoder_vp8.h" 15 #include "remoting/base/encoder_vp8.h"
16 #include "remoting/host/chromoting_host_context.h" 16 #include "remoting/host/chromoting_host_context.h"
17 #include "remoting/host/desktop_environment.h" 17 #include "remoting/host/desktop_environment.h"
18 #include "remoting/host/event_executor.h" 18 #include "remoting/host/event_executor.h"
19 #include "remoting/host/host_config.h" 19 #include "remoting/host/host_config.h"
20 #include "remoting/host/host_port_allocator.h"
21 #include "remoting/host/screen_recorder.h" 20 #include "remoting/host/screen_recorder.h"
22 #include "remoting/protocol/connection_to_client.h" 21 #include "remoting/protocol/connection_to_client.h"
23 #include "remoting/protocol/client_stub.h" 22 #include "remoting/protocol/client_stub.h"
24 #include "remoting/protocol/host_stub.h" 23 #include "remoting/protocol/host_stub.h"
25 #include "remoting/protocol/input_stub.h" 24 #include "remoting/protocol/input_stub.h"
26 #include "remoting/protocol/jingle_session_manager.h"
27 #include "remoting/protocol/libjingle_transport_factory.h"
28 #include "remoting/protocol/session_config.h" 25 #include "remoting/protocol/session_config.h"
29 26
30 using remoting::protocol::ConnectionToClient; 27 using remoting::protocol::ConnectionToClient;
31 using remoting::protocol::InputStub; 28 using remoting::protocol::InputStub;
32 29
33 namespace remoting { 30 namespace remoting {
34 31
35 namespace { 32 namespace {
36 33
37 const net::BackoffEntry::Policy kDefaultBackoffPolicy = { 34 const net::BackoffEntry::Policy kDefaultBackoffPolicy = {
(...skipping 21 matching lines...) Expand all
59 // Don't use initial delay unless the last request was an error. 56 // Don't use initial delay unless the last request was an error.
60 false, 57 false,
61 }; 58 };
62 59
63 } // namespace 60 } // namespace
64 61
65 ChromotingHost::ChromotingHost( 62 ChromotingHost::ChromotingHost(
66 ChromotingHostContext* context, 63 ChromotingHostContext* context,
67 SignalStrategy* signal_strategy, 64 SignalStrategy* signal_strategy,
68 DesktopEnvironment* environment, 65 DesktopEnvironment* environment,
69 const NetworkSettings& network_settings) 66 scoped_ptr<protocol::SessionManager> session_manager)
70 : context_(context), 67 : context_(context),
71 desktop_environment_(environment), 68 desktop_environment_(environment),
72 network_settings_(network_settings), 69 session_manager_(session_manager.Pass()),
73 signal_strategy_(signal_strategy), 70 signal_strategy_(signal_strategy),
74 stopping_recorders_(0), 71 stopping_recorders_(0),
75 state_(kInitial), 72 state_(kInitial),
76 protocol_config_(protocol::CandidateSessionConfig::CreateDefault()), 73 protocol_config_(protocol::CandidateSessionConfig::CreateDefault()),
77 login_backoff_(&kDefaultBackoffPolicy), 74 login_backoff_(&kDefaultBackoffPolicy),
78 authenticating_client_(false), 75 authenticating_client_(false),
79 reject_authenticating_client_(false) { 76 reject_authenticating_client_(false) {
80 DCHECK(context_); 77 DCHECK(context_);
81 DCHECK(signal_strategy); 78 DCHECK(signal_strategy);
82 DCHECK(desktop_environment_); 79 DCHECK(desktop_environment_);
83 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); 80 DCHECK(context_->network_message_loop()->BelongsToCurrentThread());
84 } 81 }
85 82
86 ChromotingHost::~ChromotingHost() { 83 ChromotingHost::~ChromotingHost() {
87 DCHECK(clients_.empty()); 84 DCHECK(clients_.empty());
88 } 85 }
89 86
90 void ChromotingHost::Start() { 87 void ChromotingHost::Start() {
91 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); 88 DCHECK(context_->network_message_loop()->BelongsToCurrentThread());
92 89
93 LOG(INFO) << "Starting host"; 90 LOG(INFO) << "Starting host";
94 91
95 // Make sure this object is not started. 92 // Make sure this object is not started.
96 if (state_ != kInitial) 93 if (state_ != kInitial)
97 return; 94 return;
98 state_ = kStarted; 95 state_ = kStarted;
99 96
100 // Create port allocator and transport factory. 97 // Start the SessionManager, supplying this ChromotingHost as the listener.
101 scoped_ptr<HostPortAllocator> port_allocator(
102 HostPortAllocator::Create(context_->url_request_context_getter(),
103 network_settings_));
104
105 bool incoming_only = network_settings_.nat_traversal_mode ==
106 NetworkSettings::NAT_TRAVERSAL_DISABLED;
107
108 scoped_ptr<protocol::TransportFactory> transport_factory(
109 new protocol::LibjingleTransportFactory(
110 port_allocator.PassAs<cricket::HttpPortAllocatorBase>(),
111 incoming_only));
112
113 // Create and start session manager.
114 bool fetch_stun_relay_info = network_settings_.nat_traversal_mode ==
115 NetworkSettings::NAT_TRAVERSAL_ENABLED;
116 session_manager_.reset(new protocol::JingleSessionManager(
117 transport_factory.Pass(), fetch_stun_relay_info));
118 session_manager_->Init(signal_strategy_, this); 98 session_manager_->Init(signal_strategy_, this);
119 } 99 }
120 100
121 // This method is called when we need to destroy the host process. 101 // This method is called when we need to destroy the host process.
122 void ChromotingHost::Shutdown(const base::Closure& shutdown_task) { 102 void ChromotingHost::Shutdown(const base::Closure& shutdown_task) {
123 if (!context_->network_message_loop()->BelongsToCurrentThread()) { 103 if (!context_->network_message_loop()->BelongsToCurrentThread()) {
124 context_->network_message_loop()->PostTask( 104 context_->network_message_loop()->PostTask(
125 FROM_HERE, base::Bind(&ChromotingHost::Shutdown, this, shutdown_task)); 105 FROM_HERE, base::Bind(&ChromotingHost::Shutdown, this, shutdown_task));
126 return; 106 return;
127 } 107 }
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 OnShutdown()); 430 OnShutdown());
451 431
452 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); 432 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin();
453 it != shutdown_tasks_.end(); ++it) { 433 it != shutdown_tasks_.end(); ++it) {
454 it->Run(); 434 it->Run();
455 } 435 }
456 shutdown_tasks_.clear(); 436 shutdown_tasks_.clear();
457 } 437 }
458 438
459 } // namespace remoting 439 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromoting_host.h ('k') | remoting/host/chromoting_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698