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

Side by Side Diff: blimp/net/blimp_message_output_buffer.h

Issue 1429193002: Add interfaces for most major Blimp net components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address haibinlu's feedback #2 Created 5 years, 1 month 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
(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
19 // receiving end (via BlimpMessageAckObserver).
20 class BLIMP_NET_EXPORT BlimpMessageOutputBuffer
21 : public BlimpMessageProcessor,
22 public BlimpMessageAckObserver {
23 public:
24 BlimpMessageOutputBuffer();
25
26 ~BlimpMessageOutputBuffer() override;
27
28 // Sets the processor for receiving messages from this buffer.
29 void SetOutgoingMessageProcessor(scoped_ptr<BlimpMessageProcessor> processor);
30
31 // BlimpMessageProcessor implementation.
32 // |callback|, if set, will be called once the remote end has acknowledged the
33 // receipt of |message|.
34 // A sequence of N dependent writes with one acknowledgement can be had by
35 // calling ProcessMessage() N-1 times with an empty |callback|, then
36 // calling the final (Nth) message with |callback| set.
37 void ProcessMessage(const BlimpMessage& message,
38 const net::CompletionCallback& callback) override;
39
40 // MessageAckObserver implementation.
41 // Removes BlimpMessages from the buffer whose ID is less than or equal to
42 // |message_id|.
43 // Invokes outstanding CompletionCallbacks for previously unacknowledged
44 // messages which have an ID less than or equal to |message_id|.
45 void OnMessageAck(int64 message_id) override;
46
47 private:
48 DISALLOW_COPY_AND_ASSIGN(BlimpMessageOutputBuffer);
49 };
50
51 } // namespace blimp
52
53 #endif // BLIMP_NET_BLIMP_MESSAGE_OUTPUT_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698