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

Unified Diff: chrome/browser/extensions/api/bluetooth/bluetooth_api.cc

Issue 10916331: Revert 156348 (caused http://crbug.com/149828) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
===================================================================
--- chrome/browser/extensions/api/bluetooth/bluetooth_api.cc (revision 157029)
+++ chrome/browser/extensions/api/bluetooth/bluetooth_api.cc (working copy)
@@ -11,7 +11,6 @@
#include <string>
#include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h"
-#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/experimental_bluetooth.h"
@@ -100,23 +99,14 @@
BluetoothGetDevicesFunction::BluetoothGetDevicesFunction()
: callbacks_pending_(0) {}
-void BluetoothGetDevicesFunction::DispatchDeviceSearchResult(
- const chromeos::BluetoothDevice& device) {
- experimental_bluetooth::Device extension_device;
- experimental_bluetooth::BluetoothDeviceToApiDevice(device, &extension_device);
- GetEventRouter(profile())->DispatchDeviceEvent(
- extensions::event_names::kBluetoothOnDeviceSearchResult,
- extension_device);
-}
-
-void BluetoothGetDevicesFunction::ProvidesServiceCallback(
+void BluetoothGetDevicesFunction::AddDeviceIfTrueCallback(
+ ListValue* list,
const chromeos::BluetoothDevice* device,
- bool providesService) {
+ bool shouldAdd) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- CHECK(device);
- if (providesService)
- DispatchDeviceSearchResult(*device);
+ if (shouldAdd)
+ list->Append(experimental_bluetooth::BluetoothDeviceToValue(*device));
callbacks_pending_--;
if (callbacks_pending_ == -1)
@@ -139,6 +129,9 @@
}
}
+ ListValue* matches = new ListValue;
+ SetResult(matches);
+
CHECK_EQ(0, callbacks_pending_);
chromeos::BluetoothAdapter::DeviceList devices =
@@ -146,21 +139,21 @@
for (chromeos::BluetoothAdapter::DeviceList::iterator i = devices.begin();
i != devices.end(); ++i) {
chromeos::BluetoothDevice* device = *i;
- CHECK(device);
if (!uuid.empty() && !(device->ProvidesServiceWithUUID(uuid)))
continue;
if (options.name.get() == NULL) {
- DispatchDeviceSearchResult(*device);
+ matches->Append(experimental_bluetooth::BluetoothDeviceToValue(*device));
continue;
}
callbacks_pending_++;
device->ProvidesServiceWithName(
*(options.name),
- base::Bind(&BluetoothGetDevicesFunction::ProvidesServiceCallback,
+ base::Bind(&BluetoothGetDevicesFunction::AddDeviceIfTrueCallback,
this,
+ matches,
device));
}
callbacks_pending_--;

Powered by Google App Engine
This is Rietveld 408576698