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

Side by Side Diff: remoting/protocol/message_reader.h

Issue 850983002: Implement video frame acknowledgements in the chromoting protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef REMOTING_PROTOCOL_MESSAGE_READER_H_ 5 #ifndef REMOTING_PROTOCOL_MESSAGE_READER_H_
6 #define REMOTING_PROTOCOL_MESSAGE_READER_H_ 6 #define REMOTING_PROTOCOL_MESSAGE_READER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/non_thread_safe.h" 11 #include "base/threading/non_thread_safe.h"
12 #include "base/time/time.h"
12 #include "remoting/base/compound_buffer.h" 13 #include "remoting/base/compound_buffer.h"
13 #include "remoting/protocol/message_decoder.h" 14 #include "remoting/protocol/message_decoder.h"
14 15
15 namespace net { 16 namespace net {
16 class IOBuffer; 17 class IOBuffer;
17 class Socket; 18 class Socket;
18 } // namespace net 19 } // namespace net
19 20
20 namespace remoting { 21 namespace remoting {
21 namespace protocol { 22 namespace protocol {
(...skipping 16 matching lines...) Expand all
38 39
39 MessageReader(); 40 MessageReader();
40 virtual ~MessageReader(); 41 virtual ~MessageReader();
41 42
42 // Sets the callback to be called for each incoming message. 43 // Sets the callback to be called for each incoming message.
43 void SetMessageReceivedCallback(const MessageReceivedCallback& callback); 44 void SetMessageReceivedCallback(const MessageReceivedCallback& callback);
44 45
45 // Starts reading from |socket|. 46 // Starts reading from |socket|.
46 void StartReading(net::Socket* socket); 47 void StartReading(net::Socket* socket);
47 48
49 base::TimeDelta last_message_read_delay() {
Wez 2015/01/21 01:35:40 nit: Add a brief comment to explain what this mean
Sergey Ulanov 2015/01/29 01:33:29 Done.
50 return last_message_read_delay_;
51 }
52
48 private: 53 private:
49 void DoRead(); 54 void DoRead();
50 void OnRead(int result); 55 void OnRead(int result);
51 void HandleReadResult(int result); 56 void HandleReadResult(int result);
52 void OnDataReceived(net::IOBuffer* data, int data_size); 57 void OnDataReceived(net::IOBuffer* data, int data_size);
53 void RunCallback(scoped_ptr<CompoundBuffer> message); 58 void RunCallback(scoped_ptr<CompoundBuffer> message,
59 base::TimeDelta read_delay);
54 void OnMessageDone(); 60 void OnMessageDone();
55 61
56 net::Socket* socket_; 62 net::Socket* socket_;
57 63
58 // Set to true, when we have a socket read pending, and expecting 64 // Set to true, when we have a socket read pending, and expecting
59 // OnRead() to be called when new data is received. 65 // OnRead() to be called when new data is received.
60 bool read_pending_; 66 bool read_pending_;
61 67
62 // Number of messages that we received, but haven't finished 68 // Number of messages that we received, but haven't finished
63 // processing yet, i.e. |done_task| hasn't been called for these 69 // processing yet, i.e. |done_task| hasn't been called for these
64 // messages. 70 // messages.
65 int pending_messages_; 71 int pending_messages_;
66 72
67 bool closed_; 73 bool closed_;
68 scoped_refptr<net::IOBuffer> read_buffer_; 74 scoped_refptr<net::IOBuffer> read_buffer_;
69 75
70 MessageDecoder message_decoder_; 76 MessageDecoder message_decoder_;
71 77
72 // Callback is called when a message is received. 78 // Callback is called when a message is received.
73 MessageReceivedCallback message_received_callback_; 79 MessageReceivedCallback message_received_callback_;
74 80
81 base::TimeTicks last_message_started_time_;
82 base::TimeDelta last_message_read_delay_;
Wez 2015/01/21 01:35:40 nit: Suggest adding a block comment e.g. "Used to
Sergey Ulanov 2015/01/29 01:33:29 Done.
83
75 base::WeakPtrFactory<MessageReader> weak_factory_; 84 base::WeakPtrFactory<MessageReader> weak_factory_;
76 85
77 DISALLOW_COPY_AND_ASSIGN(MessageReader); 86 DISALLOW_COPY_AND_ASSIGN(MessageReader);
78 }; 87 };
79 88
80 } // namespace protocol 89 } // namespace protocol
81 } // namespace remoting 90 } // namespace remoting
82 91
83 #endif // REMOTING_PROTOCOL_MESSAGE_READER_H_ 92 #endif // REMOTING_PROTOCOL_MESSAGE_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698