| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "blimp/net/engine_auth_handler.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "blimp/net/blimp_connection.h" |
| 9 #include "blimp/net/blimp_transport.h" |
| 10 #include "net/base/net_errors.h" |
| 11 |
| 12 namespace blimp { |
| 13 |
| 14 EngineAuthHandler::EngineAuthHandler(ConnectionHandler* connection_handler) |
| 15 : connection_handler_(connection_handler) { |
| 16 DCHECK(connection_handler_); |
| 17 } |
| 18 |
| 19 EngineAuthHandler::~EngineAuthHandler() {} |
| 20 |
| 21 void EngineAuthHandler::HandleConnection( |
| 22 scoped_ptr<BlimpConnection> connection) { |
| 23 DCHECK(connection); |
| 24 DCHECK(!connection_); |
| 25 connection_ = std::move(connection); |
| 26 connection_->SetConnectionErrorObserver(this); |
| 27 connection_->SetIncomingMessageProcessor(this); |
| 28 // TODO(haibinlu): add timeout. |
| 29 } |
| 30 |
| 31 void EngineAuthHandler::OnConnectionError(int error) { |
| 32 delete this; |
| 33 } |
| 34 |
| 35 void EngineAuthHandler::ProcessMessage( |
| 36 scoped_ptr<BlimpMessage> message, |
| 37 const net::CompletionCallback& callback) { |
| 38 // Expecting the first message is START_CONNECTION request. |
| 39 if (message->type() == BlimpMessage::START_CONNECTION) { |
| 40 // TODO(haibinlu): check client token. |
| 41 connection_handler_->HandleConnection(std::move(connection_)); |
| 42 callback.Run(net::OK); |
| 43 } |
| 44 delete this; |
| 45 } |
| 46 |
| 47 } // namespace blimp |
| OLD | NEW |