Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BLIMP_NET_BLIMP_MESSAGE_OUTPUT_BUFFER_H_ | |
| 6 #define BLIMP_NET_BLIMP_MESSAGE_OUTPUT_BUFFER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "blimp/net/blimp_message_ack_observer.h" | |
| 10 #include "blimp/net/blimp_message_processor.h" | |
| 11 #include "blimp/net/blimp_net_export.h" | |
| 12 | |
| 13 namespace blimp { | |
| 14 | |
| 15 class BlimpConnection; | |
| 16 | |
| 17 // Provides a FIFO buffer for reliable, ordered message delivery. | |
| 18 // Messages are available for redelivery until they are acknowledged by the | |
|
Wez
2015/11/12 00:12:54
nit: Class doesn't yet do re-delivery, so suggest
Kevin M
2015/11/12 01:53:16
Done.
| |
| 19 // receiving end (via BlimpMessageAckObserver). | |
|
Wez
2015/11/12 00:12:54
nit: Indentation.
Kevin M
2015/11/12 01:53:16
Done.
| |
| 20 class BLIMP_NET_EXPORT BlimpMessageOutputBuffer | |
| 21 : public BlimpMessageProcessor, | |
| 22 public BlimpMessageAckObserver { | |
| 23 public: | |
| 24 BlimpMessageOutputBuffer(); | |
| 25 ~BlimpMessageOutputBuffer() override; | |
| 26 | |
| 27 // Sets the processor to receive messages from this buffer. | |
| 28 void SetOutgoingMessageProcessor(scoped_ptr<BlimpMessageProcessor> processor); | |
|
Wez
2015/11/12 00:12:54
nit: The other CLs all seem to use bare pointers f
Kevin M
2015/11/12 01:53:16
Done.
| |
| 29 | |
| 30 // BlimpMessageProcessor implementation. | |
| 31 // |callback|, if set, will be called once the remote end has acknowledged the | |
| 32 // receipt of |message|. | |
| 33 // A sequence of N dependent writes with one acknowledgement can be had by | |
| 34 // calling ProcessMessage() N-1 times with an empty |callback|, then | |
| 35 // calling the final (Nth) message with |callback| set. | |
|
Wez
2015/11/12 00:12:54
This is too complicated - that |callback| can be n
Kevin M
2015/11/12 01:53:16
Done.
| |
| 36 void ProcessMessage(const BlimpMessage& message, | |
| 37 const net::CompletionCallback& callback) override; | |
| 38 | |
| 39 // MessageAckObserver implementation. | |
| 40 // Removes BlimpMessages from the buffer whose ID is less than or equal to | |
| 41 // |message_id|. | |
| 42 // Invokes outstanding CompletionCallbacks for previously unacknowledged | |
| 43 // messages which have an ID less than or equal to |message_id|. | |
|
Wez
2015/11/12 00:12:54
nit: Suggest reducing to "Flushes acknowledged mes
Kevin M
2015/11/12 01:53:16
Done.
| |
| 44 void OnMessageAck(int64 message_id) override; | |
| 45 | |
| 46 private: | |
| 47 DISALLOW_COPY_AND_ASSIGN(BlimpMessageOutputBuffer); | |
| 48 }; | |
| 49 | |
| 50 } // namespace blimp | |
| 51 | |
| 52 #endif // BLIMP_NET_BLIMP_MESSAGE_OUTPUT_BUFFER_H_ | |
| OLD | NEW |