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

Side by Side Diff: remoting/client/jingle_host_connection.cc

Issue 4313001: Rename classes for Chromoting: (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: Resolve merge conflicts Created 10 years, 1 month 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/client/jingle_host_connection.h ('k') | remoting/host/chromoting_host.h » ('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) 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 #include "base/callback.h" 5 #include "base/callback.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "remoting/base/constants.h" 7 #include "remoting/base/constants.h"
8 // TODO(hclam): Remove this header once MessageDispatcher is used. 8 // TODO(hclam): Remove this header once MessageDispatcher is used.
9 #include "remoting/base/multiple_array_input_stream.h" 9 #include "remoting/base/multiple_array_input_stream.h"
10 #include "remoting/client/client_config.h" 10 #include "remoting/client/client_config.h"
11 #include "remoting/client/jingle_host_connection.h" 11 #include "remoting/client/jingle_host_connection.h"
12 #include "remoting/jingle_glue/jingle_thread.h" 12 #include "remoting/jingle_glue/jingle_thread.h"
13 #include "remoting/protocol/jingle_chromotocol_server.h" 13 #include "remoting/protocol/jingle_session_manager.h"
14 #include "remoting/protocol/video_stub.h" 14 #include "remoting/protocol/video_stub.h"
15 #include "remoting/protocol/util.h" 15 #include "remoting/protocol/util.h"
16 16
17 namespace remoting { 17 namespace remoting {
18 18
19 JingleHostConnection::JingleHostConnection(ClientContext* context) 19 JingleHostConnection::JingleHostConnection(ClientContext* context)
20 : context_(context), 20 : context_(context),
21 event_callback_(NULL) { 21 event_callback_(NULL) {
22 } 22 }
23 23
(...skipping 21 matching lines...) Expand all
45 message_loop()->PostTask( 45 message_loop()->PostTask(
46 FROM_HERE, NewRunnableMethod(this, 46 FROM_HERE, NewRunnableMethod(this,
47 &JingleHostConnection::Disconnect)); 47 &JingleHostConnection::Disconnect));
48 return; 48 return;
49 } 49 }
50 50
51 control_reader_.Close(); 51 control_reader_.Close();
52 event_writer_.Close(); 52 event_writer_.Close();
53 video_reader_->Close(); 53 video_reader_->Close();
54 54
55 if (connection_) { 55 if (session_) {
56 connection_->Close( 56 session_->Close(
57 NewRunnableMethod(this, &JingleHostConnection::OnDisconnected)); 57 NewRunnableMethod(this, &JingleHostConnection::OnDisconnected));
58 } else { 58 } else {
59 OnDisconnected(); 59 OnDisconnected();
60 } 60 }
61 } 61 }
62 62
63 void JingleHostConnection::OnControlMessage(ChromotingHostMessage* msg) { 63 void JingleHostConnection::OnControlMessage(ChromotingHostMessage* msg) {
64 event_callback_->HandleMessage(this, msg); 64 event_callback_->HandleMessage(this, msg);
65 } 65 }
66 66
67 void JingleHostConnection::InitConnection() { 67 void JingleHostConnection::InitSession() {
68 DCHECK_EQ(message_loop(), MessageLoop::current()); 68 DCHECK_EQ(message_loop(), MessageLoop::current());
69 69
70 // Initialize |chromotocol_server_|. 70 // Initialize chromotocol |session_manager_|.
71 JingleChromotocolServer* chromotocol_server = 71 protocol::JingleSessionManager* session_manager =
72 new JingleChromotocolServer(context_->jingle_thread()); 72 new protocol::JingleSessionManager(context_->jingle_thread());
73 // TODO(ajwong): Make this a command switch when we're more stable. 73 // TODO(ajwong): Make this a command switch when we're more stable.
74 chromotocol_server->set_allow_local_ips(true); 74 session_manager->set_allow_local_ips(true);
75 chromotocol_server->Init( 75 session_manager->Init(
76 jingle_client_->GetFullJid(), 76 jingle_client_->GetFullJid(),
77 jingle_client_->session_manager(), 77 jingle_client_->session_manager(),
78 NewCallback(this, &JingleHostConnection::OnNewChromotocolConnection)); 78 NewCallback(this, &JingleHostConnection::OnNewSession));
79 chromotocol_server_ = chromotocol_server; 79 session_manager_ = session_manager;
80 80
81 CandidateChromotocolConfig* candidate_config = 81 CandidateChromotocolConfig* candidate_config =
82 CandidateChromotocolConfig::CreateDefault(); 82 CandidateChromotocolConfig::CreateDefault();
83 // TODO(sergeyu): Set resolution in the |candidate_config| to the desired 83 // TODO(sergeyu): Set resolution in the |candidate_config| to the desired
84 // resolution. 84 // resolution.
85 85
86 // Initialize |connection_|. 86 // Initialize |session_|.
87 connection_ = chromotocol_server_->Connect( 87 session_ = session_manager_->Connect(
88 host_jid_, candidate_config, 88 host_jid_, candidate_config,
89 NewCallback(this, &JingleHostConnection::OnConnectionStateChange)); 89 NewCallback(this, &JingleHostConnection::OnSessionStateChange));
90 } 90 }
91 91
92 void JingleHostConnection::OnDisconnected() { 92 void JingleHostConnection::OnDisconnected() {
93 connection_ = NULL; 93 session_ = NULL;
94 94
95 if (chromotocol_server_) { 95 if (session_manager_) {
96 chromotocol_server_->Close( 96 session_manager_->Close(
97 NewRunnableMethod(this, &JingleHostConnection::OnServerClosed)); 97 NewRunnableMethod(this, &JingleHostConnection::OnServerClosed));
98 } else { 98 } else {
99 OnServerClosed(); 99 OnServerClosed();
100 } 100 }
101 } 101 }
102 102
103 void JingleHostConnection::OnServerClosed() { 103 void JingleHostConnection::OnServerClosed() {
104 chromotocol_server_ = NULL; 104 session_manager_ = NULL;
105 if (jingle_client_) { 105 if (jingle_client_) {
106 jingle_client_->Close(); 106 jingle_client_->Close();
107 jingle_client_ = NULL; 107 jingle_client_ = NULL;
108 } 108 }
109 } 109 }
110 110
111 void JingleHostConnection::SendEvent(const ChromotingClientMessage& msg) { 111 void JingleHostConnection::SendEvent(const ChromotingClientMessage& msg) {
112 // This drops the message if we are not connected yet. 112 // This drops the message if we are not connected yet.
113 event_writer_.SendMessage(msg); 113 event_writer_.SendMessage(msg);
114 } 114 }
115 115
116 // JingleClient::Callback interface. 116 // JingleClient::Callback interface.
117 void JingleHostConnection::OnStateChange(JingleClient* client, 117 void JingleHostConnection::OnStateChange(JingleClient* client,
118 JingleClient::State state) { 118 JingleClient::State state) {
119 DCHECK_EQ(message_loop(), MessageLoop::current()); 119 DCHECK_EQ(message_loop(), MessageLoop::current());
120 DCHECK(client); 120 DCHECK(client);
121 DCHECK(event_callback_); 121 DCHECK(event_callback_);
122 122
123 if (state == JingleClient::CONNECTED) { 123 if (state == JingleClient::CONNECTED) {
124 VLOG(1) << "Connected as: " << client->GetFullJid(); 124 VLOG(1) << "Connected as: " << client->GetFullJid();
125 InitConnection(); 125 InitSession();
126 } else if (state == JingleClient::CLOSED) { 126 } else if (state == JingleClient::CLOSED) {
127 VLOG(1) << "Connection closed."; 127 VLOG(1) << "Connection closed.";
128 event_callback_->OnConnectionClosed(this); 128 event_callback_->OnConnectionClosed(this);
129 } 129 }
130 } 130 }
131 131
132 void JingleHostConnection::OnNewChromotocolConnection( 132 void JingleHostConnection::OnNewSession(protocol::Session* session,
133 ChromotocolConnection* connection, 133 protocol::SessionManager::IncomingSessionResponse* response) {
134 ChromotocolServer::IncomingConnectionResponse* response) {
135 DCHECK_EQ(message_loop(), MessageLoop::current()); 134 DCHECK_EQ(message_loop(), MessageLoop::current());
136 // Client always rejects incoming connections. 135 // Client always rejects incoming sessions.
137 *response = ChromotocolServer::DECLINE; 136 *response = protocol::SessionManager::DECLINE;
138 } 137 }
139 138
140 void JingleHostConnection::OnConnectionStateChange( 139 void JingleHostConnection::OnSessionStateChange(
141 ChromotocolConnection::State state) { 140 protocol::Session::State state) {
142 DCHECK_EQ(message_loop(), MessageLoop::current()); 141 DCHECK_EQ(message_loop(), MessageLoop::current());
143 DCHECK(event_callback_); 142 DCHECK(event_callback_);
144 143
145 switch (state) { 144 switch (state) {
146 case ChromotocolConnection::FAILED: 145 case protocol::Session::FAILED:
147 event_callback_->OnConnectionFailed(this); 146 event_callback_->OnConnectionFailed(this);
148 break; 147 break;
149 148
150 case ChromotocolConnection::CLOSED: 149 case protocol::Session::CLOSED:
151 event_callback_->OnConnectionClosed(this); 150 event_callback_->OnConnectionClosed(this);
152 break; 151 break;
153 152
154 case ChromotocolConnection::CONNECTED: 153 case protocol::Session::CONNECTED:
155 // Initialize reader and writer. 154 // Initialize reader and writer.
156 control_reader_.Init<ChromotingHostMessage>( 155 control_reader_.Init<ChromotingHostMessage>(
157 connection_->control_channel(), 156 session_->control_channel(),
158 NewCallback(this, &JingleHostConnection::OnControlMessage)); 157 NewCallback(this, &JingleHostConnection::OnControlMessage));
159 event_writer_.Init(connection_->event_channel()); 158 event_writer_.Init(session_->event_channel());
160 video_reader_.reset(VideoReader::Create(connection_->config())); 159 video_reader_.reset(VideoReader::Create(session_->config()));
161 video_reader_->Init(connection_, video_stub_); 160 video_reader_->Init(session_, video_stub_);
162 event_callback_->OnConnectionOpened(this); 161 event_callback_->OnConnectionOpened(this);
163 break; 162 break;
164 163
165 default: 164 default:
166 // Ignore the other states by default. 165 // Ignore the other states by default.
167 break; 166 break;
168 } 167 }
169 } 168 }
170 169
171 MessageLoop* JingleHostConnection::message_loop() { 170 MessageLoop* JingleHostConnection::message_loop() {
172 return context_->jingle_thread()->message_loop(); 171 return context_->jingle_thread()->message_loop();
173 } 172 }
174 173
175 } // namespace remoting 174 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/jingle_host_connection.h ('k') | remoting/host/chromoting_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698