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

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

Issue 2439403003: Refactor BlimpConnection to TCPConnection (Closed)
Patch Set: Added missing Engine Transport Created 4 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
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 BlimpMessageProcessor; 17 class BlimpMessageProcessor;
18 class BlimpMessagePump;
19 class BlimpMessageSender;
20 class MessagePort;
21 18
22 // Encapsulates the state and logic used to exchange BlimpMessages over 19 // Encapsulates the state and logic used to exchange BlimpMessages over
23 // a network connection. 20 // a network connection.
24 class BLIMP_NET_EXPORT BlimpConnection : public ConnectionErrorObserver { 21 class BLIMP_NET_EXPORT BlimpConnection : public ConnectionErrorObserver {
25 public: 22 public:
26 explicit BlimpConnection(std::unique_ptr<MessagePort> message_port);
27 ~BlimpConnection() override; 23 ~BlimpConnection() override;
28 24
29 // Adds |observer| to the connection's error observer list. 25 // Adds |observer| to the connection's error observer list.
30 virtual void AddConnectionErrorObserver(ConnectionErrorObserver* observer); 26 virtual void AddConnectionErrorObserver(ConnectionErrorObserver* observer);
31 27
32 // Removes |observer| from the connection's error observer list. 28 // Removes |observer| from the connection's error observer list.
33 virtual void RemoveConnectionErrorObserver(ConnectionErrorObserver* observer); 29 virtual void RemoveConnectionErrorObserver(ConnectionErrorObserver* observer);
34 30
35 // Sets the processor which will take incoming messages for this connection. 31 // Sets the processor which will take incoming messages for this connection.
36 // Can be set multiple times, but previously set processors are discarded. 32 // Can be set multiple times, but previously set processors are discarded.
37 // Caller retains the ownership of |processor|. 33 // Caller retains the ownership of |processor|.
38 virtual void SetIncomingMessageProcessor(BlimpMessageProcessor* processor); 34 virtual void SetIncomingMessageProcessor(
35 BlimpMessageProcessor* processor) = 0;
39 36
40 // Gets a processor for BrowserSession->BlimpConnection message routing. 37 // Gets a processor for BrowserSession->BlimpConnection message routing.
41 virtual BlimpMessageProcessor* GetOutgoingMessageProcessor(); 38 virtual BlimpMessageProcessor* GetOutgoingMessageProcessor() = 0;
42 39
43 protected: 40 protected:
44 class EndConnectionFilter; 41 class EndConnectionFilter;
45 friend class EndConnectionFilter; 42 friend class EndConnectionFilter;
46 43
47 BlimpConnection(); 44 BlimpConnection();
48 45
46 void AddEndConnectionProcessor(BlimpMessageProcessor* processor);
Wez 2016/11/09 22:47:17 Looking at the implementation, this is a simple-se
perumaal 2016/11/10 02:05:05 Got it, good point.
47
49 // ConnectionErrorObserver implementation. 48 // ConnectionErrorObserver implementation.
50 void OnConnectionError(int error) override; 49 void OnConnectionError(int error) override;
51 50
51 BlimpMessageProcessor* GetEndConnectionProcessor() const;
52
52 private: 53 private:
53 std::unique_ptr<MessagePort> message_port_; 54 std::unique_ptr<EndConnectionFilter> end_connection_filter_;
54 std::unique_ptr<BlimpMessagePump> message_pump_;
55 std::unique_ptr<BlimpMessageSender> outgoing_msg_processor_;
56 base::ObserverList<ConnectionErrorObserver> error_observers_; 55 base::ObserverList<ConnectionErrorObserver> error_observers_;
57 std::unique_ptr<EndConnectionFilter> end_connection_filter_;
58
59 DISALLOW_COPY_AND_ASSIGN(BlimpConnection); 56 DISALLOW_COPY_AND_ASSIGN(BlimpConnection);
60 }; 57 };
61 58
62 } // namespace blimp 59 } // namespace blimp
63 60
64 #endif // BLIMP_NET_BLIMP_CONNECTION_H_ 61 #endif // BLIMP_NET_BLIMP_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698