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

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

Issue 10383198: Move helper functions into the anonymous namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 8 years, 7 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
« no previous file with comments | « chrome/browser/extensions/api/bluetooth/bluetooth_api.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
index fa41879f71f433555a3654f4078edeb3c348620e..8003d14243d90c968bb03e9cf8c39c361c4d6064 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
@@ -21,6 +21,21 @@
using chromeos::BluetoothAdapter;
using chromeos::BluetoothDevice;
+namespace {
+
+chromeos::ExtensionBluetoothEventRouter* GetEventRouter(Profile* profile) {
+ return profile->GetExtensionService()->bluetooth_event_router();
+}
+
+const chromeos::BluetoothAdapter* GetAdapter(Profile* profile) {
+ return GetEventRouter(profile)->adapter();
+}
+
+chromeos::BluetoothAdapter* GetMutableAdapter(Profile* profile) {
+ return GetEventRouter(profile)->GetMutableAdapter();
+}
+
+} // namespace
#endif
namespace GetDevicesWithServiceUUID =
@@ -35,50 +50,18 @@ namespace api {
#if defined(OS_CHROMEOS)
-chromeos::ExtensionBluetoothEventRouter*
-BluetoothExtensionFunction::event_router() {
- return profile()->GetExtensionService()->bluetooth_event_router();
-}
-
-const chromeos::BluetoothAdapter* BluetoothExtensionFunction::adapter() const {
- const chromeos::ExtensionBluetoothEventRouter* bluetooth_event_router =
- profile()->GetExtensionService()->bluetooth_event_router();
- return bluetooth_event_router->adapter();
-}
-
-chromeos::BluetoothAdapter* BluetoothExtensionFunction::GetMutableAdapter() {
- return event_router()->GetMutableAdapter();
-}
-
-chromeos::ExtensionBluetoothEventRouter*
-AsyncBluetoothExtensionFunction::event_router() {
- return profile()->GetExtensionService()->bluetooth_event_router();
-}
-
-const chromeos::BluetoothAdapter*
-AsyncBluetoothExtensionFunction::adapter() const {
- const chromeos::ExtensionBluetoothEventRouter* bluetooth_event_router =
- profile()->GetExtensionService()->bluetooth_event_router();
- return bluetooth_event_router->adapter();
-}
-
-chromeos::BluetoothAdapter*
-AsyncBluetoothExtensionFunction::GetMutableAdapter() {
- return event_router()->GetMutableAdapter();
-}
-
bool BluetoothIsAvailableFunction::RunImpl() {
- result_.reset(Value::CreateBooleanValue(adapter()->IsPresent()));
+ result_.reset(Value::CreateBooleanValue(GetAdapter(profile())->IsPresent()));
return true;
}
bool BluetoothIsPoweredFunction::RunImpl() {
- result_.reset(Value::CreateBooleanValue(adapter()->IsPowered()));
+ result_.reset(Value::CreateBooleanValue(GetAdapter(profile())->IsPowered()));
return true;
}
bool BluetoothGetAddressFunction::RunImpl() {
- result_.reset(Value::CreateStringValue(adapter()->address()));
+ result_.reset(Value::CreateStringValue(GetAdapter(profile())->address()));
return true;
}
@@ -86,7 +69,8 @@ bool BluetoothGetDevicesWithServiceUUIDFunction::RunImpl() {
scoped_ptr<GetDevicesWithServiceUUID::Params> params(
GetDevicesWithServiceUUID::Params::Create(*args_));
- const BluetoothAdapter::ConstDeviceList& devices = adapter()->GetDevices();
+ const BluetoothAdapter::ConstDeviceList& devices =
+ GetAdapter(profile())->GetDevices();
ListValue* matches = new ListValue;
for (BluetoothAdapter::ConstDeviceList::const_iterator i =
devices.begin(); i != devices.end(); ++i) {
@@ -132,7 +116,8 @@ bool BluetoothGetDevicesWithServiceNameFunction::RunImpl() {
ListValue* matches = new ListValue;
result_.reset(matches);
- BluetoothAdapter::DeviceList devices = GetMutableAdapter()->GetDevices();
+ BluetoothAdapter::DeviceList devices =
+ GetMutableAdapter(profile())->GetDevices();
callbacks_pending_ = 0;
for (BluetoothAdapter::DeviceList::iterator i = devices.begin();
i != devices.end(); ++i) {
@@ -157,7 +142,7 @@ void BluetoothConnectFunction::ConnectToServiceCallback(
const std::string& service_uuid,
scoped_refptr<chromeos::BluetoothSocket> socket) {
if (socket.get()) {
- int socket_id = event_router()->RegisterSocket(socket);
+ int socket_id = GetEventRouter(profile())->RegisterSocket(socket);
experimental_bluetooth::Socket result_socket;
result_socket.device.address = device->address();
@@ -177,7 +162,7 @@ bool BluetoothConnectFunction::RunImpl() {
scoped_ptr<Connect::Params> params(Connect::Params::Create(*args_));
chromeos::BluetoothDevice* device =
- GetMutableAdapter()->GetDevice(params->device.address);
+ GetMutableAdapter(profile())->GetDevice(params->device.address);
if (!device) {
SendResponse(false);
return false;
@@ -194,7 +179,7 @@ bool BluetoothConnectFunction::RunImpl() {
bool BluetoothDisconnectFunction::RunImpl() {
scoped_ptr<Disconnect::Params> params(Disconnect::Params::Create(*args_));
- return event_router()->ReleaseSocket(params->socket.id);
+ return GetEventRouter(profile())->ReleaseSocket(params->socket.id);
}
#else
« no previous file with comments | « chrome/browser/extensions/api/bluetooth/bluetooth_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698