OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 BLIMP_NET_BLIMP_MESSAGE_PUMP_H_ | 5 #ifndef BLIMP_NET_BLIMP_MESSAGE_PUMP_H_ |
6 #define BLIMP_NET_BLIMP_MESSAGE_PUMP_H_ | 6 #define BLIMP_NET_BLIMP_MESSAGE_PUMP_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 | 44 |
45 private: | 45 private: |
46 // Read next packet from |reader_|. | 46 // Read next packet from |reader_|. |
47 void ReadNextPacket(); | 47 void ReadNextPacket(); |
48 | 48 |
49 // Callback when next packet is ready in |buffer_|. | 49 // Callback when next packet is ready in |buffer_|. |
50 void OnReadPacketComplete(int result); | 50 void OnReadPacketComplete(int result); |
51 | 51 |
52 // Callback when |processor_| finishes processing a BlimpMessage. | 52 // Callback when |processor_| finishes processing a BlimpMessage. |
| 53 // Any values other than net::OK indicate that |processor_| has encountered an |
| 54 // error that should be handled. Currently all errors will cause the |
| 55 // connection to be dropped; in the future we will need to add more |
| 56 // sophisticated error handling logic here. |
| 57 // TODO(kmarshall): Improve error handling. |
53 void OnProcessMessageComplete(int result); | 58 void OnProcessMessageComplete(int result); |
54 | 59 |
55 PacketReader* reader_; | 60 PacketReader* reader_; |
56 ConnectionErrorObserver* error_observer_ = nullptr; | 61 ConnectionErrorObserver* error_observer_ = nullptr; |
57 BlimpMessageProcessor* processor_ = nullptr; | 62 BlimpMessageProcessor* processor_ = nullptr; |
58 scoped_refptr<net::GrowableIOBuffer> buffer_; | 63 scoped_refptr<net::GrowableIOBuffer> buffer_; |
59 bool read_inflight_ = false; | 64 bool read_inflight_ = false; |
60 | 65 |
61 // Cancelled in the event that the connection is destroyed (along with | 66 // Cancelled in the event that the connection is destroyed (along with |
62 // |this|) while a inflight callback is held by |processor_|. | 67 // |this|) while a inflight callback is held by |processor_|. |
63 net::CancelableCompletionCallback process_msg_callback_; | 68 net::CancelableCompletionCallback process_msg_callback_; |
64 | 69 |
65 // Cancelled to guard against |this| being called back from a completed read | 70 // Cancelled to guard against |this| being called back from a completed read |
66 // operation. | 71 // operation. |
67 net::CancelableCompletionCallback read_callback_; | 72 net::CancelableCompletionCallback read_callback_; |
68 | 73 |
69 DISALLOW_COPY_AND_ASSIGN(BlimpMessagePump); | 74 DISALLOW_COPY_AND_ASSIGN(BlimpMessagePump); |
70 }; | 75 }; |
71 | 76 |
72 } // namespace blimp | 77 } // namespace blimp |
73 | 78 |
74 #endif // BLIMP_NET_BLIMP_MESSAGE_PUMP_H_ | 79 #endif // BLIMP_NET_BLIMP_MESSAGE_PUMP_H_ |
OLD | NEW |