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" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); |
147 } | 147 } |
148 | 148 |
149 DBusServiceLoader::~DBusServiceLoader() { | 149 DBusServiceLoader::~DBusServiceLoader() { |
150 DCHECK(url_to_load_context_.empty()); | 150 DCHECK(url_to_load_context_.empty()); |
151 } | 151 } |
152 | 152 |
153 void DBusServiceLoader::Load(ServiceManager* manager, | 153 void DBusServiceLoader::LoadService(ServiceManager* manager, |
154 const GURL& url, | 154 const GURL& url, |
155 scoped_refptr<LoadCallbacks> callbacks) { | 155 ScopedMessagePipeHandle shell_handle) { |
156 // TODO(aa): This could be delayed until later, when we know that loading is | |
157 // going to succeed. | |
158 ScopedMessagePipeHandle shell_handle = callbacks->RegisterApplication(); | |
159 if (!shell_handle.is_valid()) | |
160 return; | |
161 | |
162 DCHECK(url.SchemeIs("dbus")); | 156 DCHECK(url.SchemeIs("dbus")); |
163 DCHECK(url_to_load_context_.find(url) == url_to_load_context_.end()); | 157 DCHECK(url_to_load_context_.find(url) == url_to_load_context_.end()); |
164 url_to_load_context_[url] = | 158 url_to_load_context_[url] = |
165 new LoadContext(this, bus_, url, shell_handle.Pass()); | 159 new LoadContext(this, bus_, url, shell_handle.Pass()); |
166 } | 160 } |
167 | 161 |
168 void DBusServiceLoader::OnServiceError(ServiceManager* manager, | 162 void DBusServiceLoader::OnServiceError(ServiceManager* manager, |
169 const GURL& url) { | 163 const GURL& url) { |
170 // TODO(cmasone): Anything at all in this method here. | 164 // TODO(cmasone): Anything at all in this method here. |
171 } | 165 } |
172 | 166 |
173 void DBusServiceLoader::ForgetService(const GURL& url) { | 167 void DBusServiceLoader::ForgetService(const GURL& url) { |
174 DCHECK(context_->task_runners()->shell_runner()->BelongsToCurrentThread()); | 168 DCHECK(context_->task_runners()->shell_runner()->BelongsToCurrentThread()); |
175 DVLOG(2) << "Forgetting service (url: " << url << ")"; | 169 DVLOG(2) << "Forgetting service (url: " << url << ")"; |
176 | 170 |
177 LoadContextMap::iterator it = url_to_load_context_.find(url); | 171 LoadContextMap::iterator it = url_to_load_context_.find(url); |
178 DCHECK(it != url_to_load_context_.end()) << url; | 172 DCHECK(it != url_to_load_context_.end()) << url; |
179 | 173 |
180 LoadContext* doomed = it->second; | 174 LoadContext* doomed = it->second; |
181 url_to_load_context_.erase(it); | 175 url_to_load_context_.erase(it); |
182 | 176 |
183 delete doomed; | 177 delete doomed; |
184 } | 178 } |
185 | 179 |
186 } // namespace shell | 180 } // namespace shell |
187 } // namespace mojo | 181 } // namespace mojo |
OLD | NEW |