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

Unified Diff: blimp/net/browser_connection_handler.cc

Issue 1551583003: Implementation and fixes for Blimp client/engine E2E communication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dtrainor-linux-cl1528243002
Patch Set: Addressed haibin's feedback, made an ObserverList for ConnectionErrorObserver Created 5 years 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 side-by-side diff with in-line comments
Download patch
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..6a7b47428d68c5d31d8a9ff7846bbd8301605c94 100644
--- a/blimp/net/browser_connection_handler.cc
+++ b/blimp/net/browser_connection_handler.cc
@@ -42,31 +42,33 @@ 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();
+ // Squelch any errors that are thrown as a result of dropping the connection.
+ connection_->ClearConnectionErrorObservers();
+
+ connection_.reset();
}
} // namespace blimp

Powered by Google App Engine
This is Rietveld 408576698