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

Side by Side 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: Fixed misplaced EXPORT directive Created 4 years, 11 months 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 unified diff | Download patch
« no previous file with comments | « blimp/net/blimp_message_pump.cc ('k') | blimp/net/browser_connection_handler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "blimp/net/browser_connection_handler.h" 5 #include "blimp/net/browser_connection_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "blimp/net/blimp_connection.h" 9 #include "blimp/net/blimp_connection.h"
10 #include "blimp/net/blimp_message_checkpointer.h" 10 #include "blimp/net/blimp_message_checkpointer.h"
(...skipping 24 matching lines...) Expand all
35 35
36 scoped_ptr<BlimpMessageProcessor> BrowserConnectionHandler::RegisterFeature( 36 scoped_ptr<BlimpMessageProcessor> BrowserConnectionHandler::RegisterFeature(
37 BlimpMessage::Type type, 37 BlimpMessage::Type type,
38 BlimpMessageProcessor* incoming_processor) { 38 BlimpMessageProcessor* incoming_processor) {
39 demultiplexer_->AddProcessor(type, incoming_processor); 39 demultiplexer_->AddProcessor(type, incoming_processor);
40 return multiplexer_->CreateSenderForType(type); 40 return multiplexer_->CreateSenderForType(type);
41 } 41 }
42 42
43 void BrowserConnectionHandler::HandleConnection( 43 void BrowserConnectionHandler::HandleConnection(
44 scoped_ptr<BlimpConnection> connection) { 44 scoped_ptr<BlimpConnection> connection) {
45 // Since there is only a single Client, assume a newer connection should 45 DCHECK(connection);
46 // replace an existing one. 46 VLOG(1) << "HandleConnection " << connection;
47 DropCurrentConnection(); 47
48 if (connection_) {
49 DropCurrentConnection();
50 }
48 connection_ = std::move(connection); 51 connection_ = std::move(connection);
49 connection_->SetConnectionErrorObserver(this);
50 52
51 // Connect the incoming & outgoing message streams. 53 // Hook up message streams to the connection.
52 connection_->SetIncomingMessageProcessor(checkpointer_.get()); 54 connection_->SetIncomingMessageProcessor(demultiplexer_.get());
53 output_buffer_->SetOutputProcessor( 55 output_buffer_->SetOutputProcessor(
54 connection_->GetOutgoingMessageProcessor()); 56 connection_->GetOutgoingMessageProcessor());
57 connection_->AddConnectionErrorObserver(this);
58 }
59
60 void BrowserConnectionHandler::OnConnectionError(int error) {
61 DropCurrentConnection();
55 } 62 }
56 63
57 void BrowserConnectionHandler::DropCurrentConnection() { 64 void BrowserConnectionHandler::DropCurrentConnection() {
58 if (!connection_) 65 DCHECK(connection_);
59 return;
60
61 connection_->SetConnectionErrorObserver(nullptr);
62 connection_->SetIncomingMessageProcessor(nullptr);
63 output_buffer_->SetOutputProcessor(nullptr); 66 output_buffer_->SetOutputProcessor(nullptr);
64 connection_.reset(); 67 connection_.reset();
65 } 68 }
66 69
67 void BrowserConnectionHandler::OnConnectionError(int error) {
68 LOG(WARNING) << "Connection error " << net::ErrorToString(error);
69 DropCurrentConnection();
70 }
71
72 } // namespace blimp 70 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/blimp_message_pump.cc ('k') | blimp/net/browser_connection_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698