Index: blimp/net/blimp_connection.h |
diff --git a/blimp/net/blimp_connection.h b/blimp/net/blimp_connection.h |
index 36128af42300df09ca881ad0309ef842fad20cff..ea729595cf9fe2aefa91d99f76bba597d9119664 100644 |
--- a/blimp/net/blimp_connection.h |
+++ b/blimp/net/blimp_connection.h |
@@ -7,27 +7,36 @@ |
#include "base/macros.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/observer_list.h" |
#include "blimp/net/blimp_net_export.h" |
+#include "blimp/net/connection_error_observer.h" |
namespace blimp { |
class BlimpMessageProcessor; |
class BlimpMessagePump; |
-class ConnectionErrorObserver; |
class PacketReader; |
class PacketWriter; |
// Encapsulates the state and logic used to exchange BlimpMessages over |
// a network connection. |
-class BLIMP_NET_EXPORT BlimpConnection { |
+class BLIMP_NET_EXPORT BlimpConnection : public ConnectionErrorObserver { |
public: |
BlimpConnection(scoped_ptr<PacketReader> reader, |
scoped_ptr<PacketWriter> writer); |
- virtual ~BlimpConnection(); |
+ ~BlimpConnection() override; |
- // Lets |observer| know when the network connection encounters an error. |
- virtual void SetConnectionErrorObserver(ConnectionErrorObserver* observer); |
+ // Adds |observer| to the connection's error observer list. |
+ virtual void AddConnectionErrorObserver(ConnectionErrorObserver* observer); |
+ |
+ // Removes all error observers from the observer list. |
+ // Should be used to suppress error output in cases where an expected error |
+ // code should be suppressed, e.g. on graceful disconnects. |
+ virtual void ClearConnectionErrorObservers(); |
haibinlu
2016/01/04 19:45:45
per offline discussion, this can be removed.
Kevin M
2016/01/04 20:42:13
Removed this and relocated error observers to the
|
+ |
+ // Removes |observer| from the connection's error observer list. |
+ virtual void RemoveConnectionErrorObserver(ConnectionErrorObserver* observer); |
// Sets the processor which will take incoming messages for this connection. |
// Can be set multiple times, but previously set processors are discarded. |
@@ -37,10 +46,14 @@ class BLIMP_NET_EXPORT BlimpConnection { |
// Gets a processor for BrowserSession->BlimpConnection message routing. |
virtual BlimpMessageProcessor* GetOutgoingMessageProcessor(); |
+ // ConnectionErrorObserver implementation. |
+ void OnConnectionError(int error) override; |
haibinlu
2016/01/04 19:45:45
move this to private
Kevin M
2016/01/04 20:42:13
Done.
|
+ |
protected: |
BlimpConnection(); |
private: |
+ base::ObserverList<ConnectionErrorObserver> error_observers_; |
scoped_ptr<PacketReader> reader_; |
scoped_ptr<BlimpMessagePump> message_pump_; |
scoped_ptr<PacketWriter> writer_; |