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

Side by Side Diff: device/bluetooth/bluetooth_adapter_chromeos.cc

Issue 12379062: Remove Debug restriction on Bluetooth log messages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again (base files missing?) Created 7 years, 9 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
« no previous file with comments | « chromeos/dbus/introspectable_client.cc ('k') | device/bluetooth/bluetooth_device_chromeos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "device/bluetooth/bluetooth_adapter_chromeos.h" 5 #include "device/bluetooth/bluetooth_adapter_chromeos.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 const ErrorCallback& error_callback) { 127 const ErrorCallback& error_callback) {
128 DBusThreadManager::Get()->GetBluetoothOutOfBandClient()-> 128 DBusThreadManager::Get()->GetBluetoothOutOfBandClient()->
129 ReadLocalData(object_path_, 129 ReadLocalData(object_path_,
130 base::Bind(&BluetoothAdapterChromeOS::OnReadLocalData, 130 base::Bind(&BluetoothAdapterChromeOS::OnReadLocalData,
131 weak_ptr_factory_.GetWeakPtr(), 131 weak_ptr_factory_.GetWeakPtr(),
132 callback, 132 callback,
133 error_callback)); 133 error_callback));
134 } 134 }
135 135
136 void BluetoothAdapterChromeOS::TrackDefaultAdapter() { 136 void BluetoothAdapterChromeOS::TrackDefaultAdapter() {
137 DVLOG(1) << "Tracking default adapter"; 137 VLOG(1) << "Tracking default adapter";
138 track_default_ = true; 138 track_default_ = true;
139 DBusThreadManager::Get()->GetBluetoothManagerClient()-> 139 DBusThreadManager::Get()->GetBluetoothManagerClient()->
140 DefaultAdapter(base::Bind(&BluetoothAdapterChromeOS::AdapterCallback, 140 DefaultAdapter(base::Bind(&BluetoothAdapterChromeOS::AdapterCallback,
141 weak_ptr_factory_.GetWeakPtr())); 141 weak_ptr_factory_.GetWeakPtr()));
142 } 142 }
143 143
144 void BluetoothAdapterChromeOS::FindAdapter(const std::string& address) { 144 void BluetoothAdapterChromeOS::FindAdapter(const std::string& address) {
145 DVLOG(1) << "Using adapter " << address; 145 VLOG(1) << "Using adapter " << address;
146 track_default_ = false; 146 track_default_ = false;
147 DBusThreadManager::Get()->GetBluetoothManagerClient()-> 147 DBusThreadManager::Get()->GetBluetoothManagerClient()->
148 FindAdapter(address, 148 FindAdapter(address,
149 base::Bind(&BluetoothAdapterChromeOS::AdapterCallback, 149 base::Bind(&BluetoothAdapterChromeOS::AdapterCallback,
150 weak_ptr_factory_.GetWeakPtr())); 150 weak_ptr_factory_.GetWeakPtr()));
151 } 151 }
152 152
153 void BluetoothAdapterChromeOS::AdapterCallback( 153 void BluetoothAdapterChromeOS::AdapterCallback(
154 const dbus::ObjectPath& adapter_path, 154 const dbus::ObjectPath& adapter_path,
155 bool success) { 155 bool success) {
(...skipping 12 matching lines...) Expand all
168 168
169 void BluetoothAdapterChromeOS::AdapterRemoved( 169 void BluetoothAdapterChromeOS::AdapterRemoved(
170 const dbus::ObjectPath& adapter_path) { 170 const dbus::ObjectPath& adapter_path) {
171 if (adapter_path == object_path_) 171 if (adapter_path == object_path_)
172 RemoveAdapter(); 172 RemoveAdapter();
173 } 173 }
174 174
175 void BluetoothAdapterChromeOS::ChangeAdapter( 175 void BluetoothAdapterChromeOS::ChangeAdapter(
176 const dbus::ObjectPath& adapter_path) { 176 const dbus::ObjectPath& adapter_path) {
177 if (object_path_.value().empty()) { 177 if (object_path_.value().empty()) {
178 DVLOG(1) << "Adapter path initialized to " << adapter_path.value(); 178 VLOG(1) << "Adapter path initialized to " << adapter_path.value();
179 } else if (object_path_.value() != adapter_path.value()) { 179 } else if (object_path_.value() != adapter_path.value()) {
180 DVLOG(1) << "Adapter path changed from " << object_path_.value() 180 VLOG(1) << "Adapter path changed from " << object_path_.value()
181 << " to " << adapter_path.value(); 181 << " to " << adapter_path.value();
182 182
183 RemoveAdapter(); 183 RemoveAdapter();
184 } else { 184 } else {
185 DVLOG(1) << "Adapter address updated"; 185 VLOG(1) << "Adapter address updated";
186 } 186 }
187 187
188 object_path_ = adapter_path; 188 object_path_ = adapter_path;
189 189
190 // Update properties to their new values. 190 // Update properties to their new values.
191 BluetoothAdapterClient::Properties* properties = 191 BluetoothAdapterClient::Properties* properties =
192 DBusThreadManager::Get()->GetBluetoothAdapterClient()-> 192 DBusThreadManager::Get()->GetBluetoothAdapterClient()->
193 GetProperties(object_path_); 193 GetProperties(object_path_);
194 194
195 address_ = properties->address.value(); 195 address_ = properties->address.value();
196 name_ = properties->name.value(); 196 name_ = properties->name.value();
197 197
198 // Delay announcing a new adapter until we have an address. 198 // Delay announcing a new adapter until we have an address.
199 if (address_.empty()) { 199 if (address_.empty()) {
200 DVLOG(1) << "Adapter address not yet known"; 200 VLOG(1) << "Adapter address not yet known";
201 return; 201 return;
202 } 202 }
203 203
204 PoweredChanged(properties->powered.value()); 204 PoweredChanged(properties->powered.value());
205 DiscoveringChanged(properties->discovering.value()); 205 DiscoveringChanged(properties->discovering.value());
206 DevicesChanged(properties->devices.value()); 206 DevicesChanged(properties->devices.value());
207 207
208 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 208 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
209 AdapterPresentChanged(this, true)); 209 AdapterPresentChanged(this, true));
210 } 210 }
211 211
212 void BluetoothAdapterChromeOS::RemoveAdapter() { 212 void BluetoothAdapterChromeOS::RemoveAdapter() {
213 const bool adapter_was_present = IsPresent(); 213 const bool adapter_was_present = IsPresent();
214 214
215 DVLOG(1) << "Adapter lost."; 215 VLOG(1) << "Adapter lost.";
216 PoweredChanged(false); 216 PoweredChanged(false);
217 DiscoveringChanged(false); 217 DiscoveringChanged(false);
218 ClearDevices(); 218 ClearDevices();
219 219
220 object_path_ = dbus::ObjectPath(""); 220 object_path_ = dbus::ObjectPath("");
221 address_.clear(); 221 address_.clear();
222 name_.clear(); 222 name_.clear();
223 223
224 if (adapter_was_present) 224 if (adapter_was_present)
225 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 225 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
(...skipping 19 matching lines...) Expand all
245 AdapterPoweredChanged(this, powered_)); 245 AdapterPoweredChanged(this, powered_));
246 } 246 }
247 247
248 void BluetoothAdapterChromeOS::OnStartDiscovery( 248 void BluetoothAdapterChromeOS::OnStartDiscovery(
249 const base::Closure& callback, 249 const base::Closure& callback,
250 const ErrorCallback& error_callback, 250 const ErrorCallback& error_callback,
251 const dbus::ObjectPath& adapter_path, 251 const dbus::ObjectPath& adapter_path,
252 bool success) { 252 bool success) {
253 if (success) { 253 if (success) {
254 if (discovering_count_++ == 0) { 254 if (discovering_count_++ == 0) {
255 DVLOG(1) << object_path_.value() << ": started discovery."; 255 VLOG(1) << object_path_.value() << ": started discovery.";
256 256
257 // Clear devices found in previous discovery attempts 257 // Clear devices found in previous discovery attempts
258 ClearDiscoveredDevices(); 258 ClearDiscoveredDevices();
259 259
260 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 260 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
261 AdapterDiscoveringChanged(this, true)); 261 AdapterDiscoveringChanged(this, true));
262 } 262 }
263 263
264 callback.Run(); 264 callback.Run();
265 } else { 265 } else {
266 error_callback.Run(); 266 error_callback.Run();
267 } 267 }
268 } 268 }
269 269
270 void BluetoothAdapterChromeOS::OnStopDiscovery( 270 void BluetoothAdapterChromeOS::OnStopDiscovery(
271 const base::Closure& callback, 271 const base::Closure& callback,
272 const ErrorCallback& error_callback, 272 const ErrorCallback& error_callback,
273 const dbus::ObjectPath& adapter_path, 273 const dbus::ObjectPath& adapter_path,
274 bool success) { 274 bool success) {
275 if (success) { 275 if (success) {
276 if (--discovering_count_ == 0) { 276 if (--discovering_count_ == 0) {
277 DVLOG(1) << object_path_.value() << ": stopped discovery."; 277 VLOG(1) << object_path_.value() << ": stopped discovery.";
278 278
279 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 279 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
280 AdapterDiscoveringChanged(this, false)); 280 AdapterDiscoveringChanged(this, false));
281 } else if (discovering_count_ < 0) { 281 } else if (discovering_count_ < 0) {
282 LOG(WARNING) << adapter_path.value() << ": call to StopDiscovering " 282 LOG(WARNING) << adapter_path.value() << ": call to StopDiscovering "
283 << "without matching StartDiscovering."; 283 << "without matching StartDiscovering.";
284 error_callback.Run(); 284 error_callback.Run();
285 return; 285 return;
286 } 286 }
287 287
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 const bool update_device = (iter != devices_.end()); 373 const bool update_device = (iter != devices_.end());
374 if (update_device) { 374 if (update_device) {
375 device = static_cast<BluetoothDeviceChromeOS*>(iter->second); 375 device = static_cast<BluetoothDeviceChromeOS*>(iter->second);
376 } else { 376 } else {
377 device = BluetoothDeviceChromeOS::Create(this); 377 device = BluetoothDeviceChromeOS::Create(this);
378 devices_[address] = device; 378 devices_[address] = device;
379 } 379 }
380 380
381 const bool was_paired = device->IsPaired(); 381 const bool was_paired = device->IsPaired();
382 if (!was_paired) { 382 if (!was_paired) {
383 DVLOG(1) << "Assigned object path " << device_path.value() << " to device " 383 VLOG(1) << "Assigned object path " << device_path.value() << " to device "
384 << address; 384 << address;
385 device->SetObjectPath(device_path); 385 device->SetObjectPath(device_path);
386 } 386 }
387 device->Update(properties, true); 387 device->Update(properties, true);
388 388
389 if (update_device) { 389 if (update_device) {
390 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 390 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
391 DeviceChanged(this, device)); 391 DeviceChanged(this, device));
392 } else { 392 } else {
393 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 393 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
394 DeviceAdded(this, device)); 394 DeviceAdded(this, device));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 if (device->object_path_ != device_path) 433 if (device->object_path_ != device_path)
434 continue; 434 continue;
435 435
436 // DeviceRemoved can also be called to indicate a device that is visible 436 // DeviceRemoved can also be called to indicate a device that is visible
437 // during discovery has disconnected, but it is still visible to the 437 // during discovery has disconnected, but it is still visible to the
438 // adapter, so don't remove in that case and only clear the object path. 438 // adapter, so don't remove in that case and only clear the object path.
439 if (!device->IsVisible()) { 439 if (!device->IsVisible()) {
440 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 440 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
441 DeviceRemoved(this, device)); 441 DeviceRemoved(this, device));
442 442
443 DVLOG(1) << "Removed device " << device->address(); 443 VLOG(1) << "Removed device " << device->address();
444 444
445 delete device; 445 delete device;
446 devices_.erase(temp); 446 devices_.erase(temp);
447 } else { 447 } else {
448 DVLOG(1) << "Removed object path from device " << device->address(); 448 VLOG(1) << "Removed object path from device " << device->address();
449 device->RemoveObjectPath(); 449 device->RemoveObjectPath();
450 450
451 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 451 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
452 DeviceChanged(this, device)); 452 DeviceChanged(this, device));
453 } 453 }
454 } 454 }
455 } 455 }
456 456
457 void BluetoothAdapterChromeOS::DevicesChanged( 457 void BluetoothAdapterChromeOS::DevicesChanged(
458 const std::vector<dbus::ObjectPath>& devices) { 458 const std::vector<dbus::ObjectPath>& devices) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 BluetoothDeviceChromeOS* device; 491 BluetoothDeviceChromeOS* device;
492 DevicesMap::iterator iter = devices_.find(address); 492 DevicesMap::iterator iter = devices_.find(address);
493 const bool update_device = (iter != devices_.end()); 493 const bool update_device = (iter != devices_.end());
494 if (update_device) { 494 if (update_device) {
495 device = static_cast<BluetoothDeviceChromeOS*>(iter->second); 495 device = static_cast<BluetoothDeviceChromeOS*>(iter->second);
496 } else { 496 } else {
497 device = BluetoothDeviceChromeOS::Create(this); 497 device = BluetoothDeviceChromeOS::Create(this);
498 devices_[address] = device; 498 devices_[address] = device;
499 } 499 }
500 500
501 DVLOG(1) << "Device " << address << " is visible to the adapter"; 501 VLOG(1) << "Device " << address << " is visible to the adapter";
502 device->SetVisible(true); 502 device->SetVisible(true);
503 device->Update(&properties, false); 503 device->Update(&properties, false);
504 504
505 if (update_device) { 505 if (update_device) {
506 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 506 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
507 DeviceChanged(this, device)); 507 DeviceChanged(this, device));
508 } else { 508 } else {
509 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 509 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
510 DeviceAdded(this, device)); 510 DeviceAdded(this, device));
511 } 511 }
(...skipping 12 matching lines...) Expand all
524 BluetoothDeviceChromeOS* device = 524 BluetoothDeviceChromeOS* device =
525 static_cast<BluetoothDeviceChromeOS*>(iter->second); 525 static_cast<BluetoothDeviceChromeOS*>(iter->second);
526 526
527 // DeviceDisappeared can also be called to indicate that a device we've 527 // DeviceDisappeared can also be called to indicate that a device we've
528 // paired with is no longer visible to the adapter, so don't remove 528 // paired with is no longer visible to the adapter, so don't remove
529 // in that case and only clear the visible flag. 529 // in that case and only clear the visible flag.
530 if (!device->IsPaired()) { 530 if (!device->IsPaired()) {
531 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 531 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
532 DeviceRemoved(this, device)); 532 DeviceRemoved(this, device));
533 533
534 DVLOG(1) << "Discovered device " << device->address() 534 VLOG(1) << "Discovered device " << device->address()
535 << " is no longer visible to the adapter"; 535 << " is no longer visible to the adapter";
536 536
537 delete device; 537 delete device;
538 devices_.erase(iter); 538 devices_.erase(iter);
539 } else { 539 } else {
540 DVLOG(1) << "Paired device " << device->address() 540 VLOG(1) << "Paired device " << device->address()
541 << " is no longer visible to the adapter"; 541 << " is no longer visible to the adapter";
542 device->SetVisible(false); 542 device->SetVisible(false);
543 543
544 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 544 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
545 DeviceChanged(this, device)); 545 DeviceChanged(this, device));
546 } 546 }
547 } 547 }
548 548
549 } // namespace chromeos 549 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/introspectable_client.cc ('k') | device/bluetooth/bluetooth_device_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698