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_CONNECTION_H_ | |
6 #define BLIMP_NET_BLIMP_CONNECTION_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/macros.h" | |
11 #include "base/observer_list.h" | |
12 #include "blimp/net/blimp_net_export.h" | |
13 #include "blimp/net/connection_error_observer.h" | |
14 | |
15 namespace blimp { | |
16 | |
17 class BlimpMessageProcessor; | |
18 | |
19 // Encapsulates the state and logic used to exchange BlimpMessages over | |
20 // a network connection. | |
21 class BLIMP_NET_EXPORT BlimpConnection : public ConnectionErrorObserver { | |
22 public: | |
23 ~BlimpConnection() override; | |
24 | |
25 // Adds |observer| to the connection's error observer list. | |
26 virtual void AddConnectionErrorObserver(ConnectionErrorObserver* observer); | |
27 | |
28 // Removes |observer| from the connection's error observer list. | |
29 virtual void RemoveConnectionErrorObserver(ConnectionErrorObserver* observer); | |
30 | |
31 // Sets the processor which will take incoming messages for this connection. | |
32 // Can be set multiple times, but previously set processors are discarded. | |
33 // Caller retains the ownership of |processor|. | |
34 virtual void SetIncomingMessageProcessor( | |
35 BlimpMessageProcessor* processor) = 0; | |
36 | |
37 // Gets a processor for BrowserSession->BlimpConnection message routing. | |
38 virtual BlimpMessageProcessor* GetOutgoingMessageProcessor() = 0; | |
39 | |
40 protected: | |
41 class EndConnectionFilter; | |
42 friend class EndConnectionFilter; | |
43 | |
44 BlimpConnection(); | |
45 | |
46 void AddEndConnectionProcessor(BlimpMessageProcessor* processor); | |
47 | |
48 // ConnectionErrorObserver implementation. | |
49 void OnConnectionError(int error) override; | |
50 | |
51 BlimpMessageProcessor* GetEndConnectionProcessor() const; | |
52 | |
53 private: | |
54 std::unique_ptr<EndConnectionFilter> end_connection_filter_; | |
55 base::ObserverList<ConnectionErrorObserver> error_observers_; | |
56 DISALLOW_COPY_AND_ASSIGN(BlimpConnection); | |
57 }; | |
58 | |
59 } // namespace blimp | |
60 | |
61 #endif // BLIMP_NET_BLIMP_CONNECTION_H_ | |
OLD | NEW |