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" | |
20 #include "mojo/dbus/dbus_external_service.h" | 19 #include "mojo/dbus/dbus_external_service.h" |
| 20 #include "mojo/embedder/channel_init.h" |
21 #include "mojo/embedder/platform_channel_pair.h" | 21 #include "mojo/embedder/platform_channel_pair.h" |
22 #include "mojo/shell/context.h" | 22 #include "mojo/shell/context.h" |
23 #include "mojo/shell/external_service.mojom.h" | 23 #include "mojo/shell/external_service.mojom.h" |
24 #include "mojo/shell/keep_alive.h" | 24 #include "mojo/shell/keep_alive.h" |
25 | 25 |
26 namespace mojo { | 26 namespace mojo { |
27 namespace shell { | 27 namespace shell { |
28 | 28 |
29 // Manages the connection to a single externally-running service. | 29 // Manages the connection to a single externally-running service. |
30 class DBusServiceLoader::LoadContext { | 30 class DBusServiceLoader::LoadContext { |
(...skipping 26 matching lines...) Expand all Loading... |
57 private: | 57 private: |
58 // Sets up a pipe to share with the externally-running service and returns | 58 // Sets up a pipe to share with the externally-running service and returns |
59 // the endpoint that should be sent over DBus. | 59 // the endpoint that should be sent over DBus. |
60 // The FD for the endpoint must be validated on an IO thread. | 60 // The FD for the endpoint must be validated on an IO thread. |
61 scoped_ptr<dbus::FileDescriptor> CreateChannelOnIOThread() { | 61 scoped_ptr<dbus::FileDescriptor> CreateChannelOnIOThread() { |
62 base::ThreadRestrictions::AssertIOAllowed(); | 62 base::ThreadRestrictions::AssertIOAllowed(); |
63 CHECK(bus_->Connect()); | 63 CHECK(bus_->Connect()); |
64 CHECK(bus_->SetUpAsyncOperations()); | 64 CHECK(bus_->SetUpAsyncOperations()); |
65 | 65 |
66 embedder::PlatformChannelPair channel_pair; | 66 embedder::PlatformChannelPair channel_pair; |
67 channel_init_.reset(new common::ChannelInit); | 67 channel_init_.reset(new embedder::ChannelInit); |
68 mojo::ScopedMessagePipeHandle bootstrap_message_pipe = | 68 mojo::ScopedMessagePipeHandle bootstrap_message_pipe = |
69 channel_init_->Init(channel_pair.PassServerHandle().release().fd, | 69 channel_init_->Init(channel_pair.PassServerHandle().release().fd, |
70 loader_->context_->task_runners()->io_runner()); | 70 loader_->context_->task_runners()->io_runner()); |
71 CHECK(bootstrap_message_pipe.is_valid()); | 71 CHECK(bootstrap_message_pipe.is_valid()); |
72 | 72 |
73 external_service_.Bind(bootstrap_message_pipe.Pass()); | 73 external_service_.Bind(bootstrap_message_pipe.Pass()); |
74 | 74 |
75 scoped_ptr<dbus::FileDescriptor> client_fd(new dbus::FileDescriptor); | 75 scoped_ptr<dbus::FileDescriptor> client_fd(new dbus::FileDescriptor); |
76 client_fd->PutValue(channel_pair.PassClientHandle().release().fd); | 76 client_fd->PutValue(channel_pair.PassClientHandle().release().fd); |
77 client_fd->CheckValidity(); // Must be run on an IO thread. | 77 client_fd->CheckValidity(); // Must be run on an IO thread. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 base::Unretained(loader_), url_)); | 126 base::Unretained(loader_), url_)); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 DBusServiceLoader* const loader_; | 130 DBusServiceLoader* const loader_; |
131 scoped_refptr<dbus::Bus> bus_; | 131 scoped_refptr<dbus::Bus> bus_; |
132 dbus::ObjectProxy* service_dbus_proxy_; // Owned by bus_; | 132 dbus::ObjectProxy* service_dbus_proxy_; // Owned by bus_; |
133 const GURL url_; | 133 const GURL url_; |
134 ScopedMessagePipeHandle service_provider_handle_; | 134 ScopedMessagePipeHandle service_provider_handle_; |
135 KeepAlive keep_alive_; | 135 KeepAlive keep_alive_; |
136 scoped_ptr<common::ChannelInit> channel_init_; | 136 scoped_ptr<embedder::ChannelInit> channel_init_; |
137 ExternalServicePtr external_service_; | 137 ExternalServicePtr external_service_; |
138 | 138 |
139 DISALLOW_COPY_AND_ASSIGN(LoadContext); | 139 DISALLOW_COPY_AND_ASSIGN(LoadContext); |
140 }; | 140 }; |
141 | 141 |
142 DBusServiceLoader::DBusServiceLoader(Context* context) : context_(context) { | 142 DBusServiceLoader::DBusServiceLoader(Context* context) : context_(context) { |
143 dbus::Bus::Options options; | 143 dbus::Bus::Options options; |
144 options.bus_type = dbus::Bus::SESSION; | 144 options.bus_type = dbus::Bus::SESSION; |
145 options.dbus_task_runner = context_->task_runners()->io_runner(); | 145 options.dbus_task_runner = context_->task_runners()->io_runner(); |
146 bus_ = new dbus::Bus(options); | 146 bus_ = new dbus::Bus(options); |
(...skipping 25 matching lines...) Expand all Loading... |
172 DCHECK(it != url_to_load_context_.end()) << url; | 172 DCHECK(it != url_to_load_context_.end()) << url; |
173 | 173 |
174 LoadContext* doomed = it->second; | 174 LoadContext* doomed = it->second; |
175 url_to_load_context_.erase(it); | 175 url_to_load_context_.erase(it); |
176 | 176 |
177 delete doomed; | 177 delete doomed; |
178 } | 178 } |
179 | 179 |
180 } // namespace shell | 180 } // namespace shell |
181 } // namespace mojo | 181 } // namespace mojo |
OLD | NEW |