Restore variadic macros in DevToolsEmbedderMessageDispatcher
[chromium-blink-merge.git] / mojo / shell / content_handler_connection.cc
blob99fbb773844b68c52f7f74a58c050faa9f14a13f
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 "base/memory/scoped_ptr.h"
8 #include "mojo/shell/application_manager.h"
9 #include "mojo/shell/connect_to_application_params.h"
10 #include "mojo/shell/identity.h"
12 namespace mojo {
13 namespace shell {
15 ContentHandlerConnection::ContentHandlerConnection(
16 ApplicationManager* manager,
17 const Identity& originator_identity,
18 const CapabilityFilter& originator_filter,
19 const GURL& content_handler_url,
20 const std::string& qualifier,
21 const CapabilityFilter& filter,
22 uint32_t id)
23 : manager_(manager),
24 content_handler_url_(content_handler_url),
25 content_handler_qualifier_(qualifier),
26 connection_closed_(false),
27 id_(id) {
28 ServiceProviderPtr services;
30 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams);
31 params->set_originator_identity(originator_identity);
32 params->set_originator_filter(originator_filter);
33 params->SetURLInfo(content_handler_url);
34 params->set_qualifier(qualifier);
35 params->set_services(GetProxy(&services));
36 params->set_filter(filter);
38 manager->ConnectToApplication(params.Pass());
40 MessagePipe pipe;
41 content_handler_.Bind(
42 InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u));
43 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass());
44 content_handler_.set_connection_error_handler(
45 [this]() { CloseConnection(); });
48 void ContentHandlerConnection::CloseConnection() {
49 if (connection_closed_)
50 return;
51 connection_closed_ = true;
52 manager_->OnContentHandlerConnectionClosed(this);
53 delete this;
56 ContentHandlerConnection::~ContentHandlerConnection() {
57 // If this DCHECK fails then something has tried to delete this object without
58 // calling CloseConnection.
59 DCHECK(connection_closed_);
62 } // namespace shell
63 } // namespace mojo