Chromium Code Reviews| 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 PacketReader; | 15 class PacketReader; |
| 15 class PacketWriter; | 16 class PacketWriter; |
| 16 | 17 |
| 18 | |
|
Wez
2015/11/12 03:45:56
nit: Remove spurious blank line.
Kevin M
2015/11/12 19:03:47
Done.
| |
| 19 // Encapsulates the state and logic used to exchange BlimpMessages over | |
| 20 // a network connection. | |
| 17 class BLIMP_NET_EXPORT BlimpConnection { | 21 class BLIMP_NET_EXPORT BlimpConnection { |
| 18 public: | 22 public: |
| 19 virtual ~BlimpConnection(); | 23 class DisconnectObserver { |
| 24 // Called when the network connection for |this| is disconnected. | |
| 25 virtual void OnDisconnected() = 0; | |
| 26 }; | |
| 20 | 27 |
| 21 protected: | |
| 22 BlimpConnection(scoped_ptr<PacketReader> reader, | 28 BlimpConnection(scoped_ptr<PacketReader> reader, |
| 23 scoped_ptr<PacketWriter> writer); | 29 scoped_ptr<PacketWriter> writer); |
| 24 | 30 |
| 31 ~BlimpConnection(); | |
| 32 | |
| 33 // Lets |observer| know when the network connection is terminated. | |
| 34 void AddDisconnectObserver(DisconnectObserver* observer); | |
| 35 | |
| 36 // Sets the processor which will take incoming messages for this connection. | |
| 37 // Can be set multiple times, but previously set processors are discarded. | |
| 38 void set_incoming_message_processor( | |
| 39 scoped_ptr<BlimpMessageProcessor> processor); | |
| 40 | |
| 41 // Gets a processor for BrowserSession->BlimpConnection message routing. | |
| 42 scoped_ptr<BlimpMessageProcessor> take_outgoing_message_processor() const; | |
| 43 | |
| 25 private: | 44 private: |
| 26 scoped_ptr<PacketReader> reader_; | 45 scoped_ptr<PacketReader> reader_; |
| 27 scoped_ptr<PacketWriter> writer_; | 46 scoped_ptr<PacketWriter> writer_; |
| 28 }; | 47 }; |
|
Wez
2015/11/12 03:45:56
DISALLOW_COPY_AND_ASSIGN
Kevin M
2015/11/12 19:03:47
Done.
| |
| 29 | 48 |
| 30 } // namespace blimp | 49 } // namespace blimp |
| 31 | 50 |
| 32 #endif // BLIMP_NET_BLIMP_CONNECTION_H_ | 51 #endif // BLIMP_NET_BLIMP_CONNECTION_H_ |
| OLD | NEW |