Index: remoting/protocol/message_reader.cc |
diff --git a/remoting/protocol/message_reader.cc b/remoting/protocol/message_reader.cc |
index 6e3d5369bf2ca690b8e4d4ce740b176dbf30a4a9..9c1c516cc2af9386a07ff80ad93c797850f626ff 100644 |
--- a/remoting/protocol/message_reader.cc |
+++ b/remoting/protocol/message_reader.cc |
@@ -90,6 +90,11 @@ void MessageReader::HandleReadResult(int result) { |
void MessageReader::OnDataReceived(net::IOBuffer* data, int data_size) { |
DCHECK(CalledOnValidThread()); |
+ |
+ base::TimeTicks now = base::TimeTicks::Now(); |
+ |
+ if (message_decoder_.is_buffer_empty()) |
+ last_message_started_time_ = now; |
Wez
2015/01/21 01:35:40
nit: Blank line after this?
This logic doesn't se
Sergey Ulanov
2015/01/29 01:33:29
Yes, I noticed it myself too. Fixed now and update
|
message_decoder_.AddData(data, data_size); |
// Get list of all new messages first, and then call the callback |
@@ -99,16 +104,18 @@ void MessageReader::OnDataReceived(net::IOBuffer* data, int data_size) { |
if (!buffer) |
break; |
pending_messages_++; |
+ base::TimeDelta read_delay = now - last_message_started_time_; |
base::ThreadTaskRunnerHandle::Get()->PostTask( |
FROM_HERE, |
- base::Bind(&MessageReader::RunCallback, |
- weak_factory_.GetWeakPtr(), |
- base::Passed(make_scoped_ptr(buffer)))); |
+ base::Bind(&MessageReader::RunCallback, weak_factory_.GetWeakPtr(), |
+ base::Passed(make_scoped_ptr(buffer)), read_delay)); |
} |
} |
-void MessageReader::RunCallback(scoped_ptr<CompoundBuffer> message) { |
- if (!message_received_callback_.is_null()){ |
+void MessageReader::RunCallback(scoped_ptr<CompoundBuffer> message, |
+ base::TimeDelta read_delay) { |
+ last_message_read_delay_ = read_delay; |
+ if (!message_received_callback_.is_null()) { |
message_received_callback_.Run( |
message.Pass(), |
base::Bind(&MessageReader::OnMessageDone, weak_factory_.GetWeakPtr())); |