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

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: added inequality operator 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;
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;
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;
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;
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(
261 const dbus::ObjectPath& object_path) {
260 VLOG(1) << "GetObjectProxyForPath: " << object_path; 262 VLOG(1) << "GetObjectProxyForPath: " << object_path;
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
(...skipping 37 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;
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
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 << ": Device created: " << device_path;
335 337
336 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, 338 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_,
337 DeviceCreated(object_path, device_path)); 339 DeviceCreated(object_path, device_path));
338 } 340 }
339 341
340 // Called by dbus:: when the DeviceCreated signal is initially connected. 342 // Called by dbus:: when the DeviceCreated signal is initially connected.
341 void DeviceCreatedConnected(const std::string& object_path, 343 void DeviceCreatedConnected(const dbus::ObjectPath& object_path,
342 const std::string& interface_name, 344 const std::string& interface_name,
343 const std::string& signal_name, 345 const std::string& signal_name,
344 bool success) { 346 bool success) {
345 LOG_IF(WARNING, !success) << object_path 347 LOG_IF(WARNING, !success) << object_path
346 << ": Failed to connect to DeviceCreated signal."; 348 << ": Failed to connect to DeviceCreated signal.";
347 } 349 }
348 350
349 // Called by dbus:: when a DeviceRemoved signal is received. 351 // Called by dbus:: when a DeviceRemoved signal is received.
350 void DeviceRemovedReceived(const std::string& object_path, 352 void DeviceRemovedReceived(const dbus::ObjectPath& object_path,
351 dbus::Signal* signal) { 353 dbus::Signal* signal) {
352 DCHECK(signal); 354 DCHECK(signal);
353 dbus::MessageReader reader(signal); 355 dbus::MessageReader reader(signal);
354 std::string device_path; 356 dbus::ObjectPath device_path;
355 if (!reader.PopObjectPath(&device_path)) { 357 if (!reader.PopObjectPath(&device_path)) {
356 LOG(ERROR) << object_path 358 LOG(ERROR) << object_path
357 << ": DeviceRemoved signal has incorrect parameters: " 359 << ": DeviceRemoved signal has incorrect parameters: "
358 << signal->ToString(); 360 << signal->ToString();
359 return; 361 return;
360 } 362 }
361 VLOG(1) << object_path << ": Device removed: " << device_path; 363 VLOG(1) << object_path << ": Device removed: " << device_path;
362 364
363 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, 365 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_,
364 DeviceRemoved(object_path, device_path)); 366 DeviceRemoved(object_path, device_path));
365 } 367 }
366 368
367 // Called by dbus:: when the DeviceRemoved signal is initially connected. 369 // Called by dbus:: when the DeviceRemoved signal is initially connected.
368 void DeviceRemovedConnected(const std::string& object_path, 370 void DeviceRemovedConnected(const dbus::ObjectPath& object_path,
369 const std::string& interface_name, 371 const std::string& interface_name,
370 const std::string& signal_name, 372 const std::string& signal_name,
371 bool success) { 373 bool success) {
372 LOG_IF(WARNING, !success) << object_path 374 LOG_IF(WARNING, !success) << object_path
373 << ": Failed to connect to DeviceRemoved signal."; 375 << ": Failed to connect to DeviceRemoved signal.";
374 } 376 }
375 377
376 // Called by dbus:: when a PropertyChanged signal is received. 378 // Called by dbus:: when a PropertyChanged signal is received.
377 void PropertyChangedReceived(const std::string& object_path, 379 void PropertyChangedReceived(const dbus::ObjectPath& object_path,
378 dbus::Signal* signal) { 380 dbus::Signal* signal) {
379 DCHECK(signal); 381 DCHECK(signal);
380 dbus::MessageReader reader(signal); 382 dbus::MessageReader reader(signal);
381 std::string property_name; 383 std::string property_name;
382 if (!reader.PopString(&property_name)) { 384 if (!reader.PopString(&property_name)) {
383 LOG(ERROR) << object_path 385 LOG(ERROR) << object_path
384 << ": PropertyChanged signal has incorrect parameters: " 386 << ": PropertyChanged signal has incorrect parameters: "
385 << signal->ToString(); 387 << signal->ToString();
386 return; 388 return;
387 } 389 }
(...skipping 12 matching lines...) Expand all
400 return; 402 return;
401 } 403 }
402 VLOG(1) << object_path << ": PropertyChanged: Discovering = " 404 VLOG(1) << object_path << ": PropertyChanged: Discovering = "
403 << discovering; 405 << discovering;
404 406
405 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, 407 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_,
406 DiscoveringPropertyChanged(object_path, discovering)); 408 DiscoveringPropertyChanged(object_path, discovering));
407 } 409 }
408 410
409 // Called by dbus:: when the PropertyChanged signal is initially connected. 411 // Called by dbus:: when the PropertyChanged signal is initially connected.
410 void PropertyChangedConnected(const std::string& object_path, 412 void PropertyChangedConnected(const dbus::ObjectPath& object_path,
411 const std::string& interface_name, 413 const std::string& interface_name,
412 const std::string& signal_name, 414 const std::string& signal_name,
413 bool success) { 415 bool success) {
414 LOG_IF(WARNING, !success) << object_path 416 LOG_IF(WARNING, !success) << object_path
415 << ": Failed to connect to PropertyChanged signal."; 417 << ": Failed to connect to PropertyChanged signal.";
416 } 418 }
417 419
418 // Called by dbus:: when a DeviceFound signal is received. 420 // Called by dbus:: when a DeviceFound signal is received.
419 void DeviceFoundReceived(const std::string& object_path, 421 void DeviceFoundReceived(const dbus::ObjectPath& object_path,
420 dbus::Signal* signal) { 422 dbus::Signal* signal) {
421 DCHECK(signal); 423 DCHECK(signal);
422 dbus::MessageReader reader(signal); 424 dbus::MessageReader reader(signal);
423 std::string address; 425 std::string address;
424 if (!reader.PopString(&address)) { 426 if (!reader.PopString(&address)) {
425 LOG(ERROR) << object_path 427 LOG(ERROR) << object_path
426 << ": DeviceFound signal has incorrect parameters: " 428 << ": DeviceFound signal has incorrect parameters: "
427 << signal->ToString(); 429 << signal->ToString();
428 return; 430 return;
429 } 431 }
430 VLOG(1) << object_path << ": Device found: " << address; 432 VLOG(1) << object_path << ": Device found: " << address;
431 433
432 DictionaryValue device_properties; 434 DictionaryValue device_properties;
433 if (!PopArrayOfDictEntries(&reader, signal, &device_properties)) { 435 if (!PopArrayOfDictEntries(&reader, signal, &device_properties)) {
434 LOG(ERROR) << object_path 436 LOG(ERROR) << object_path
435 << ": DeviceFound signal has incorrect parameters: " 437 << ": DeviceFound signal has incorrect parameters: "
436 << signal->ToString(); 438 << signal->ToString();
437 return; 439 return;
438 } 440 }
439 441
440 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, 442 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_,
441 DeviceFound(object_path, address, device_properties)); 443 DeviceFound(object_path, address, device_properties));
442 } 444 }
443 445
444 // Called by dbus:: when the DeviceFound signal is initially connected. 446 // Called by dbus:: when the DeviceFound signal is initially connected.
445 void DeviceFoundConnected(const std::string& object_path, 447 void DeviceFoundConnected(const dbus::ObjectPath& object_path,
446 const std::string& interface_name, 448 const std::string& interface_name,
447 const std::string& signal_name, 449 const std::string& signal_name,
448 bool success) { 450 bool success) {
449 LOG_IF(WARNING, !success) << object_path 451 LOG_IF(WARNING, !success) << object_path
450 << ": Failed to connect to DeviceFound signal."; 452 << ": Failed to connect to DeviceFound signal.";
451 } 453 }
452 454
453 // Called by dbus:: when a DeviceDisappeared signal is received. 455 // Called by dbus:: when a DeviceDisappeared signal is received.
454 void DeviceDisappearedReceived(const std::string& object_path, 456 void DeviceDisappearedReceived(const dbus::ObjectPath& object_path,
455 dbus::Signal* signal) { 457 dbus::Signal* signal) {
456 DCHECK(signal); 458 DCHECK(signal);
457 dbus::MessageReader reader(signal); 459 dbus::MessageReader reader(signal);
458 std::string address; 460 std::string address;
459 if (!reader.PopString(&address)) { 461 if (!reader.PopString(&address)) {
460 LOG(ERROR) << object_path 462 LOG(ERROR) << object_path
461 << ": DeviceDisappeared signal has incorrect parameters: " 463 << ": DeviceDisappeared signal has incorrect parameters: "
462 << signal->ToString(); 464 << signal->ToString();
463 return; 465 return;
464 } 466 }
465 VLOG(1) << object_path << ": Device disappeared: " << address; 467 VLOG(1) << object_path << ": Device disappeared: " << address;
466 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, 468 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_,
467 DeviceDisappeared(object_path, address)); 469 DeviceDisappeared(object_path, address));
468 } 470 }
469 471
470 // Called by dbus:: when the DeviceDisappeared signal is initially connected. 472 // Called by dbus:: when the DeviceDisappeared signal is initially connected.
471 void DeviceDisappearedConnected(const std::string& object_path, 473 void DeviceDisappearedConnected(const dbus::ObjectPath& object_path,
472 const std::string& interface_name, 474 const std::string& interface_name,
473 const std::string& signal_name, 475 const std::string& signal_name,
474 bool success) { 476 bool success) {
475 LOG_IF(WARNING, !success) << object_path 477 LOG_IF(WARNING, !success) << object_path
476 << ": Failed to connect to DeviceDisappeared signal."; 478 << ": Failed to connect to DeviceDisappeared signal.";
477 } 479 }
478 480
479 // Called when a response for StartDiscovery() is received. 481 // Called when a response for StartDiscovery() is received.
480 void OnStartDiscovery(const std::string& object_path, 482 void OnStartDiscovery(const dbus::ObjectPath& object_path,
481 dbus::Response* response) { 483 dbus::Response* response) {
482 VLOG(1) << "OnStartDiscovery: " << object_path; 484 VLOG(1) << "OnStartDiscovery: " << object_path;
483 LOG_IF(WARNING, !response) << object_path << ": OnStartDiscovery: failed."; 485 LOG_IF(WARNING, !response) << object_path << ": OnStartDiscovery: failed.";
484 } 486 }
485 487
486 // Called when a response for StopDiscovery() is received. 488 // Called when a response for StopDiscovery() is received.
487 void OnStopDiscovery(const std::string& object_path, 489 void OnStopDiscovery(const dbus::ObjectPath& object_path,
488 dbus::Response* response) { 490 dbus::Response* response) {
489 VLOG(1) << "OnStopDiscovery: " << object_path; 491 VLOG(1) << "OnStopDiscovery: " << object_path;
490 LOG_IF(WARNING, !response) << object_path << ": OnStopDiscovery: failed."; 492 LOG_IF(WARNING, !response) << object_path << ": OnStopDiscovery: failed.";
491 } 493 }
492 494
493 // Weak pointer factory for generating 'this' pointers that might live longer 495 // Weak pointer factory for generating 'this' pointers that might live longer
494 // than we do. 496 // than we do.
495 base::WeakPtrFactory<BluetoothAdapterClientImpl> weak_ptr_factory_; 497 base::WeakPtrFactory<BluetoothAdapterClientImpl> weak_ptr_factory_;
496 498
497 dbus::Bus* bus_; 499 dbus::Bus* bus_;
498 500
499 // We maintain a collection of dbus object proxies, one for each adapter. 501 // We maintain a collection of dbus object proxies, one for each adapter.
500 typedef std::map<const std::string, dbus::ObjectProxy*> ProxyMap; 502 typedef std::map<const dbus::ObjectPath, dbus::ObjectProxy*> ProxyMap;
501 ProxyMap proxy_map_; 503 ProxyMap proxy_map_;
502 504
503 // List of observers interested in event notifications from us. 505 // List of observers interested in event notifications from us.
504 ObserverList<BluetoothAdapterClient::Observer> observers_; 506 ObserverList<BluetoothAdapterClient::Observer> observers_;
505 507
506 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterClientImpl); 508 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterClientImpl);
507 }; 509 };
508 510
509 // The BluetoothAdapterClient implementation used on Linux desktop, which does 511 // The BluetoothAdapterClient implementation used on Linux desktop, which does
510 // nothing. 512 // nothing.
511 class BluetoothAdapterClientStubImpl : public BluetoothAdapterClient { 513 class BluetoothAdapterClientStubImpl : public BluetoothAdapterClient {
512 public: 514 public:
513 // BluetoothAdapterClient override. 515 // BluetoothAdapterClient override.
514 virtual void AddObserver(Observer* observer) { 516 virtual void AddObserver(Observer* observer) {
515 VLOG(1) << "AddObserver"; 517 VLOG(1) << "AddObserver";
516 } 518 }
517 519
518 // BluetoothAdapterClient override. 520 // BluetoothAdapterClient override.
519 virtual void RemoveObserver(Observer* observer) { 521 virtual void RemoveObserver(Observer* observer) {
520 VLOG(1) << "RemoveObserver"; 522 VLOG(1) << "RemoveObserver";
521 } 523 }
522 524
523 // BluetoothAdapterClient override. 525 // BluetoothAdapterClient override.
524 virtual void StartDiscovery(const std::string& object_path) { 526 virtual void StartDiscovery(const dbus::ObjectPath& object_path) {
525 VLOG(1) << "StartDiscovery: " << object_path; 527 VLOG(1) << "StartDiscovery: " << object_path;
526 } 528 }
527 529
528 // BluetoothAdapterClient override. 530 // BluetoothAdapterClient override.
529 virtual void StopDiscovery(const std::string& object_path) { 531 virtual void StopDiscovery(const dbus::ObjectPath& object_path) {
530 VLOG(1) << "StopDiscovery: " << object_path; 532 VLOG(1) << "StopDiscovery: " << object_path;
531 } 533 }
532 }; 534 };
533 535
534 BluetoothAdapterClient::BluetoothAdapterClient() { 536 BluetoothAdapterClient::BluetoothAdapterClient() {
535 } 537 }
536 538
537 BluetoothAdapterClient::~BluetoothAdapterClient() { 539 BluetoothAdapterClient::~BluetoothAdapterClient() {
538 } 540 }
539 541
540 BluetoothAdapterClient* BluetoothAdapterClient::Create( 542 BluetoothAdapterClient* BluetoothAdapterClient::Create(
541 dbus::Bus* bus, 543 dbus::Bus* bus,
542 BluetoothManagerClient* manager_client) { 544 BluetoothManagerClient* manager_client) {
543 if (system::runtime_environment::IsRunningOnChromeOS()) { 545 if (system::runtime_environment::IsRunningOnChromeOS()) {
544 return new BluetoothAdapterClientImpl(bus, manager_client); 546 return new BluetoothAdapterClientImpl(bus, manager_client);
545 } else { 547 } else {
546 return new BluetoothAdapterClientStubImpl(); 548 return new BluetoothAdapterClientStubImpl();
547 } 549 }
548 } 550 }
549 551
550 } // namespace chromeos 552 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698