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

Side by Side Diff: remoting/host/client_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/host/client_connection.h ('k') | remoting/host/client_connection_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) 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 // TODO(hclam): Remove this header once MessageDispatcher is used. 5 // TODO(hclam): Remove this header once MessageDispatcher is used.
6 #include "remoting/base/multiple_array_input_stream.h" 6 #include "remoting/base/multiple_array_input_stream.h"
7 #include "remoting/host/client_connection.h" 7 #include "remoting/host/client_connection.h"
8 8
9 #include "google/protobuf/message.h" 9 #include "google/protobuf/message.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 11 matching lines...) Expand all
22 handler_(handler) { 22 handler_(handler) {
23 DCHECK(loop_); 23 DCHECK(loop_);
24 DCHECK(handler_); 24 DCHECK(handler_);
25 } 25 }
26 26
27 ClientConnection::~ClientConnection() { 27 ClientConnection::~ClientConnection() {
28 // TODO(hclam): When we shut down the viewer we may have to close the 28 // TODO(hclam): When we shut down the viewer we may have to close the
29 // connection. 29 // connection.
30 } 30 }
31 31
32 void ClientConnection::Init(ChromotocolConnection* connection) { 32 void ClientConnection::Init(protocol::Session* session) {
33 DCHECK_EQ(connection->message_loop(), MessageLoop::current()); 33 DCHECK_EQ(session->message_loop(), MessageLoop::current());
34 34
35 connection_ = connection; 35 session_ = session;
36 connection_->SetStateChangeCallback( 36 session_->SetStateChangeCallback(
37 NewCallback(this, &ClientConnection::OnConnectionStateChange)); 37 NewCallback(this, &ClientConnection::OnSessionStateChange));
38 } 38 }
39 39
40 ChromotocolConnection* ClientConnection::connection() { 40 protocol::Session* ClientConnection::session() {
41 return connection_; 41 return session_;
42 } 42 }
43 43
44 void ClientConnection::SendInitClientMessage(int width, int height) { 44 void ClientConnection::SendInitClientMessage(int width, int height) {
45 DCHECK_EQ(loop_, MessageLoop::current()); 45 DCHECK_EQ(loop_, MessageLoop::current());
46 46
47 // If we are disconnected then return. 47 // If we are disconnected then return.
48 if (!connection_) 48 if (!session_)
49 return; 49 return;
50 50
51 ChromotingHostMessage msg; 51 ChromotingHostMessage msg;
52 msg.mutable_init_client()->set_width(width); 52 msg.mutable_init_client()->set_width(width);
53 msg.mutable_init_client()->set_height(height); 53 msg.mutable_init_client()->set_height(height);
54 DCHECK(msg.IsInitialized()); 54 DCHECK(msg.IsInitialized());
55 control_writer_.SendMessage(msg); 55 control_writer_.SendMessage(msg);
56 } 56 }
57 57
58 void ClientConnection::SendVideoPacket(const VideoPacket& packet) { 58 void ClientConnection::SendVideoPacket(const VideoPacket& packet) {
59 DCHECK_EQ(loop_, MessageLoop::current()); 59 DCHECK_EQ(loop_, MessageLoop::current());
60 60
61 // If we are disconnected then return. 61 // If we are disconnected then return.
62 if (!connection_) 62 if (!session_)
63 return; 63 return;
64 64
65 video_writer_->SendPacket(packet); 65 video_writer_->SendPacket(packet);
66 } 66 }
67 67
68 int ClientConnection::GetPendingUpdateStreamMessages() { 68 int ClientConnection::GetPendingUpdateStreamMessages() {
69 DCHECK_EQ(loop_, MessageLoop::current()); 69 DCHECK_EQ(loop_, MessageLoop::current());
70 return video_writer_->GetPendingPackets(); 70 return video_writer_->GetPendingPackets();
71 } 71 }
72 72
73 void ClientConnection::Disconnect() { 73 void ClientConnection::Disconnect() {
74 DCHECK_EQ(loop_, MessageLoop::current()); 74 DCHECK_EQ(loop_, MessageLoop::current());
75 75
76 // If there is a channel then close it and release the reference. 76 // If there is a channel then close it and release the reference.
77 if (connection_) { 77 if (session_) {
78 connection_->Close(NewRunnableMethod(this, &ClientConnection::OnClosed)); 78 session_->Close(NewRunnableMethod(this, &ClientConnection::OnClosed));
79 connection_ = NULL; 79 session_ = NULL;
80 } 80 }
81 } 81 }
82 82
83 ClientConnection::ClientConnection() {} 83 ClientConnection::ClientConnection() {}
84 84
85 void ClientConnection::OnConnectionStateChange( 85 void ClientConnection::OnSessionStateChange(
86 ChromotocolConnection::State state) { 86 protocol::Session::State state) {
87 if (state == ChromotocolConnection::CONNECTED) { 87 if (state == protocol::Session::CONNECTED) {
88 control_writer_.Init(connection_->control_channel()); 88 control_writer_.Init(session_->control_channel());
89 event_reader_.Init<ChromotingClientMessage>( 89 event_reader_.Init<ChromotingClientMessage>(
90 connection_->event_channel(), 90 session_->event_channel(),
91 NewCallback(this, &ClientConnection::OnMessageReceived)); 91 NewCallback(this, &ClientConnection::OnMessageReceived));
92 video_writer_.reset(VideoWriter::Create(connection_->config())); 92 video_writer_.reset(VideoWriter::Create(session_->config()));
93 video_writer_->Init(connection_); 93 video_writer_->Init(session_);
94 } 94 }
95 95
96 loop_->PostTask(FROM_HERE, 96 loop_->PostTask(FROM_HERE,
97 NewRunnableMethod(this, &ClientConnection::StateChangeTask, state)); 97 NewRunnableMethod(this, &ClientConnection::StateChangeTask, state));
98 } 98 }
99 99
100 void ClientConnection::OnMessageReceived(ChromotingClientMessage* message) { 100 void ClientConnection::OnMessageReceived(ChromotingClientMessage* message) {
101 loop_->PostTask(FROM_HERE, 101 loop_->PostTask(FROM_HERE,
102 NewRunnableMethod(this, &ClientConnection::MessageReceivedTask, 102 NewRunnableMethod(this, &ClientConnection::MessageReceivedTask,
103 message)); 103 message));
104 } 104 }
105 105
106 void ClientConnection::StateChangeTask(ChromotocolConnection::State state) { 106 void ClientConnection::StateChangeTask(protocol::Session::State state) {
107 DCHECK_EQ(loop_, MessageLoop::current()); 107 DCHECK_EQ(loop_, MessageLoop::current());
108 108
109 DCHECK(handler_); 109 DCHECK(handler_);
110 switch(state) { 110 switch(state) {
111 case ChromotocolConnection::CONNECTING: 111 case protocol::Session::CONNECTING:
112 break; 112 break;
113 // Don't care about this message. 113 // Don't care about this message.
114 case ChromotocolConnection::CONNECTED: 114 case protocol::Session::CONNECTED:
115 handler_->OnConnectionOpened(this); 115 handler_->OnConnectionOpened(this);
116 break; 116 break;
117 case ChromotocolConnection::CLOSED: 117 case protocol::Session::CLOSED:
118 handler_->OnConnectionClosed(this); 118 handler_->OnConnectionClosed(this);
119 break; 119 break;
120 case ChromotocolConnection::FAILED: 120 case protocol::Session::FAILED:
121 handler_->OnConnectionFailed(this); 121 handler_->OnConnectionFailed(this);
122 break; 122 break;
123 default: 123 default:
124 // We shouldn't receive other states. 124 // We shouldn't receive other states.
125 NOTREACHED(); 125 NOTREACHED();
126 } 126 }
127 } 127 }
128 128
129 void ClientConnection::MessageReceivedTask(ChromotingClientMessage* message) { 129 void ClientConnection::MessageReceivedTask(ChromotingClientMessage* message) {
130 DCHECK_EQ(loop_, MessageLoop::current()); 130 DCHECK_EQ(loop_, MessageLoop::current());
131 DCHECK(handler_); 131 DCHECK(handler_);
132 handler_->HandleMessage(this, message); 132 handler_->HandleMessage(this, message);
133 } 133 }
134 134
135 // OnClosed() is used as a callback for ChromotocolConnection::Close(). 135 // OnClosed() is used as a callback for protocol::Session::Close().
136 void ClientConnection::OnClosed() { 136 void ClientConnection::OnClosed() {
137 } 137 }
138 138
139 } // namespace remoting 139 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/client_connection.h ('k') | remoting/host/client_connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698