OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/dbus_service_loader_linux.h" | 5 #include "mojo/shell/dbus_service_loader_linux.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/task_runner_util.h" | 12 #include "base/task_runner_util.h" |
13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
14 #include "dbus/bus.h" | 14 #include "dbus/bus.h" |
15 #include "dbus/file_descriptor.h" | 15 #include "dbus/file_descriptor.h" |
16 #include "dbus/message.h" | 16 #include "dbus/message.h" |
17 #include "dbus/object_path.h" | 17 #include "dbus/object_path.h" |
18 #include "dbus/object_proxy.h" | 18 #include "dbus/object_proxy.h" |
19 #include "mojo/common/channel_init.h" | 19 #include "mojo/common/channel_init.h" |
20 #include "mojo/dbus/dbus_external_service.h" | 20 #include "mojo/dbus/dbus_external_service.h" |
21 #include "mojo/embedder/platform_channel_pair.h" | 21 #include "mojo/embedder/platform_channel_pair.h" |
22 #include "mojo/public/cpp/bindings/allocation_scope.h" | |
23 #include "mojo/shell/context.h" | 22 #include "mojo/shell/context.h" |
24 #include "mojo/shell/external_service.mojom.h" | 23 #include "mojo/shell/external_service.mojom.h" |
25 #include "mojo/shell/keep_alive.h" | 24 #include "mojo/shell/keep_alive.h" |
26 | 25 |
27 namespace mojo { | 26 namespace mojo { |
28 namespace shell { | 27 namespace shell { |
29 | 28 |
30 // Manages the connection to a single externally-running service. | 29 // Manages the connection to a single externally-running service. |
31 class DBusServiceLoader::LoadContext { | 30 class DBusServiceLoader::LoadContext { |
32 public: | 31 public: |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // TODO(cmasone): handle errors! | 97 // TODO(cmasone): handle errors! |
99 service_dbus_proxy_->CallMethod( | 98 service_dbus_proxy_->CallMethod( |
100 &call, | 99 &call, |
101 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 100 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
102 base::Bind(&LoadContext::ActivateService, base::Unretained(this))); | 101 base::Bind(&LoadContext::ActivateService, base::Unretained(this))); |
103 } | 102 } |
104 | 103 |
105 // Sends a ShellHandle over to the now-connected externally-running service, | 104 // Sends a ShellHandle over to the now-connected externally-running service, |
106 // using the Mojo ExternalService API. | 105 // using the Mojo ExternalService API. |
107 void ActivateService(dbus::Response* response) { | 106 void ActivateService(dbus::Response* response) { |
108 mojo::AllocationScope scope; | |
109 external_service_->Activate( | 107 external_service_->Activate( |
110 mojo::ScopedMessagePipeHandle( | 108 mojo::ScopedMessagePipeHandle( |
111 mojo::MessagePipeHandle( | 109 mojo::MessagePipeHandle( |
112 service_provider_handle_.release().value()))); | 110 service_provider_handle_.release().value()))); |
113 } | 111 } |
114 | 112 |
115 // Should the ExternalService disappear completely, destroy connection state. | 113 // Should the ExternalService disappear completely, destroy connection state. |
116 // NB: This triggers off of the service disappearing from | 114 // NB: This triggers off of the service disappearing from |
117 // DBus. Perhaps there's a way to watch at the Mojo layer instead, | 115 // DBus. Perhaps there's a way to watch at the Mojo layer instead, |
118 // and that would be superior? | 116 // and that would be superior? |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 DCHECK(it != url_to_load_context_.end()) << url; | 172 DCHECK(it != url_to_load_context_.end()) << url; |
175 | 173 |
176 LoadContext* doomed = it->second; | 174 LoadContext* doomed = it->second; |
177 url_to_load_context_.erase(it); | 175 url_to_load_context_.erase(it); |
178 | 176 |
179 delete doomed; | 177 delete doomed; |
180 } | 178 } |
181 | 179 |
182 } // namespace shell | 180 } // namespace shell |
183 } // namespace mojo | 181 } // namespace mojo |
OLD | NEW |