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

Unified Diff: mojo/shell/content_handler_connection.cc

Issue 1228743002: Mandoline: Move ContentHandlerConnection into separate file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/shell/content_handler_connection.h ('k') | mojo/shell/shell_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/content_handler_connection.cc
diff --git a/mojo/shell/content_handler_connection.cc b/mojo/shell/content_handler_connection.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2de57971fb2f39ac8da9d6b7029cb058337aedba
--- /dev/null
+++ b/mojo/shell/content_handler_connection.cc
@@ -0,0 +1,53 @@
+// 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 "mojo/shell/content_handler_connection.h"
+
+#include "mojo/shell/application_manager.h"
+
+namespace mojo {
+namespace shell {
+
+ContentHandlerConnection::ContentHandlerConnection(
+ ApplicationManager* manager,
+ const GURL& content_handler_url,
+ const GURL& requestor_url,
+ const std::string& qualifier)
+ : manager_(manager),
+ content_handler_url_(content_handler_url),
+ content_handler_qualifier_(qualifier),
+ connection_closed_(false) {
+ ServiceProviderPtr services;
+ mojo::URLRequestPtr request(mojo::URLRequest::New());
+ request->url = mojo::String::From(content_handler_url.spec());
+ manager->ConnectToApplication(
+ request.Pass(), qualifier, requestor_url, GetProxy(&services),
+ nullptr, base::Closure());
+ MessagePipe pipe;
+ content_handler_.Bind(
+ InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u));
+ services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass());
+ content_handler_.set_error_handler(this);
+}
+
+void ContentHandlerConnection::CloseConnection() {
+ if (connection_closed_)
+ return;
+ connection_closed_ = true;
+ manager_->OnContentHandlerConnectionClosed(this);
+ delete this;
+}
+
+ContentHandlerConnection::~ContentHandlerConnection() {
+ // If this DCHECK fails then something has tried to delete this object without
+ // calling CloseConnection.
+ DCHECK(connection_closed_);
+}
+
+void ContentHandlerConnection::OnConnectionError() {
+ CloseConnection();
+}
+
+} // namespace shell
+} // namespace mojo
« no previous file with comments | « mojo/shell/content_handler_connection.h ('k') | mojo/shell/shell_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698