Add ICU message format support
[chromium-blink-merge.git] / mojo / shell / content_handler_connection.cc
blobdd3c5cb9e1a9e496a3e69cdd9a958ad4909d5017
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.
5 #include "mojo/shell/content_handler_connection.h"
7 #include "mojo/shell/application_manager.h"
9 namespace mojo {
10 namespace shell {
12 ContentHandlerConnection::ContentHandlerConnection(
13 ApplicationInstance* originator,
14 ApplicationManager* manager,
15 const GURL& content_handler_url,
16 const GURL& requestor_url,
17 const std::string& qualifier,
18 const CapabilityFilter& filter)
19 : manager_(manager),
20 content_handler_url_(content_handler_url),
21 content_handler_qualifier_(qualifier),
22 connection_closed_(false) {
23 ServiceProviderPtr services;
24 mojo::URLRequestPtr request(mojo::URLRequest::New());
25 request->url = mojo::String::From(content_handler_url.spec());
26 manager->ConnectToApplication(
27 originator, request.Pass(), qualifier, requestor_url, GetProxy(&services),
28 nullptr, filter, base::Closure());
29 MessagePipe pipe;
30 content_handler_.Bind(
31 InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u));
32 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass());
33 content_handler_.set_connection_error_handler(
34 [this]() { CloseConnection(); });
37 void ContentHandlerConnection::CloseConnection() {
38 if (connection_closed_)
39 return;
40 connection_closed_ = true;
41 manager_->OnContentHandlerConnectionClosed(this);
42 delete this;
45 ContentHandlerConnection::~ContentHandlerConnection() {
46 // If this DCHECK fails then something has tried to delete this object without
47 // calling CloseConnection.
48 DCHECK(connection_closed_);
51 } // namespace shell
52 } // namespace mojo