Chromium Code Reviews| Index: blimp/net/blimp_message_output_buffer.h |
| diff --git a/blimp/net/blimp_message_output_buffer.h b/blimp/net/blimp_message_output_buffer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0fff67eedcbc5538e0606213eb32ef5a8cec1d15 |
| --- /dev/null |
| +++ b/blimp/net/blimp_message_output_buffer.h |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BLIMP_NET_BLIMP_MESSAGE_OUTPUT_BUFFER_H_ |
| +#define BLIMP_NET_BLIMP_MESSAGE_OUTPUT_BUFFER_H_ |
| + |
| +#include "base/macros.h" |
| +#include "blimp/net/blimp_message_ack_observer.h" |
| +#include "blimp/net/blimp_message_processor.h" |
| +#include "blimp/net/blimp_net_export.h" |
| + |
| +namespace blimp { |
| + |
| +class BlimpConnection; |
| + |
| +// Provides a FIFO buffer for reliable, ordered message delivery. |
| +// 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.
|
| +// receiving end (via BlimpMessageAckObserver). |
|
Wez
2015/11/12 00:12:54
nit: Indentation.
Kevin M
2015/11/12 01:53:16
Done.
|
| +class BLIMP_NET_EXPORT BlimpMessageOutputBuffer |
| + : public BlimpMessageProcessor, |
| + public BlimpMessageAckObserver { |
| + public: |
| + BlimpMessageOutputBuffer(); |
| + ~BlimpMessageOutputBuffer() override; |
| + |
| + // Sets the processor to receive messages from this buffer. |
| + 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.
|
| + |
| + // BlimpMessageProcessor implementation. |
| + // |callback|, if set, will be called once the remote end has acknowledged the |
| + // receipt of |message|. |
| + // A sequence of N dependent writes with one acknowledgement can be had by |
| + // calling ProcessMessage() N-1 times with an empty |callback|, then |
| + // 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.
|
| + void ProcessMessage(const BlimpMessage& message, |
| + const net::CompletionCallback& callback) override; |
| + |
| + // MessageAckObserver implementation. |
| + // Removes BlimpMessages from the buffer whose ID is less than or equal to |
| + // |message_id|. |
| + // Invokes outstanding CompletionCallbacks for previously unacknowledged |
| + // 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.
|
| + void OnMessageAck(int64 message_id) override; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(BlimpMessageOutputBuffer); |
| +}; |
| + |
| +} // namespace blimp |
| + |
| +#endif // BLIMP_NET_BLIMP_MESSAGE_OUTPUT_BUFFER_H_ |