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

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

Issue 1654513003: Simplify message parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no_done
Patch Set: Created 4 years, 10 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
« no previous file with comments | « remoting/protocol/ice_connection_to_host.h ('k') | remoting/protocol/message_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 24 matching lines...) Expand all
35 // e.g. when we the sender sends multiple messages in one TCP packet. 35 // e.g. when we the sender sends multiple messages in one TCP packet.
36 class MessageReader : public base::NonThreadSafe { 36 class MessageReader : public base::NonThreadSafe {
37 public: 37 public:
38 typedef base::Callback<void(scoped_ptr<CompoundBuffer> message)> 38 typedef base::Callback<void(scoped_ptr<CompoundBuffer> message)>
39 MessageReceivedCallback; 39 MessageReceivedCallback;
40 typedef base::Callback<void(int)> ReadFailedCallback; 40 typedef base::Callback<void(int)> ReadFailedCallback;
41 41
42 MessageReader(); 42 MessageReader();
43 virtual ~MessageReader(); 43 virtual ~MessageReader();
44 44
45 // Sets the callback to be called for each incoming message.
46 void SetMessageReceivedCallback(const MessageReceivedCallback& callback);
47
48 // Starts reading from |socket|. 45 // Starts reading from |socket|.
49 void StartReading(P2PStreamSocket* socket, 46 void StartReading(P2PStreamSocket* socket,
47 const MessageReceivedCallback& message_received_callback,
50 const ReadFailedCallback& read_failed_callback); 48 const ReadFailedCallback& read_failed_callback);
51 49
52 private: 50 private:
53 void DoRead(); 51 void DoRead();
54 void OnRead(int result); 52 void OnRead(int result);
55 void HandleReadResult(int result, bool* read_succeeded); 53 void HandleReadResult(int result, bool* read_succeeded);
56 void OnDataReceived(net::IOBuffer* data, int data_size); 54 void OnDataReceived(net::IOBuffer* data, int data_size);
57 void RunCallback(scoped_ptr<CompoundBuffer> message); 55 void RunCallback(scoped_ptr<CompoundBuffer> message);
58 56
59 ReadFailedCallback read_failed_callback_; 57 ReadFailedCallback read_failed_callback_;
(...skipping 14 matching lines...) Expand all
74 72
75 base::WeakPtrFactory<MessageReader> weak_factory_; 73 base::WeakPtrFactory<MessageReader> weak_factory_;
76 74
77 DISALLOW_COPY_AND_ASSIGN(MessageReader); 75 DISALLOW_COPY_AND_ASSIGN(MessageReader);
78 }; 76 };
79 77
80 } // namespace protocol 78 } // namespace protocol
81 } // namespace remoting 79 } // namespace remoting
82 80
83 #endif // REMOTING_PROTOCOL_MESSAGE_READER_H_ 81 #endif // REMOTING_PROTOCOL_MESSAGE_READER_H_
OLDNEW
« no previous file with comments | « remoting/protocol/ice_connection_to_host.h ('k') | remoting/protocol/message_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698