| Index: blimp/net/engine_auth_handler.cc
|
| diff --git a/blimp/net/engine_auth_handler.cc b/blimp/net/engine_auth_handler.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..637e807d405ca4fd0fea9ca732163f87908ab3ce
|
| --- /dev/null
|
| +++ b/blimp/net/engine_auth_handler.cc
|
| @@ -0,0 +1,47 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "blimp/net/engine_auth_handler.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "blimp/net/blimp_connection.h"
|
| +#include "blimp/net/blimp_transport.h"
|
| +#include "net/base/net_errors.h"
|
| +
|
| +namespace blimp {
|
| +
|
| +EngineAuthHandler::EngineAuthHandler(ConnectionHandler* connection_handler)
|
| + : connection_handler_(connection_handler) {
|
| + DCHECK(connection_handler_);
|
| +}
|
| +
|
| +EngineAuthHandler::~EngineAuthHandler() {}
|
| +
|
| +void EngineAuthHandler::HandleConnection(
|
| + scoped_ptr<BlimpConnection> connection) {
|
| + DCHECK(connection);
|
| + DCHECK(!connection_);
|
| + connection_ = std::move(connection);
|
| + connection_->SetConnectionErrorObserver(this);
|
| + connection_->SetIncomingMessageProcessor(this);
|
| + // TODO(haibinlu): add timeout.
|
| +}
|
| +
|
| +void EngineAuthHandler::OnConnectionError(int error) {
|
| + delete this;
|
| +}
|
| +
|
| +void EngineAuthHandler::ProcessMessage(
|
| + scoped_ptr<BlimpMessage> message,
|
| + const net::CompletionCallback& callback) {
|
| + // Expecting the first message is START_CONNECTION request.
|
| + if (message->type() == BlimpMessage::START_CONNECTION) {
|
| + // TODO(haibinlu): check client token.
|
| + connection_handler_->HandleConnection(std::move(connection_));
|
| + callback.Run(net::OK);
|
| + }
|
| + delete this;
|
| +}
|
| +
|
| +} // namespace blimp
|
|
|