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 "mojo/shell/application_manager.h" | 7 #include "mojo/shell/application_manager.h" |
8 | 8 |
9 namespace mojo { | 9 namespace mojo { |
10 namespace shell { | 10 namespace shell { |
11 | 11 |
12 ContentHandlerConnection::ContentHandlerConnection( | 12 ContentHandlerConnection::ContentHandlerConnection( |
13 ApplicationManager* manager, | 13 ApplicationManager* manager, |
14 const GURL& content_handler_url, | 14 const GURL& content_handler_url, |
15 const GURL& requestor_url, | 15 const GURL& requestor_url, |
16 const std::string& qualifier) | 16 const std::string& qualifier) |
17 : manager_(manager), | 17 : manager_(manager), |
18 content_handler_url_(content_handler_url), | 18 content_handler_url_(content_handler_url), |
19 content_handler_qualifier_(qualifier), | 19 content_handler_qualifier_(qualifier), |
20 connection_closed_(false) { | 20 connection_closed_(false) { |
21 ServiceProviderPtr services; | 21 ServiceProviderPtr services; |
22 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 22 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
23 request->url = mojo::String::From(content_handler_url.spec()); | 23 request->url = mojo::String::From(content_handler_url.spec()); |
24 // TODO(beng): Need to figure out how to deal with originator and | |
25 // CapabilityFilter here. | |
24 manager->ConnectToApplication( | 26 manager->ConnectToApplication( |
25 request.Pass(), qualifier, requestor_url, GetProxy(&services), | 27 NULL, request.Pass(), qualifier, requestor_url, GetProxy(&services), |
sky
2015/07/22 15:57:45
NULL->nullptr
| |
26 nullptr, base::Closure()); | 28 nullptr, nullptr, base::Closure()); |
27 MessagePipe pipe; | 29 MessagePipe pipe; |
28 content_handler_.Bind( | 30 content_handler_.Bind( |
29 InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u)); | 31 InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u)); |
30 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass()); | 32 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass()); |
31 content_handler_.set_connection_error_handler( | 33 content_handler_.set_connection_error_handler( |
32 [this]() { CloseConnection(); }); | 34 [this]() { CloseConnection(); }); |
33 } | 35 } |
34 | 36 |
35 void ContentHandlerConnection::CloseConnection() { | 37 void ContentHandlerConnection::CloseConnection() { |
36 if (connection_closed_) | 38 if (connection_closed_) |
37 return; | 39 return; |
38 connection_closed_ = true; | 40 connection_closed_ = true; |
39 manager_->OnContentHandlerConnectionClosed(this); | 41 manager_->OnContentHandlerConnectionClosed(this); |
40 delete this; | 42 delete this; |
41 } | 43 } |
42 | 44 |
43 ContentHandlerConnection::~ContentHandlerConnection() { | 45 ContentHandlerConnection::~ContentHandlerConnection() { |
44 // If this DCHECK fails then something has tried to delete this object without | 46 // If this DCHECK fails then something has tried to delete this object without |
45 // calling CloseConnection. | 47 // calling CloseConnection. |
46 DCHECK(connection_closed_); | 48 DCHECK(connection_closed_); |
47 } | 49 } |
48 | 50 |
49 } // namespace shell | 51 } // namespace shell |
50 } // namespace mojo | 52 } // namespace mojo |
OLD | NEW |