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

Side by Side Diff: chrome/browser/chromeos/bluetooth/bluetooth_adapter.cc

Issue 10837294: Add bluetooth.getName API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 8 years, 4 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 (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/bluetooth/bluetooth_adapter.h" 5 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 210
211 object_path_ = adapter_path; 211 object_path_ = adapter_path;
212 212
213 // Update properties to their new values. 213 // Update properties to their new values.
214 BluetoothAdapterClient::Properties* properties = 214 BluetoothAdapterClient::Properties* properties =
215 DBusThreadManager::Get()->GetBluetoothAdapterClient()-> 215 DBusThreadManager::Get()->GetBluetoothAdapterClient()->
216 GetProperties(object_path_); 216 GetProperties(object_path_);
217 217
218 address_ = properties->address.value(); 218 address_ = properties->address.value();
219 name_ = properties->name.value();
219 220
220 PoweredChanged(properties->powered.value()); 221 PoweredChanged(properties->powered.value());
221 DiscoveringChanged(properties->discovering.value()); 222 DiscoveringChanged(properties->discovering.value());
222 DevicesChanged(properties->devices.value()); 223 DevicesChanged(properties->devices.value());
223 224
224 // Notify observers if we did not have an adapter before, the case of 225 // Notify observers if we did not have an adapter before, the case of
225 // moving from one to another is hidden from layers above. 226 // moving from one to another is hidden from layers above.
226 if (new_adapter) 227 if (new_adapter)
227 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 228 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
228 AdapterPresentChanged(this, true)); 229 AdapterPresentChanged(this, true));
229 } 230 }
230 231
231 void BluetoothAdapter::RemoveAdapter() { 232 void BluetoothAdapter::RemoveAdapter() {
232 DVLOG(1) << "Adapter lost."; 233 DVLOG(1) << "Adapter lost.";
233 PoweredChanged(false); 234 PoweredChanged(false);
234 DiscoveringChanged(false); 235 DiscoveringChanged(false);
235 ClearDevices(); 236 ClearDevices();
236 237
237 object_path_ = dbus::ObjectPath(""); 238 object_path_ = dbus::ObjectPath("");
238 address_.clear(); 239 address_.clear();
240 name_.clear();
239 241
240 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 242 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
241 AdapterPresentChanged(this, false)); 243 AdapterPresentChanged(this, false));
242 } 244 }
243 245
244 void BluetoothAdapter::OnSetPowered(const base::Closure& callback, 246 void BluetoothAdapter::OnSetPowered(const base::Closure& callback,
245 const ErrorCallback& error_callback, 247 const ErrorCallback& error_callback,
246 bool success) { 248 bool success) {
247 if (success) 249 if (success)
248 callback.Run(); 250 callback.Run();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 330
329 } else if (property_name == properties->discovering.name()) { 331 } else if (property_name == properties->discovering.name()) {
330 DiscoveringChanged(properties->discovering.value()); 332 DiscoveringChanged(properties->discovering.value());
331 333
332 } else if (property_name == properties->devices.name()) { 334 } else if (property_name == properties->devices.name()) {
333 DevicesChanged(properties->devices.value()); 335 DevicesChanged(properties->devices.value());
334 336
335 } else if (property_name == properties->address.name()) { 337 } else if (property_name == properties->address.name()) {
336 address_ = properties->address.value(); 338 address_ = properties->address.value();
337 339
340 } else if (property_name == properties->name.name()) {
341 name_ = properties->name.value();
342
338 } 343 }
339 } 344 }
340 345
341 void BluetoothAdapter::DevicePropertyChanged( 346 void BluetoothAdapter::DevicePropertyChanged(
342 const dbus::ObjectPath& device_path, 347 const dbus::ObjectPath& device_path,
343 const std::string& property_name) { 348 const std::string& property_name) {
344 UpdateDevice(device_path); 349 UpdateDevice(device_path);
345 } 350 }
346 351
347 void BluetoothAdapter::UpdateDevice(const dbus::ObjectPath& device_path) { 352 void BluetoothAdapter::UpdateDevice(const dbus::ObjectPath& device_path) {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 } 567 }
563 568
564 // static 569 // static
565 BluetoothAdapter* BluetoothAdapter::Create(const std::string& address) { 570 BluetoothAdapter* BluetoothAdapter::Create(const std::string& address) {
566 BluetoothAdapter* adapter = new BluetoothAdapter; 571 BluetoothAdapter* adapter = new BluetoothAdapter;
567 adapter->FindAdapter(address); 572 adapter->FindAdapter(address);
568 return adapter; 573 return adapter;
569 } 574 }
570 575
571 } // namespace chromeos 576 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/bluetooth/bluetooth_adapter.h ('k') | chrome/browser/chromeos/bluetooth/test/mock_bluetooth_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698