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/package_manager/content_handler_connection.h" | 5 #include "mojo/shell/package_manager/content_handler_connection.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "mojo/shell/application_manager.h" | 13 #include "mojo/shell/application_manager.h" |
14 #include "mojo/shell/connect_to_application_params.h" | 14 #include "mojo/shell/connect_to_application_params.h" |
15 #include "mojo/shell/identity.h" | 15 #include "mojo/shell/identity.h" |
16 | 16 |
17 namespace mojo { | 17 namespace mojo { |
18 namespace package_manager { | 18 namespace shell { |
19 | 19 |
20 ContentHandlerConnection::ContentHandlerConnection( | 20 ContentHandlerConnection::ContentHandlerConnection( |
21 shell::ApplicationManager* manager, | 21 ApplicationManager* manager, |
22 const shell::Identity& source, | 22 const Identity& source, |
23 const shell::Identity& content_handler, | 23 const Identity& content_handler, |
24 uint32_t id, | 24 uint32_t id, |
25 const ClosedCallback& connection_closed_callback) | 25 const ClosedCallback& connection_closed_callback) |
26 : connection_closed_callback_(connection_closed_callback), | 26 : connection_closed_callback_(connection_closed_callback), |
27 identity_(content_handler), | 27 identity_(content_handler), |
28 connection_closed_(false), | 28 connection_closed_(false), |
29 id_(id), | 29 id_(id), |
30 ref_count_(0) { | 30 ref_count_(0) { |
31 ServiceProviderPtr services; | 31 ServiceProviderPtr services; |
32 | 32 |
33 scoped_ptr<shell::ConnectToApplicationParams> params( | 33 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams); |
34 new shell::ConnectToApplicationParams); | |
35 params->set_source(source); | 34 params->set_source(source); |
36 params->SetTarget(identity_); | 35 params->SetTarget(identity_); |
37 params->set_services(GetProxy(&services)); | 36 params->set_services(GetProxy(&services)); |
38 manager->ConnectToApplication(std::move(params)); | 37 manager->ConnectToApplication(std::move(params)); |
39 | 38 |
40 MessagePipe pipe; | 39 MessagePipe pipe; |
41 content_handler_.Bind( | 40 content_handler_.Bind( |
42 InterfacePtrInfo<ContentHandler>(std::move(pipe.handle0), 0u)); | 41 InterfacePtrInfo<ContentHandler>(std::move(pipe.handle0), 0u)); |
43 services->ConnectToService(ContentHandler::Name_, std::move(pipe.handle1)); | 42 services->ConnectToService(ContentHandler::Name_, std::move(pipe.handle1)); |
44 content_handler_.set_connection_error_handler( | 43 content_handler_.set_connection_error_handler( |
(...skipping 22 matching lines...) Expand all Loading... |
67 // If this DCHECK fails then something has tried to delete this object without | 66 // If this DCHECK fails then something has tried to delete this object without |
68 // calling CloseConnection. | 67 // calling CloseConnection. |
69 DCHECK(connection_closed_); | 68 DCHECK(connection_closed_); |
70 } | 69 } |
71 | 70 |
72 void ContentHandlerConnection::ApplicationDestructed() { | 71 void ContentHandlerConnection::ApplicationDestructed() { |
73 if (!--ref_count_) | 72 if (!--ref_count_) |
74 CloseConnection(); | 73 CloseConnection(); |
75 } | 74 } |
76 | 75 |
77 } // namespace package_manager | 76 } // namespace shell |
78 } // namespace mojo | 77 } // namespace mojo |
OLD | NEW |