Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: mojo/shell/dbus_service_loader_linux.cc

Issue 265793015: Mojo: Replace RemotePtr with InterfacePtr and InterfaceImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: snapshot Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 21 matching lines...) Expand all
32 // Manages the connection to a single externally-running service. 32 // Manages the connection to a single externally-running service.
33 class DBusServiceLoader::LoadContext : public mojo::ExternalServiceHost { 33 class DBusServiceLoader::LoadContext : public mojo::ExternalServiceHost {
34 public: 34 public:
35 // Kicks off the attempt to bootstrap a connection to the externally-running 35 // Kicks off the attempt to bootstrap a connection to the externally-running
36 // service specified by url_. 36 // service specified by url_.
37 // Creates a MessagePipe and passes one end over DBus to the service. Then, 37 // Creates a MessagePipe and passes one end over DBus to the service. Then,
38 // calls ExternalService::Activate(ShellHandle) over the now-shared pipe. 38 // calls ExternalService::Activate(ShellHandle) over the now-shared pipe.
39 LoadContext(DBusServiceLoader* loader, 39 LoadContext(DBusServiceLoader* loader,
40 const scoped_refptr<dbus::Bus>& bus, 40 const scoped_refptr<dbus::Bus>& bus,
41 const GURL& url, 41 const GURL& url,
42 ScopedShellHandle shell_handle) 42 ScopedMessagePipeHandle shell_handle)
43 : loader_(loader), 43 : loader_(loader),
44 bus_(bus), 44 bus_(bus),
45 service_dbus_proxy_(NULL), 45 service_dbus_proxy_(NULL),
46 url_(url), 46 url_(url),
47 shell_handle_(shell_handle.Pass()), 47 shell_handle_(shell_handle.Pass()),
48 keep_alive_(loader->context_) { 48 keep_alive_(loader->context_) {
49 base::PostTaskAndReplyWithResult( 49 base::PostTaskAndReplyWithResult(
50 loader_->context_->task_runners()->io_runner(), 50 loader_->context_->task_runners()->io_runner(),
51 FROM_HERE, 51 FROM_HERE,
52 base::Bind(&LoadContext::CreateChannelOnIOThread, 52 base::Bind(&LoadContext::CreateChannelOnIOThread,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 FROM_HERE, 129 FROM_HERE,
130 base::Bind(&DBusServiceLoader::ForgetService, 130 base::Bind(&DBusServiceLoader::ForgetService,
131 base::Unretained(loader_), url_)); 131 base::Unretained(loader_), url_));
132 } 132 }
133 } 133 }
134 134
135 DBusServiceLoader* const loader_; 135 DBusServiceLoader* const loader_;
136 scoped_refptr<dbus::Bus> bus_; 136 scoped_refptr<dbus::Bus> bus_;
137 dbus::ObjectProxy* service_dbus_proxy_; // Owned by bus_; 137 dbus::ObjectProxy* service_dbus_proxy_; // Owned by bus_;
138 const GURL url_; 138 const GURL url_;
139 ScopedShellHandle shell_handle_; 139 ScopedMessagePipeHandle shell_handle_;
140 KeepAlive keep_alive_; 140 KeepAlive keep_alive_;
141 scoped_ptr<common::ChannelInit> channel_init_; 141 scoped_ptr<common::ChannelInit> channel_init_;
142 mojo::RemotePtr<mojo::ExternalService> external_service_; 142 mojo::RemotePtr<mojo::ExternalService> external_service_;
143 143
144 DISALLOW_COPY_AND_ASSIGN(LoadContext); 144 DISALLOW_COPY_AND_ASSIGN(LoadContext);
145 }; 145 };
146 146
147 DBusServiceLoader::DBusServiceLoader(Context* context) : context_(context) { 147 DBusServiceLoader::DBusServiceLoader(Context* context) : context_(context) {
148 dbus::Bus::Options options; 148 dbus::Bus::Options options;
149 options.bus_type = dbus::Bus::SESSION; 149 options.bus_type = dbus::Bus::SESSION;
150 options.dbus_task_runner = context_->task_runners()->io_runner(); 150 options.dbus_task_runner = context_->task_runners()->io_runner();
151 bus_ = new dbus::Bus(options); 151 bus_ = new dbus::Bus(options);
152 } 152 }
153 153
154 DBusServiceLoader::~DBusServiceLoader() { 154 DBusServiceLoader::~DBusServiceLoader() {
155 DCHECK(url_to_load_context_.empty()); 155 DCHECK(url_to_load_context_.empty());
156 } 156 }
157 157
158 void DBusServiceLoader::LoadService(ServiceManager* manager, 158 void DBusServiceLoader::LoadService(ServiceManager* manager,
159 const GURL& url, 159 const GURL& url,
160 ScopedShellHandle service_handle) { 160 ScopedMessagePipeHandle service_handle) {
161 DCHECK(url.SchemeIs("dbus")); 161 DCHECK(url.SchemeIs("dbus"));
162 DCHECK(url_to_load_context_.find(url) == url_to_load_context_.end()); 162 DCHECK(url_to_load_context_.find(url) == url_to_load_context_.end());
163 url_to_load_context_[url] = 163 url_to_load_context_[url] =
164 new LoadContext(this, bus_, url, service_handle.Pass()); 164 new LoadContext(this, bus_, url, service_handle.Pass());
165 } 165 }
166 166
167 void DBusServiceLoader::OnServiceError(ServiceManager* manager, 167 void DBusServiceLoader::OnServiceError(ServiceManager* manager,
168 const GURL& url) { 168 const GURL& url) {
169 // TODO(cmasone): Anything at all in this method here. 169 // TODO(cmasone): Anything at all in this method here.
170 } 170 }
171 171
172 void DBusServiceLoader::ForgetService(const GURL& url) { 172 void DBusServiceLoader::ForgetService(const GURL& url) {
173 DCHECK(context_->task_runners()->ui_runner()->BelongsToCurrentThread()); 173 DCHECK(context_->task_runners()->ui_runner()->BelongsToCurrentThread());
174 DVLOG(2) << "Forgetting service (url: " << url << ")"; 174 DVLOG(2) << "Forgetting service (url: " << url << ")";
175 175
176 LoadContextMap::iterator it = url_to_load_context_.find(url); 176 LoadContextMap::iterator it = url_to_load_context_.find(url);
177 DCHECK(it != url_to_load_context_.end()) << url; 177 DCHECK(it != url_to_load_context_.end()) << url;
178 178
179 LoadContext* doomed = it->second; 179 LoadContext* doomed = it->second;
180 url_to_load_context_.erase(it); 180 url_to_load_context_.erase(it);
181 181
182 delete doomed; 182 delete doomed;
183 } 183 }
184 184
185 } // namespace shell 185 } // namespace shell
186 } // namespace mojo 186 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698