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_CONNECTION_H_ | 5 #ifndef BLIMP_NET_BLIMP_CONNECTION_H_ |
6 #define BLIMP_NET_BLIMP_CONNECTION_H_ | 6 #define BLIMP_NET_BLIMP_CONNECTION_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "blimp/net/blimp_net_export.h" | 12 #include "blimp/net/blimp_net_export.h" |
13 #include "blimp/net/connection_error_observer.h" | 13 #include "blimp/net/connection_error_observer.h" |
14 | 14 |
15 namespace blimp { | 15 namespace blimp { |
16 | 16 |
17 class BlimpConnectionStatistics; | |
17 class BlimpMessageProcessor; | 18 class BlimpMessageProcessor; |
18 class BlimpMessagePump; | 19 class BlimpMessagePump; |
19 class PacketReader; | 20 class PacketReader; |
20 class PacketWriter; | 21 class PacketWriter; |
21 | 22 |
22 // Encapsulates the state and logic used to exchange BlimpMessages over | 23 // Encapsulates the state and logic used to exchange BlimpMessages over |
23 // a network connection. | 24 // a network connection. |
24 class BLIMP_NET_EXPORT BlimpConnection : public ConnectionErrorObserver { | 25 class BLIMP_NET_EXPORT BlimpConnection : public ConnectionErrorObserver { |
25 public: | 26 public: |
26 BlimpConnection(std::unique_ptr<PacketReader> reader, | 27 BlimpConnection(std::unique_ptr<PacketReader> reader, |
27 std::unique_ptr<PacketWriter> writer); | 28 std::unique_ptr<PacketWriter> writer); |
28 | 29 |
29 ~BlimpConnection() override; | 30 ~BlimpConnection() override; |
30 | 31 |
31 // Adds |observer| to the connection's error observer list. | 32 // Adds |observer| to the connection's error observer list. |
32 virtual void AddConnectionErrorObserver(ConnectionErrorObserver* observer); | 33 virtual void AddConnectionErrorObserver(ConnectionErrorObserver* observer); |
33 | 34 |
34 // Removes |observer| from the connection's error observer list. | 35 // Removes |observer| from the connection's error observer list. |
35 virtual void RemoveConnectionErrorObserver(ConnectionErrorObserver* observer); | 36 virtual void RemoveConnectionErrorObserver(ConnectionErrorObserver* observer); |
36 | 37 |
37 // Sets the processor which will take incoming messages for this connection. | 38 // Sets the processor which will take incoming messages for this connection. |
38 // Can be set multiple times, but previously set processors are discarded. | 39 // Can be set multiple times, but previously set processors are discarded. |
39 // Caller retains the ownership of |processor|. | 40 // Caller retains the ownership of |processor|. |
40 virtual void SetIncomingMessageProcessor(BlimpMessageProcessor* processor); | 41 virtual void SetIncomingMessageProcessor(BlimpMessageProcessor* processor); |
41 | 42 |
42 // Gets a processor for BrowserSession->BlimpConnection message routing. | 43 // Gets a processor for BrowserSession->BlimpConnection message routing. |
43 virtual BlimpMessageProcessor* GetOutgoingMessageProcessor(); | 44 virtual BlimpMessageProcessor* GetOutgoingMessageProcessor(); |
44 | 45 |
46 void SetBlimpConnectionStatistics(BlimpConnectionStatistics* statistics); | |
Kevin M
2016/05/24 01:02:01
Add comment
shaktisahu
2016/05/24 21:02:44
Removed function since we are passing in construct
| |
47 | |
45 protected: | 48 protected: |
46 BlimpConnection(); | 49 BlimpConnection(); |
47 | 50 |
48 // ConnectionErrorObserver implementation. | 51 // ConnectionErrorObserver implementation. |
49 void OnConnectionError(int error) override; | 52 void OnConnectionError(int error) override; |
50 | 53 |
51 private: | 54 private: |
52 std::unique_ptr<PacketReader> reader_; | 55 std::unique_ptr<PacketReader> reader_; |
53 std::unique_ptr<BlimpMessagePump> message_pump_; | 56 std::unique_ptr<BlimpMessagePump> message_pump_; |
54 std::unique_ptr<PacketWriter> writer_; | 57 std::unique_ptr<PacketWriter> writer_; |
55 std::unique_ptr<BlimpMessageProcessor> outgoing_msg_processor_; | 58 std::unique_ptr<BlimpMessageProcessor> outgoing_msg_processor_; |
Kevin M
2016/05/24 01:02:01
Make this a BlimpMessageSender, and move BlimpMess
| |
56 base::ObserverList<ConnectionErrorObserver> error_observers_; | 59 base::ObserverList<ConnectionErrorObserver> error_observers_; |
57 | 60 |
58 DISALLOW_COPY_AND_ASSIGN(BlimpConnection); | 61 DISALLOW_COPY_AND_ASSIGN(BlimpConnection); |
59 }; | 62 }; |
60 | 63 |
61 } // namespace blimp | 64 } // namespace blimp |
62 | 65 |
63 #endif // BLIMP_NET_BLIMP_CONNECTION_H_ | 66 #endif // BLIMP_NET_BLIMP_CONNECTION_H_ |
OLD | NEW |