| 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 "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "blimp/net/blimp_net_export.h" | 10 #include "blimp/net/blimp_net_export.h" |
| 11 | 11 |
| 12 namespace blimp { | 12 namespace blimp { |
| 13 | 13 |
| 14 class BlimpMessageProcessor; | 14 class BlimpMessageProcessor; |
| 15 class BlimpMessagePump; | 15 class BlimpMessagePump; |
| 16 class ConnectionErrorObserver; | 16 class ConnectionErrorObserver; |
| 17 class PacketReader; | 17 class PacketReader; |
| 18 class PacketWriter; | 18 class PacketWriter; |
| 19 | 19 |
| 20 // Encapsulates the state and logic used to exchange BlimpMessages over | 20 // Encapsulates the state and logic used to exchange BlimpMessages over |
| 21 // a network connection. | 21 // a network connection. |
| 22 class BLIMP_NET_EXPORT BlimpConnection { | 22 class BLIMP_NET_EXPORT BlimpConnection { |
| 23 public: | 23 public: |
| 24 BlimpConnection(scoped_ptr<PacketReader> reader, | 24 BlimpConnection(scoped_ptr<PacketReader> reader, |
| 25 scoped_ptr<PacketWriter> writer); | 25 scoped_ptr<PacketWriter> writer); |
| 26 | 26 |
| 27 virtual ~BlimpConnection(); | 27 virtual ~BlimpConnection(); |
| 28 | 28 |
| 29 // Lets |observer| know when the network connection encounters an error. | 29 // Lets |observer| know when the network connection encounters an error. |
| 30 void SetConnectionErrorObserver(ConnectionErrorObserver* observer); | 30 virtual void SetConnectionErrorObserver(ConnectionErrorObserver* observer); |
| 31 | 31 |
| 32 // Sets the processor which will take incoming messages for this connection. | 32 // Sets the processor which will take incoming messages for this connection. |
| 33 // Can be set multiple times, but previously set processors are discarded. | 33 // Can be set multiple times, but previously set processors are discarded. |
| 34 // Caller retains the ownership of |processor|. | 34 // Caller retains the ownership of |processor|. |
| 35 void SetIncomingMessageProcessor(BlimpMessageProcessor* processor); | 35 virtual void SetIncomingMessageProcessor(BlimpMessageProcessor* processor); |
| 36 | 36 |
| 37 // Gets a processor for BrowserSession->BlimpConnection message routing. | 37 // Gets a processor for BrowserSession->BlimpConnection message routing. |
| 38 BlimpMessageProcessor* GetOutgoingMessageProcessor() const; | 38 virtual BlimpMessageProcessor* GetOutgoingMessageProcessor() const; |
| 39 |
| 40 protected: |
| 41 BlimpConnection(); |
| 39 | 42 |
| 40 private: | 43 private: |
| 41 scoped_ptr<PacketReader> reader_; | 44 scoped_ptr<PacketReader> reader_; |
| 42 scoped_ptr<BlimpMessagePump> message_pump_; | 45 scoped_ptr<BlimpMessagePump> message_pump_; |
| 43 scoped_ptr<PacketWriter> writer_; | 46 scoped_ptr<PacketWriter> writer_; |
| 44 scoped_ptr<BlimpMessageProcessor> outgoing_msg_processor_; | 47 scoped_ptr<BlimpMessageProcessor> outgoing_msg_processor_; |
| 45 | 48 |
| 46 DISALLOW_COPY_AND_ASSIGN(BlimpConnection); | 49 DISALLOW_COPY_AND_ASSIGN(BlimpConnection); |
| 47 }; | 50 }; |
| 48 | 51 |
| 49 } // namespace blimp | 52 } // namespace blimp |
| 50 | 53 |
| 51 #endif // BLIMP_NET_BLIMP_CONNECTION_H_ | 54 #endif // BLIMP_NET_BLIMP_CONNECTION_H_ |
| OLD | NEW |