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

Side by Side Diff: chrome/browser/chromeos/dbus/bluetooth_adapter_client.cc

Issue 9378039: dbus: add ObjectPath type (Closed) Base URL: http://git.chromium.org/git/chromium/src@master
Patch Set: add patch for cryptohome_client Created 8 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/dbus/bluetooth_adapter_client.h" 5 #include "chrome/browser/chromeos/dbus/bluetooth_adapter_client.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "chrome/browser/chromeos/dbus/bluetooth_manager_client.h" 12 #include "chrome/browser/chromeos/dbus/bluetooth_manager_client.h"
13 #include "chrome/browser/chromeos/system/runtime_environment.h" 13 #include "chrome/browser/chromeos/system/runtime_environment.h"
14 #include "dbus/bus.h" 14 #include "dbus/bus.h"
15 #include "dbus/message.h" 15 #include "dbus/message.h"
16 #include "dbus/object_path.h"
16 #include "dbus/object_proxy.h" 17 #include "dbus/object_proxy.h"
17 #include "third_party/cros_system_api/dbus/service_constants.h" 18 #include "third_party/cros_system_api/dbus/service_constants.h"
18 19
19 namespace { 20 namespace {
20 21
21 // Utility function to convert an array of dbus dict_entry objects into a 22 // Utility function to convert an array of dbus dict_entry objects into a
22 // DictionaryValue object. 23 // DictionaryValue object.
23 // 24 //
24 // The dict_entry objects must have keys that are strings and values that are 25 // The dict_entry objects must have keys that are strings and values that are
25 // simple variants. 26 // simple variants.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 136 }
136 case dbus::Message::STRING: { 137 case dbus::Message::STRING: {
137 std::string value; 138 std::string value;
138 if (!variant_reader.PopString(&value)) { 139 if (!variant_reader.PopString(&value)) {
139 return false; 140 return false;
140 } 141 }
141 dictionary->SetString(key, value); 142 dictionary->SetString(key, value);
142 break; 143 break;
143 } 144 }
144 case dbus::Message::OBJECT_PATH: { 145 case dbus::Message::OBJECT_PATH: {
145 std::string value; 146 dbus::ObjectPath value;
146 if (!variant_reader.PopObjectPath(&value)) { 147 if (!variant_reader.PopObjectPath(&value)) {
147 return false; 148 return false;
148 } 149 }
149 dictionary->SetString(key, value); 150 dictionary->SetString(key, value.value());
150 break; 151 break;
151 } 152 }
152 case dbus::Message::ARRAY: { 153 case dbus::Message::ARRAY: {
153 // Not yet supported. 154 // Not yet supported.
154 return false; 155 return false;
155 } 156 }
156 case dbus::Message::STRUCT: { 157 case dbus::Message::STRUCT: {
157 // Not yet supported. 158 // Not yet supported.
158 return false; 159 return false;
159 } 160 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 202 }
202 203
203 // BluetoothAdapterClient override. 204 // BluetoothAdapterClient override.
204 virtual void RemoveObserver(BluetoothAdapterClient::Observer* observer) { 205 virtual void RemoveObserver(BluetoothAdapterClient::Observer* observer) {
205 VLOG(1) << "RemoveObserver"; 206 VLOG(1) << "RemoveObserver";
206 DCHECK(observer); 207 DCHECK(observer);
207 observers_.RemoveObserver(observer); 208 observers_.RemoveObserver(observer);
208 } 209 }
209 210
210 // BluetoothAdapterClient override. 211 // BluetoothAdapterClient override.
211 virtual void StartDiscovery(const std::string& object_path) { 212 virtual void StartDiscovery(const dbus::ObjectPath& object_path) {
212 VLOG(1) << "StartDiscovery: " << object_path; 213 VLOG(1) << "StartDiscovery: " << object_path.value();
213 214
214 dbus::MethodCall method_call( 215 dbus::MethodCall method_call(
215 bluetooth_adapter::kBluetoothAdapterInterface, 216 bluetooth_adapter::kBluetoothAdapterInterface,
216 bluetooth_adapter::kStartDiscovery); 217 bluetooth_adapter::kStartDiscovery);
217 218
218 dbus::ObjectProxy* adapter_proxy = GetObjectProxyForPath(object_path); 219 dbus::ObjectProxy* adapter_proxy = GetObjectProxyForPath(object_path);
219 220
220 adapter_proxy->CallMethod( 221 adapter_proxy->CallMethod(
221 &method_call, 222 &method_call,
222 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 223 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
223 base::Bind(&BluetoothAdapterClientImpl::OnStartDiscovery, 224 base::Bind(&BluetoothAdapterClientImpl::OnStartDiscovery,
224 weak_ptr_factory_.GetWeakPtr(), object_path)); 225 weak_ptr_factory_.GetWeakPtr(), object_path));
225 } 226 }
226 227
227 // BluetoothAdapterClient override. 228 // BluetoothAdapterClient override.
228 virtual void StopDiscovery(const std::string& object_path) { 229 virtual void StopDiscovery(const dbus::ObjectPath& object_path) {
229 VLOG(1) << "StopDiscovery: " << object_path; 230 VLOG(1) << "StopDiscovery: " << object_path.value();
230 231
231 dbus::MethodCall method_call( 232 dbus::MethodCall method_call(
232 bluetooth_adapter::kBluetoothAdapterInterface, 233 bluetooth_adapter::kBluetoothAdapterInterface,
233 bluetooth_adapter::kStopDiscovery); 234 bluetooth_adapter::kStopDiscovery);
234 235
235 dbus::ObjectProxy* adapter_proxy = GetObjectProxyForPath(object_path); 236 dbus::ObjectProxy* adapter_proxy = GetObjectProxyForPath(object_path);
236 237
237 adapter_proxy->CallMethod( 238 adapter_proxy->CallMethod(
238 &method_call, 239 &method_call,
239 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 240 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
240 base::Bind(&BluetoothAdapterClientImpl::OnStopDiscovery, 241 base::Bind(&BluetoothAdapterClientImpl::OnStopDiscovery,
241 weak_ptr_factory_.GetWeakPtr(), object_path)); 242 weak_ptr_factory_.GetWeakPtr(), object_path));
242 } 243 }
243 244
244 private: 245 private:
245 // BluetoothManagerClient::Observer override. 246 // BluetoothManagerClient::Observer override.
246 virtual void AdapterAdded(const std::string& object_path) OVERRIDE { 247 virtual void AdapterAdded(const dbus::ObjectPath& object_path) OVERRIDE {
247 VLOG(1) << "AdapterAdded: " << object_path; 248 VLOG(1) << "AdapterAdded: " << object_path.value();
248 } 249 }
249 250
250 // BluetoothManagerClient::Observer override. 251 // BluetoothManagerClient::Observer override.
251 virtual void AdapterRemoved(const std::string& object_path) OVERRIDE { 252 virtual void AdapterRemoved(const dbus::ObjectPath& object_path) OVERRIDE {
252 VLOG(1) << "AdapterRemoved: " << object_path; 253 VLOG(1) << "AdapterRemoved: " << object_path.value();
253 RemoveObjectProxyForPath(object_path); 254 RemoveObjectProxyForPath(object_path);
254 } 255 }
255 256
256 // Ensures that we have a dbus object proxy for an adapter with dbus 257 // Ensures that we have a dbus object proxy for an adapter with dbus
257 // object path |object_path|, and if not, creates it and stores it in 258 // object path |object_path|, and if not, creates it and stores it in
258 // our |proxy_map_| map. 259 // our |proxy_map_| map.
259 dbus::ObjectProxy* GetObjectProxyForPath(const std::string& object_path) { 260 dbus::ObjectProxy* GetObjectProxyForPath(
260 VLOG(1) << "GetObjectProxyForPath: " << object_path; 261 const dbus::ObjectPath& object_path) {
262 VLOG(1) << "GetObjectProxyForPath: " << object_path.value();
261 263
262 ProxyMap::iterator it = proxy_map_.find(object_path); 264 ProxyMap::iterator it = proxy_map_.find(object_path);
263 if (it != proxy_map_.end()) 265 if (it != proxy_map_.end())
264 return it->second; 266 return it->second;
265 267
266 DCHECK(bus_); 268 DCHECK(bus_);
267 dbus::ObjectProxy* adapter_proxy = bus_->GetObjectProxy( 269 dbus::ObjectProxy* adapter_proxy = bus_->GetObjectProxy(
268 bluetooth_adapter::kBluetoothAdapterServiceName, object_path); 270 bluetooth_adapter::kBluetoothAdapterServiceName, object_path);
269 271
270 proxy_map_[object_path] = adapter_proxy; 272 proxy_map_[object_path] = adapter_proxy;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 base::Bind(&BluetoothAdapterClientImpl::DeviceDisappearedReceived, 309 base::Bind(&BluetoothAdapterClientImpl::DeviceDisappearedReceived,
308 weak_ptr_factory_.GetWeakPtr(), object_path), 310 weak_ptr_factory_.GetWeakPtr(), object_path),
309 base::Bind(&BluetoothAdapterClientImpl::DeviceDisappearedConnected, 311 base::Bind(&BluetoothAdapterClientImpl::DeviceDisappearedConnected,
310 weak_ptr_factory_.GetWeakPtr(), object_path)); 312 weak_ptr_factory_.GetWeakPtr(), object_path));
311 313
312 return adapter_proxy; 314 return adapter_proxy;
313 } 315 }
314 316
315 // Removes the dbus object proxy for the adapter with dbus object path 317 // Removes the dbus object proxy for the adapter with dbus object path
316 // |object_path| from our |proxy_map_| map. 318 // |object_path| from our |proxy_map_| map.
317 void RemoveObjectProxyForPath(const std::string& object_path) { 319 void RemoveObjectProxyForPath(const dbus::ObjectPath& object_path) {
318 VLOG(1) << "RemoveObjectProxyForPath: " << object_path; 320 VLOG(1) << "RemoveObjectProxyForPath: " << object_path.value();
319 proxy_map_.erase(object_path); 321 proxy_map_.erase(object_path);
320 } 322 }
321 323
322 // Called by dbus:: when a DeviceCreated signal is received. 324 // Called by dbus:: when a DeviceCreated signal is received.
323 void DeviceCreatedReceived(const std::string& object_path, 325 void DeviceCreatedReceived(const dbus::ObjectPath& object_path,
324 dbus::Signal* signal) { 326 dbus::Signal* signal) {
325 DCHECK(signal); 327 DCHECK(signal);
326 dbus::MessageReader reader(signal); 328 dbus::MessageReader reader(signal);
327 std::string device_path; 329 dbus::ObjectPath device_path;
328 if (!reader.PopObjectPath(&device_path)) { 330 if (!reader.PopObjectPath(&device_path)) {
329 LOG(ERROR) << object_path 331 LOG(ERROR) << object_path.value()
330 << ": DeviceCreated signal has incorrect parameters: " 332 << ": DeviceCreated signal has incorrect parameters: "
331 << signal->ToString(); 333 << signal->ToString();
332 return; 334 return;
333 } 335 }
334 VLOG(1) << object_path << ": Device created: " << device_path; 336 VLOG(1) << object_path.value() << ": Device created: "
337 << device_path.value();
335 338
336 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, 339 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_,
337 DeviceCreated(object_path, device_path)); 340 DeviceCreated(object_path, device_path));
338 } 341 }
339 342
340 // Called by dbus:: when the DeviceCreated signal is initially connected. 343 // Called by dbus:: when the DeviceCreated signal is initially connected.
341 void DeviceCreatedConnected(const std::string& object_path, 344 void DeviceCreatedConnected(const dbus::ObjectPath& object_path,
342 const std::string& interface_name, 345 const std::string& interface_name,
343 const std::string& signal_name, 346 const std::string& signal_name,
344 bool success) { 347 bool success) {
345 LOG_IF(WARNING, !success) << object_path 348 LOG_IF(WARNING, !success) << object_path.value()
346 << ": Failed to connect to DeviceCreated signal."; 349 << ": Failed to connect to DeviceCreated signal.";
347 } 350 }
348 351
349 // Called by dbus:: when a DeviceRemoved signal is received. 352 // Called by dbus:: when a DeviceRemoved signal is received.
350 void DeviceRemovedReceived(const std::string& object_path, 353 void DeviceRemovedReceived(const dbus::ObjectPath& object_path,
351 dbus::Signal* signal) { 354 dbus::Signal* signal) {
352 DCHECK(signal); 355 DCHECK(signal);
353 dbus::MessageReader reader(signal); 356 dbus::MessageReader reader(signal);
354 std::string device_path; 357 dbus::ObjectPath device_path;
355 if (!reader.PopObjectPath(&device_path)) { 358 if (!reader.PopObjectPath(&device_path)) {
356 LOG(ERROR) << object_path 359 LOG(ERROR) << object_path.value()
357 << ": DeviceRemoved signal has incorrect parameters: " 360 << ": DeviceRemoved signal has incorrect parameters: "
358 << signal->ToString(); 361 << signal->ToString();
359 return; 362 return;
360 } 363 }
361 VLOG(1) << object_path << ": Device removed: " << device_path; 364 VLOG(1) << object_path.value() << ": Device removed: "
365 << device_path.value();
362 366
363 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, 367 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_,
364 DeviceRemoved(object_path, device_path)); 368 DeviceRemoved(object_path, device_path));
365 } 369 }
366 370
367 // Called by dbus:: when the DeviceRemoved signal is initially connected. 371 // Called by dbus:: when the DeviceRemoved signal is initially connected.
368 void DeviceRemovedConnected(const std::string& object_path, 372 void DeviceRemovedConnected(const dbus::ObjectPath& object_path,
369 const std::string& interface_name, 373 const std::string& interface_name,
370 const std::string& signal_name, 374 const std::string& signal_name,
371 bool success) { 375 bool success) {
372 LOG_IF(WARNING, !success) << object_path 376 LOG_IF(WARNING, !success) << object_path.value()
373 << ": Failed to connect to DeviceRemoved signal."; 377 << ": Failed to connect to DeviceRemoved signal.";
374 } 378 }
375 379
376 // Called by dbus:: when a PropertyChanged signal is received. 380 // Called by dbus:: when a PropertyChanged signal is received.
377 void PropertyChangedReceived(const std::string& object_path, 381 void PropertyChangedReceived(const dbus::ObjectPath& object_path,
378 dbus::Signal* signal) { 382 dbus::Signal* signal) {
379 DCHECK(signal); 383 DCHECK(signal);
380 dbus::MessageReader reader(signal); 384 dbus::MessageReader reader(signal);
381 std::string property_name; 385 std::string property_name;
382 if (!reader.PopString(&property_name)) { 386 if (!reader.PopString(&property_name)) {
383 LOG(ERROR) << object_path 387 LOG(ERROR) << object_path.value()
384 << ": PropertyChanged signal has incorrect parameters: " 388 << ": PropertyChanged signal has incorrect parameters: "
385 << signal->ToString(); 389 << signal->ToString();
386 return; 390 return;
387 } 391 }
388 392
389 if (property_name != bluetooth_adapter::kDiscoveringProperty) { 393 if (property_name != bluetooth_adapter::kDiscoveringProperty) {
390 VLOG(1) << object_path << ": PropertyChanged: " << property_name; 394 VLOG(1) << object_path.value() << ": PropertyChanged: " << property_name;
391 // We don't care. 395 // We don't care.
392 return; 396 return;
393 } 397 }
394 398
395 bool discovering = false; 399 bool discovering = false;
396 if (!reader.PopVariantOfBool(&discovering)) { 400 if (!reader.PopVariantOfBool(&discovering)) {
397 LOG(ERROR) << object_path 401 LOG(ERROR) << object_path.value()
398 << ": PropertyChanged signal has incorrect parameters: " 402 << ": PropertyChanged signal has incorrect parameters: "
399 << signal->ToString(); 403 << signal->ToString();
400 return; 404 return;
401 } 405 }
402 VLOG(1) << object_path << ": PropertyChanged: Discovering = " 406 VLOG(1) << object_path.value() << ": PropertyChanged: Discovering = "
403 << discovering; 407 << discovering;
404 408
405 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, 409 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_,
406 DiscoveringPropertyChanged(object_path, discovering)); 410 DiscoveringPropertyChanged(object_path, discovering));
407 } 411 }
408 412
409 // Called by dbus:: when the PropertyChanged signal is initially connected. 413 // Called by dbus:: when the PropertyChanged signal is initially connected.
410 void PropertyChangedConnected(const std::string& object_path, 414 void PropertyChangedConnected(const dbus::ObjectPath& object_path,
411 const std::string& interface_name, 415 const std::string& interface_name,
412 const std::string& signal_name, 416 const std::string& signal_name,
413 bool success) { 417 bool success) {
414 LOG_IF(WARNING, !success) << object_path 418 LOG_IF(WARNING, !success)
419 << object_path.value()
415 << ": Failed to connect to PropertyChanged signal."; 420 << ": Failed to connect to PropertyChanged signal.";
416 } 421 }
417 422
418 // Called by dbus:: when a DeviceFound signal is received. 423 // Called by dbus:: when a DeviceFound signal is received.
419 void DeviceFoundReceived(const std::string& object_path, 424 void DeviceFoundReceived(const dbus::ObjectPath& object_path,
420 dbus::Signal* signal) { 425 dbus::Signal* signal) {
421 DCHECK(signal); 426 DCHECK(signal);
422 dbus::MessageReader reader(signal); 427 dbus::MessageReader reader(signal);
423 std::string address; 428 std::string address;
424 if (!reader.PopString(&address)) { 429 if (!reader.PopString(&address)) {
425 LOG(ERROR) << object_path 430 LOG(ERROR) << object_path.value()
426 << ": DeviceFound signal has incorrect parameters: " 431 << ": DeviceFound signal has incorrect parameters: "
427 << signal->ToString(); 432 << signal->ToString();
428 return; 433 return;
429 } 434 }
430 VLOG(1) << object_path << ": Device found: " << address; 435 VLOG(1) << object_path.value() << ": Device found: " << address;
431 436
432 DictionaryValue device_properties; 437 DictionaryValue device_properties;
433 if (!PopArrayOfDictEntries(&reader, signal, &device_properties)) { 438 if (!PopArrayOfDictEntries(&reader, signal, &device_properties)) {
434 LOG(ERROR) << object_path 439 LOG(ERROR) << object_path.value()
435 << ": DeviceFound signal has incorrect parameters: " 440 << ": DeviceFound signal has incorrect parameters: "
436 << signal->ToString(); 441 << signal->ToString();
437 return; 442 return;
438 } 443 }
439 444
440 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, 445 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_,
441 DeviceFound(object_path, address, device_properties)); 446 DeviceFound(object_path, address, device_properties));
442 } 447 }
443 448
444 // Called by dbus:: when the DeviceFound signal is initially connected. 449 // Called by dbus:: when the DeviceFound signal is initially connected.
445 void DeviceFoundConnected(const std::string& object_path, 450 void DeviceFoundConnected(const dbus::ObjectPath& object_path,
446 const std::string& interface_name, 451 const std::string& interface_name,
447 const std::string& signal_name, 452 const std::string& signal_name,
448 bool success) { 453 bool success) {
449 LOG_IF(WARNING, !success) << object_path 454 LOG_IF(WARNING, !success) << object_path.value()
450 << ": Failed to connect to DeviceFound signal."; 455 << ": Failed to connect to DeviceFound signal.";
451 } 456 }
452 457
453 // Called by dbus:: when a DeviceDisappeared signal is received. 458 // Called by dbus:: when a DeviceDisappeared signal is received.
454 void DeviceDisappearedReceived(const std::string& object_path, 459 void DeviceDisappearedReceived(const dbus::ObjectPath& object_path,
455 dbus::Signal* signal) { 460 dbus::Signal* signal) {
456 DCHECK(signal); 461 DCHECK(signal);
457 dbus::MessageReader reader(signal); 462 dbus::MessageReader reader(signal);
458 std::string address; 463 std::string address;
459 if (!reader.PopString(&address)) { 464 if (!reader.PopString(&address)) {
460 LOG(ERROR) << object_path 465 LOG(ERROR) << object_path.value()
461 << ": DeviceDisappeared signal has incorrect parameters: " 466 << ": DeviceDisappeared signal has incorrect parameters: "
462 << signal->ToString(); 467 << signal->ToString();
463 return; 468 return;
464 } 469 }
465 VLOG(1) << object_path << ": Device disappeared: " << address; 470 VLOG(1) << object_path.value() << ": Device disappeared: " << address;
466 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, 471 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_,
467 DeviceDisappeared(object_path, address)); 472 DeviceDisappeared(object_path, address));
468 } 473 }
469 474
470 // Called by dbus:: when the DeviceDisappeared signal is initially connected. 475 // Called by dbus:: when the DeviceDisappeared signal is initially connected.
471 void DeviceDisappearedConnected(const std::string& object_path, 476 void DeviceDisappearedConnected(const dbus::ObjectPath& object_path,
472 const std::string& interface_name, 477 const std::string& interface_name,
473 const std::string& signal_name, 478 const std::string& signal_name,
474 bool success) { 479 bool success) {
475 LOG_IF(WARNING, !success) << object_path 480 LOG_IF(WARNING, !success)
481 << object_path.value()
476 << ": Failed to connect to DeviceDisappeared signal."; 482 << ": Failed to connect to DeviceDisappeared signal.";
477 } 483 }
478 484
479 // Called when a response for StartDiscovery() is received. 485 // Called when a response for StartDiscovery() is received.
480 void OnStartDiscovery(const std::string& object_path, 486 void OnStartDiscovery(const dbus::ObjectPath& object_path,
481 dbus::Response* response) { 487 dbus::Response* response) {
482 VLOG(1) << "OnStartDiscovery: " << object_path; 488 VLOG(1) << "OnStartDiscovery: " << object_path.value();
483 LOG_IF(WARNING, !response) << object_path << ": OnStartDiscovery: failed."; 489 LOG_IF(WARNING, !response) << object_path.value()
490 << ": OnStartDiscovery: failed.";
484 } 491 }
485 492
486 // Called when a response for StopDiscovery() is received. 493 // Called when a response for StopDiscovery() is received.
487 void OnStopDiscovery(const std::string& object_path, 494 void OnStopDiscovery(const dbus::ObjectPath& object_path,
488 dbus::Response* response) { 495 dbus::Response* response) {
489 VLOG(1) << "OnStopDiscovery: " << object_path; 496 VLOG(1) << "OnStopDiscovery: " << object_path.value();
490 LOG_IF(WARNING, !response) << object_path << ": OnStopDiscovery: failed."; 497 LOG_IF(WARNING, !response) << object_path.value()
498 << ": OnStopDiscovery: failed.";
491 } 499 }
492 500
493 // Weak pointer factory for generating 'this' pointers that might live longer 501 // Weak pointer factory for generating 'this' pointers that might live longer
494 // than we do. 502 // than we do.
495 base::WeakPtrFactory<BluetoothAdapterClientImpl> weak_ptr_factory_; 503 base::WeakPtrFactory<BluetoothAdapterClientImpl> weak_ptr_factory_;
496 504
497 dbus::Bus* bus_; 505 dbus::Bus* bus_;
498 506
499 // We maintain a collection of dbus object proxies, one for each adapter. 507 // We maintain a collection of dbus object proxies, one for each adapter.
500 typedef std::map<const std::string, dbus::ObjectProxy*> ProxyMap; 508 typedef std::map<const dbus::ObjectPath, dbus::ObjectProxy*> ProxyMap;
501 ProxyMap proxy_map_; 509 ProxyMap proxy_map_;
502 510
503 // List of observers interested in event notifications from us. 511 // List of observers interested in event notifications from us.
504 ObserverList<BluetoothAdapterClient::Observer> observers_; 512 ObserverList<BluetoothAdapterClient::Observer> observers_;
505 513
506 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterClientImpl); 514 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterClientImpl);
507 }; 515 };
508 516
509 // The BluetoothAdapterClient implementation used on Linux desktop, which does 517 // The BluetoothAdapterClient implementation used on Linux desktop, which does
510 // nothing. 518 // nothing.
511 class BluetoothAdapterClientStubImpl : public BluetoothAdapterClient { 519 class BluetoothAdapterClientStubImpl : public BluetoothAdapterClient {
512 public: 520 public:
513 // BluetoothAdapterClient override. 521 // BluetoothAdapterClient override.
514 virtual void AddObserver(Observer* observer) { 522 virtual void AddObserver(Observer* observer) {
515 VLOG(1) << "AddObserver"; 523 VLOG(1) << "AddObserver";
516 } 524 }
517 525
518 // BluetoothAdapterClient override. 526 // BluetoothAdapterClient override.
519 virtual void RemoveObserver(Observer* observer) { 527 virtual void RemoveObserver(Observer* observer) {
520 VLOG(1) << "RemoveObserver"; 528 VLOG(1) << "RemoveObserver";
521 } 529 }
522 530
523 // BluetoothAdapterClient override. 531 // BluetoothAdapterClient override.
524 virtual void StartDiscovery(const std::string& object_path) { 532 virtual void StartDiscovery(const dbus::ObjectPath& object_path) {
525 VLOG(1) << "StartDiscovery: " << object_path; 533 VLOG(1) << "StartDiscovery: " << object_path.value();
526 } 534 }
527 535
528 // BluetoothAdapterClient override. 536 // BluetoothAdapterClient override.
529 virtual void StopDiscovery(const std::string& object_path) { 537 virtual void StopDiscovery(const dbus::ObjectPath& object_path) {
530 VLOG(1) << "StopDiscovery: " << object_path; 538 VLOG(1) << "StopDiscovery: " << object_path.value();
531 } 539 }
532 }; 540 };
533 541
534 BluetoothAdapterClient::BluetoothAdapterClient() { 542 BluetoothAdapterClient::BluetoothAdapterClient() {
535 } 543 }
536 544
537 BluetoothAdapterClient::~BluetoothAdapterClient() { 545 BluetoothAdapterClient::~BluetoothAdapterClient() {
538 } 546 }
539 547
540 BluetoothAdapterClient* BluetoothAdapterClient::Create( 548 BluetoothAdapterClient* BluetoothAdapterClient::Create(
541 dbus::Bus* bus, 549 dbus::Bus* bus,
542 BluetoothManagerClient* manager_client) { 550 BluetoothManagerClient* manager_client) {
543 if (system::runtime_environment::IsRunningOnChromeOS()) { 551 if (system::runtime_environment::IsRunningOnChromeOS()) {
544 return new BluetoothAdapterClientImpl(bus, manager_client); 552 return new BluetoothAdapterClientImpl(bus, manager_client);
545 } else { 553 } else {
546 return new BluetoothAdapterClientStubImpl(); 554 return new BluetoothAdapterClientStubImpl();
547 } 555 }
548 } 556 }
549 557
550 } // namespace chromeos 558 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/dbus/bluetooth_adapter_client.h ('k') | chrome/browser/chromeos/dbus/bluetooth_device_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698