| 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 #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 25 matching lines...) Expand all Loading... |
| 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 DCHECK(connection); | 45 DCHECK(connection); |
| 46 VLOG(1) << "HandleConnection " << connection; | 46 VLOG(1) << "HandleConnection " << connection.get(); |
| 47 | 47 |
| 48 if (connection_) { | 48 if (connection_) { |
| 49 DropCurrentConnection(); | 49 DropCurrentConnection(); |
| 50 } | 50 } |
| 51 connection_ = std::move(connection); | 51 connection_ = std::move(connection); |
| 52 | 52 |
| 53 // Hook up message streams to the connection. | 53 // Hook up message streams to the connection. |
| 54 connection_->SetIncomingMessageProcessor(demultiplexer_.get()); | 54 connection_->SetIncomingMessageProcessor(demultiplexer_.get()); |
| 55 output_buffer_->SetOutputProcessor( | 55 output_buffer_->SetOutputProcessor( |
| 56 connection_->GetOutgoingMessageProcessor()); | 56 connection_->GetOutgoingMessageProcessor()); |
| 57 connection_->AddConnectionErrorObserver(this); | 57 connection_->AddConnectionErrorObserver(this); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void BrowserConnectionHandler::OnConnectionError(int error) { | 60 void BrowserConnectionHandler::OnConnectionError(int error) { |
| 61 DropCurrentConnection(); | 61 DropCurrentConnection(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void BrowserConnectionHandler::DropCurrentConnection() { | 64 void BrowserConnectionHandler::DropCurrentConnection() { |
| 65 DCHECK(connection_); | 65 DCHECK(connection_); |
| 66 output_buffer_->SetOutputProcessor(nullptr); | 66 output_buffer_->SetOutputProcessor(nullptr); |
| 67 connection_.reset(); | 67 connection_.reset(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 } // namespace blimp | 70 } // namespace blimp |
| OLD | NEW |