OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/shell/content_handler_connection.h" | 5 #include "mojo/shell/content_handler_connection.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "mojo/shell/application_manager.h" | 8 #include "mojo/shell/application_manager.h" |
9 #include "mojo/shell/connect_to_application_params.h" | 9 #include "mojo/shell/connect_to_application_params.h" |
10 #include "mojo/shell/identity.h" | 10 #include "mojo/shell/identity.h" |
11 | 11 |
12 namespace mojo { | 12 namespace mojo { |
13 namespace shell { | 13 namespace shell { |
14 | 14 |
15 ContentHandlerConnection::ContentHandlerConnection( | 15 ContentHandlerConnection::ContentHandlerConnection( |
16 ApplicationManager* manager, | 16 ApplicationManager* manager, |
17 const Identity& source, | 17 const Identity& originator_identity, |
18 const Identity& content_handler, | 18 const CapabilityFilter& originator_filter, |
| 19 const GURL& content_handler_url, |
| 20 const std::string& qualifier, |
| 21 const CapabilityFilter& filter, |
19 uint32_t id) | 22 uint32_t id) |
20 : manager_(manager), | 23 : manager_(manager), |
21 identity_(content_handler), | 24 content_handler_url_(content_handler_url), |
| 25 content_handler_qualifier_(qualifier), |
22 connection_closed_(false), | 26 connection_closed_(false), |
23 id_(id) { | 27 id_(id) { |
24 ServiceProviderPtr services; | 28 ServiceProviderPtr services; |
25 | 29 |
26 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams); | 30 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams); |
27 params->set_source(source); | 31 params->set_originator_identity(originator_identity); |
28 params->SetTarget(identity_); | 32 params->set_originator_filter(originator_filter); |
| 33 params->SetURLInfo(content_handler_url); |
| 34 params->set_qualifier(qualifier); |
29 params->set_services(GetProxy(&services)); | 35 params->set_services(GetProxy(&services)); |
| 36 params->set_filter(filter); |
| 37 |
30 manager->ConnectToApplication(params.Pass()); | 38 manager->ConnectToApplication(params.Pass()); |
31 | 39 |
32 MessagePipe pipe; | 40 MessagePipe pipe; |
33 content_handler_.Bind( | 41 content_handler_.Bind( |
34 InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u)); | 42 InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u)); |
35 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass()); | 43 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass()); |
36 content_handler_.set_connection_error_handler( | 44 content_handler_.set_connection_error_handler( |
37 [this]() { CloseConnection(); }); | 45 [this]() { CloseConnection(); }); |
38 } | 46 } |
39 | 47 |
40 void ContentHandlerConnection::CloseConnection() { | 48 void ContentHandlerConnection::CloseConnection() { |
41 if (connection_closed_) | 49 if (connection_closed_) |
42 return; | 50 return; |
43 connection_closed_ = true; | 51 connection_closed_ = true; |
44 manager_->OnContentHandlerConnectionClosed(this); | 52 manager_->OnContentHandlerConnectionClosed(this); |
45 delete this; | 53 delete this; |
46 } | 54 } |
47 | 55 |
48 ContentHandlerConnection::~ContentHandlerConnection() { | 56 ContentHandlerConnection::~ContentHandlerConnection() { |
49 // If this DCHECK fails then something has tried to delete this object without | 57 // If this DCHECK fails then something has tried to delete this object without |
50 // calling CloseConnection. | 58 // calling CloseConnection. |
51 DCHECK(connection_closed_); | 59 DCHECK(connection_closed_); |
52 } | 60 } |
53 | 61 |
54 } // namespace shell | 62 } // namespace shell |
55 } // namespace mojo | 63 } // namespace mojo |
OLD | NEW |