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

Unified Diff: blimp/net/engine_auth_handler.cc

Issue 1492643003: [Blimp Net] Add EngineAuthHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/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

Powered by Google App Engine
This is Rietveld 408576698