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 #include "remoting/host/client_connection.h" | 5 #include "remoting/host/client_connection.h" |
6 | 6 |
7 #include "google/protobuf/message.h" | 7 #include "google/protobuf/message.h" |
8 #include "media/base/data_buffer.h" | 8 #include "media/base/data_buffer.h" |
9 #include "remoting/base/protocol_decoder.h" | 9 #include "remoting/base/protocol_decoder.h" |
10 #include "remoting/base/protocol_util.h" | 10 #include "remoting/base/protocol_util.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 ClientConnection::~ClientConnection() { | 33 ClientConnection::~ClientConnection() { |
34 // TODO(hclam): When we shut down the viewer we may have to close the | 34 // TODO(hclam): When we shut down the viewer we may have to close the |
35 // jingle channel. | 35 // jingle channel. |
36 } | 36 } |
37 | 37 |
38 // static | 38 // static |
39 scoped_refptr<media::DataBuffer> | 39 scoped_refptr<media::DataBuffer> |
40 ClientConnection::CreateWireFormatDataBuffer( | 40 ClientConnection::CreateWireFormatDataBuffer( |
41 const HostMessage* msg) { | 41 const ChromotingHostMessage* msg) { |
42 // TODO(hclam): Instead of serializing |msg| create an DataBuffer | 42 // TODO(hclam): Instead of serializing |msg| create an DataBuffer |
43 // object that wraps around it. | 43 // object that wraps around it. |
44 scoped_ptr<const HostMessage> message_deleter(msg); | 44 scoped_ptr<const ChromotingHostMessage> message_deleter(msg); |
45 return SerializeAndFrameMessage(*msg); | 45 return SerializeAndFrameMessage(*msg); |
46 } | 46 } |
47 | 47 |
48 void ClientConnection::SendInitClientMessage(int width, int height) { | 48 void ClientConnection::SendInitClientMessage(int width, int height) { |
49 DCHECK_EQ(loop_, MessageLoop::current()); | 49 DCHECK_EQ(loop_, MessageLoop::current()); |
50 DCHECK(!update_stream_size_); | 50 DCHECK(!update_stream_size_); |
51 | 51 |
52 // If we are disconnected then return. | 52 // If we are disconnected then return. |
53 if (!channel_) | 53 if (!channel_) |
54 return; | 54 return; |
55 | 55 |
56 HostMessage msg; | 56 ChromotingHostMessage msg; |
57 msg.mutable_init_client()->set_width(width); | 57 msg.mutable_init_client()->set_width(width); |
58 msg.mutable_init_client()->set_height(height); | 58 msg.mutable_init_client()->set_height(height); |
59 DCHECK(msg.IsInitialized()); | 59 DCHECK(msg.IsInitialized()); |
60 channel_->Write(SerializeAndFrameMessage(msg)); | 60 channel_->Write(SerializeAndFrameMessage(msg)); |
61 } | 61 } |
62 | 62 |
63 void ClientConnection::SendBeginUpdateStreamMessage() { | 63 void ClientConnection::SendBeginUpdateStreamMessage() { |
64 DCHECK_EQ(loop_, MessageLoop::current()); | 64 DCHECK_EQ(loop_, MessageLoop::current()); |
65 | 65 |
66 // If we are disconnected then return. | 66 // If we are disconnected then return. |
67 if (!channel_) | 67 if (!channel_) |
68 return; | 68 return; |
69 | 69 |
70 HostMessage msg; | 70 ChromotingHostMessage msg; |
71 msg.mutable_begin_update_stream(); | 71 msg.mutable_begin_update_stream(); |
72 DCHECK(msg.IsInitialized()); | 72 DCHECK(msg.IsInitialized()); |
73 | 73 |
74 scoped_refptr<DataBuffer> data = SerializeAndFrameMessage(msg); | 74 scoped_refptr<DataBuffer> data = SerializeAndFrameMessage(msg); |
75 DCHECK(!update_stream_size_); | 75 DCHECK(!update_stream_size_); |
76 update_stream_size_ += data->GetDataSize(); | 76 update_stream_size_ += data->GetDataSize(); |
77 channel_->Write(data); | 77 channel_->Write(data); |
78 } | 78 } |
79 | 79 |
80 void ClientConnection::SendUpdateStreamPacketMessage( | 80 void ClientConnection::SendUpdateStreamPacketMessage( |
81 scoped_refptr<DataBuffer> data) { | 81 scoped_refptr<DataBuffer> data) { |
82 DCHECK_EQ(loop_, MessageLoop::current()); | 82 DCHECK_EQ(loop_, MessageLoop::current()); |
83 | 83 |
84 // If we are disconnected then return. | 84 // If we are disconnected then return. |
85 if (!channel_) | 85 if (!channel_) |
86 return; | 86 return; |
87 | 87 |
88 update_stream_size_ += data->GetDataSize(); | 88 update_stream_size_ += data->GetDataSize(); |
89 channel_->Write(data); | 89 channel_->Write(data); |
90 } | 90 } |
91 | 91 |
92 void ClientConnection::SendEndUpdateStreamMessage() { | 92 void ClientConnection::SendEndUpdateStreamMessage() { |
93 DCHECK_EQ(loop_, MessageLoop::current()); | 93 DCHECK_EQ(loop_, MessageLoop::current()); |
94 | 94 |
95 // If we are disconnected then return. | 95 // If we are disconnected then return. |
96 if (!channel_) | 96 if (!channel_) |
97 return; | 97 return; |
98 | 98 |
99 HostMessage msg; | 99 ChromotingHostMessage msg; |
100 msg.mutable_end_update_stream(); | 100 msg.mutable_end_update_stream(); |
101 DCHECK(msg.IsInitialized()); | 101 DCHECK(msg.IsInitialized()); |
102 | 102 |
103 scoped_refptr<DataBuffer> data = SerializeAndFrameMessage(msg); | 103 scoped_refptr<DataBuffer> data = SerializeAndFrameMessage(msg); |
104 update_stream_size_ += data->GetDataSize(); | 104 update_stream_size_ += data->GetDataSize(); |
105 channel_->Write(data); | 105 channel_->Write(data); |
106 | 106 |
107 // Here's some logic to help finding the average update stream size. | 107 // Here's some logic to help finding the average update stream size. |
108 size_in_queue_ += update_stream_size_; | 108 size_in_queue_ += update_stream_size_; |
109 size_queue_.push_back(update_stream_size_); | 109 size_queue_.push_back(update_stream_size_); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 DCHECK(decoder_.get()); | 180 DCHECK(decoder_.get()); |
181 ClientMessageList list; | 181 ClientMessageList list; |
182 decoder_->ParseClientMessages(data, &list); | 182 decoder_->ParseClientMessages(data, &list); |
183 | 183 |
184 // Then submit the messages to the handler. | 184 // Then submit the messages to the handler. |
185 DCHECK(handler_); | 185 DCHECK(handler_); |
186 handler_->HandleMessages(this, &list); | 186 handler_->HandleMessages(this, &list); |
187 } | 187 } |
188 | 188 |
189 } // namespace remoting | 189 } // namespace remoting |
OLD | NEW |