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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_); |
110 if (size_queue_.size() > kAverageUpdateStream) { | 110 if (size_queue_.size() > kAverageUpdateStream) { |
111 size_in_queue_ -= size_queue_.front(); | 111 size_in_queue_ -= size_queue_.front(); |
112 size_queue_.pop_front(); | 112 size_queue_.pop_front(); |
113 DCHECK_GE(size_in_queue_, 0); | 113 DCHECK_GE(size_in_queue_, 0); |
114 } | 114 } |
115 update_stream_size_ = 0; | 115 update_stream_size_ = 0; |
116 } | 116 } |
117 | 117 |
| 118 void ClientConnection::MarkEndOfUpdate() { |
| 119 // This is some logic to help calculate the average update stream size. |
| 120 size_in_queue_ += update_stream_size_; |
| 121 size_queue_.push_back(update_stream_size_); |
| 122 if (size_queue_.size() > kAverageUpdateStream) { |
| 123 size_in_queue_ -= size_queue_.front(); |
| 124 size_queue_.pop_front(); |
| 125 DCHECK_GE(size_in_queue_, 0); |
| 126 } |
| 127 update_stream_size_ = 0; |
| 128 } |
| 129 |
118 int ClientConnection::GetPendingUpdateStreamMessages() { | 130 int ClientConnection::GetPendingUpdateStreamMessages() { |
119 DCHECK_EQ(loop_, MessageLoop::current()); | 131 DCHECK_EQ(loop_, MessageLoop::current()); |
120 | 132 |
121 if (!size_queue_.size()) | 133 if (!size_queue_.size()) |
122 return 0; | 134 return 0; |
123 int average_size = size_in_queue_ / size_queue_.size(); | 135 int average_size = size_in_queue_ / size_queue_.size(); |
124 if (!average_size) | 136 if (!average_size) |
125 return 0; | 137 return 0; |
126 return channel_->write_buffer_size() / average_size; | 138 return channel_->write_buffer_size() / average_size; |
127 } | 139 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 DCHECK(decoder_.get()); | 192 DCHECK(decoder_.get()); |
181 ClientMessageList list; | 193 ClientMessageList list; |
182 decoder_->ParseClientMessages(data, &list); | 194 decoder_->ParseClientMessages(data, &list); |
183 | 195 |
184 // Then submit the messages to the handler. | 196 // Then submit the messages to the handler. |
185 DCHECK(handler_); | 197 DCHECK(handler_); |
186 handler_->HandleMessages(this, &list); | 198 handler_->HandleMessages(this, &list); |
187 } | 199 } |
188 | 200 |
189 } // namespace remoting | 201 } // namespace remoting |
OLD | NEW |