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

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

Issue 2236093002: Decouple Blimp transport output from BlimpConnections using MessagePort. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@statistics-singleton
Patch Set: Created 4 years, 4 months 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; 18 class BlimpMessagePump;
19 class BlimpMessageSender; 19 class BlimpMessageSender;
20 class PacketReader; 20 class MessagePort;
21 class PacketWriter;
22 21
23 // Encapsulates the state and logic used to exchange BlimpMessages over 22 // Encapsulates the state and logic used to exchange BlimpMessages over
24 // a network connection. 23 // a network connection.
25 class BLIMP_NET_EXPORT BlimpConnection : public ConnectionErrorObserver { 24 class BLIMP_NET_EXPORT BlimpConnection : public ConnectionErrorObserver {
26 public: 25 public:
27 BlimpConnection(std::unique_ptr<PacketReader> reader, 26 explicit BlimpConnection(std::unique_ptr<MessagePort> message_port);
28 std::unique_ptr<PacketWriter> writer);
29
30 ~BlimpConnection() override; 27 ~BlimpConnection() override;
31 28
32 // Adds |observer| to the connection's error observer list. 29 // Adds |observer| to the connection's error observer list.
33 virtual void AddConnectionErrorObserver(ConnectionErrorObserver* observer); 30 virtual void AddConnectionErrorObserver(ConnectionErrorObserver* observer);
34 31
35 // Removes |observer| from the connection's error observer list. 32 // Removes |observer| from the connection's error observer list.
36 virtual void RemoveConnectionErrorObserver(ConnectionErrorObserver* observer); 33 virtual void RemoveConnectionErrorObserver(ConnectionErrorObserver* observer);
37 34
38 // Sets the processor which will take incoming messages for this connection. 35 // Sets the processor which will take incoming messages for this connection.
39 // Can be set multiple times, but previously set processors are discarded. 36 // Can be set multiple times, but previously set processors are discarded.
40 // Caller retains the ownership of |processor|. 37 // Caller retains the ownership of |processor|.
41 virtual void SetIncomingMessageProcessor(BlimpMessageProcessor* processor); 38 virtual void SetIncomingMessageProcessor(BlimpMessageProcessor* processor);
42 39
43 // Gets a processor for BrowserSession->BlimpConnection message routing. 40 // Gets a processor for BrowserSession->BlimpConnection message routing.
44 virtual BlimpMessageProcessor* GetOutgoingMessageProcessor(); 41 virtual BlimpMessageProcessor* GetOutgoingMessageProcessor();
45 42
46 protected: 43 protected:
47 class EndConnectionFilter; 44 class EndConnectionFilter;
48 friend class EndConnectionFilter; 45 friend class EndConnectionFilter;
49 46
50 BlimpConnection(); 47 BlimpConnection();
51 48
52 // ConnectionErrorObserver implementation. 49 // ConnectionErrorObserver implementation.
53 void OnConnectionError(int error) override; 50 void OnConnectionError(int error) override;
54 51
55 private: 52 private:
56 std::unique_ptr<PacketReader> reader_; 53 std::unique_ptr<MessagePort> message_port_;
57 std::unique_ptr<BlimpMessagePump> message_pump_; 54 std::unique_ptr<BlimpMessagePump> message_pump_;
58 std::unique_ptr<PacketWriter> writer_;
59 std::unique_ptr<BlimpMessageSender> outgoing_msg_processor_; 55 std::unique_ptr<BlimpMessageSender> outgoing_msg_processor_;
60 base::ObserverList<ConnectionErrorObserver> error_observers_; 56 base::ObserverList<ConnectionErrorObserver> error_observers_;
61 std::unique_ptr<EndConnectionFilter> end_connection_filter_; 57 std::unique_ptr<EndConnectionFilter> end_connection_filter_;
62 58
63 DISALLOW_COPY_AND_ASSIGN(BlimpConnection); 59 DISALLOW_COPY_AND_ASSIGN(BlimpConnection);
64 }; 60 };
65 61
66 } // namespace blimp 62 } // namespace blimp
67 63
68 #endif // BLIMP_NET_BLIMP_CONNECTION_H_ 64 #endif // BLIMP_NET_BLIMP_CONNECTION_H_
OLDNEW
« no previous file with comments | « blimp/net/BUILD.gn ('k') | blimp/net/blimp_connection.cc » ('j') | blimp/net/blimp_transport.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698