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 // TODO(hclam): Remove this header once MessageDispatcher is used. |
| 6 #include "remoting/base/multiple_array_input_stream.h" |
5 #include "remoting/host/client_connection.h" | 7 #include "remoting/host/client_connection.h" |
6 | 8 |
7 #include "google/protobuf/message.h" | 9 #include "google/protobuf/message.h" |
8 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
9 #include "remoting/protocol/messages_decoder.h" | |
10 #include "remoting/protocol/util.h" | 11 #include "remoting/protocol/util.h" |
11 | 12 |
12 namespace remoting { | 13 namespace remoting { |
13 | 14 |
14 // Determine how many update streams we should count to find the size of | 15 // Determine how many update streams we should count to find the size of |
15 // average update stream. | 16 // average update stream. |
16 static const size_t kAverageUpdateStream = 10; | 17 static const size_t kAverageUpdateStream = 10; |
17 | 18 |
18 ClientConnection::ClientConnection(MessageLoop* message_loop, | 19 ClientConnection::ClientConnection(MessageLoop* message_loop, |
19 EventHandler* handler) | 20 EventHandler* handler) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 connection_->Close(NewRunnableMethod(this, &ClientConnection::OnClosed)); | 79 connection_->Close(NewRunnableMethod(this, &ClientConnection::OnClosed)); |
79 connection_ = NULL; | 80 connection_ = NULL; |
80 } | 81 } |
81 } | 82 } |
82 | 83 |
83 ClientConnection::ClientConnection() {} | 84 ClientConnection::ClientConnection() {} |
84 | 85 |
85 void ClientConnection::OnConnectionStateChange( | 86 void ClientConnection::OnConnectionStateChange( |
86 ChromotocolConnection::State state) { | 87 ChromotocolConnection::State state) { |
87 if (state == ChromotocolConnection::CONNECTED) { | 88 if (state == ChromotocolConnection::CONNECTED) { |
88 event_reader_.Init( | 89 event_reader_.Init<ChromotingClientMessage>( |
89 connection_->event_channel(), | 90 connection_->event_channel(), |
90 NewCallback(this, &ClientConnection::OnMessageReceived)); | 91 NewCallback(this, &ClientConnection::OnMessageReceived)); |
91 video_writer_.Init(connection_->video_channel()); | 92 video_writer_.Init(connection_->video_channel()); |
92 } | 93 } |
93 | 94 |
94 loop_->PostTask(FROM_HERE, | 95 loop_->PostTask(FROM_HERE, |
95 NewRunnableMethod(this, &ClientConnection::StateChangeTask, state)); | 96 NewRunnableMethod(this, &ClientConnection::StateChangeTask, state)); |
96 } | 97 } |
97 | 98 |
98 void ClientConnection::OnMessageReceived(ChromotingClientMessage* message) { | 99 void ClientConnection::OnMessageReceived(ChromotingClientMessage* message) { |
(...skipping 29 matching lines...) Expand all Loading... |
128 DCHECK_EQ(loop_, MessageLoop::current()); | 129 DCHECK_EQ(loop_, MessageLoop::current()); |
129 DCHECK(handler_); | 130 DCHECK(handler_); |
130 handler_->HandleMessage(this, message); | 131 handler_->HandleMessage(this, message); |
131 } | 132 } |
132 | 133 |
133 // OnClosed() is used as a callback for ChromotocolConnection::Close(). | 134 // OnClosed() is used as a callback for ChromotocolConnection::Close(). |
134 void ClientConnection::OnClosed() { | 135 void ClientConnection::OnClosed() { |
135 } | 136 } |
136 | 137 |
137 } // namespace remoting | 138 } // namespace remoting |
OLD | NEW |