Index: blimp/net/browser_connection_handler.cc |
diff --git a/blimp/net/browser_connection_handler.cc b/blimp/net/browser_connection_handler.cc |
index 896803c68323180cf413aca9219955b3eed2eded..78009cc3343e81d4d7a9d3477f98e2cef65daefb 100644 |
--- a/blimp/net/browser_connection_handler.cc |
+++ b/blimp/net/browser_connection_handler.cc |
@@ -42,31 +42,29 @@ scoped_ptr<BlimpMessageProcessor> BrowserConnectionHandler::RegisterFeature( |
void BrowserConnectionHandler::HandleConnection( |
scoped_ptr<BlimpConnection> connection) { |
- // Since there is only a single Client, assume a newer connection should |
- // replace an existing one. |
- DropCurrentConnection(); |
+ DCHECK(connection); |
+ VLOG(1) << "HandleConnection " << connection; |
+ |
+ if (connection_) { |
+ DropCurrentConnection(); |
+ } |
connection_ = std::move(connection); |
- connection_->SetConnectionErrorObserver(this); |
- // Connect the incoming & outgoing message streams. |
- connection_->SetIncomingMessageProcessor(checkpointer_.get()); |
+ // Hook up message streams to the connection. |
+ connection_->SetIncomingMessageProcessor(demultiplexer_.get()); |
output_buffer_->SetOutputProcessor( |
connection_->GetOutgoingMessageProcessor()); |
+ connection_->AddConnectionErrorObserver(this); |
} |
-void BrowserConnectionHandler::DropCurrentConnection() { |
- if (!connection_) |
- return; |
+void BrowserConnectionHandler::OnConnectionError(int error) { |
+ DropCurrentConnection(); |
+} |
- connection_->SetConnectionErrorObserver(nullptr); |
- connection_->SetIncomingMessageProcessor(nullptr); |
+void BrowserConnectionHandler::DropCurrentConnection() { |
+ DCHECK(connection_); |
output_buffer_->SetOutputProcessor(nullptr); |
connection_.reset(); |
} |
-void BrowserConnectionHandler::OnConnectionError(int error) { |
- LOG(WARNING) << "Connection error " << net::ErrorToString(error); |
- DropCurrentConnection(); |
-} |
- |
} // namespace blimp |