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

Unified Diff: device/bluetooth/bluetooth_adapter.cc

Issue 1096183003: bluetooth: Refactor bluetooth_adapter.cc for C++ style: dcl/dfn ordering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-style-typedefs-
Patch Set: Created 5 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_adapter.cc
diff --git a/device/bluetooth/bluetooth_adapter.cc b/device/bluetooth/bluetooth_adapter.cc
index fd2e29b3edce0e4d810edc1d0c083d4b6e80078d..14679d62c5149fb19820fd9f9ff367e554a5b545 100644
--- a/device/bluetooth/bluetooth_adapter.cc
+++ b/device/bluetooth/bluetooth_adapter.cc
@@ -24,22 +24,20 @@ base::WeakPtr<BluetoothAdapter> BluetoothAdapter::CreateAdapter(
}
#endif // !defined(OS_CHROMEOS) && !defined(OS_WIN) && !defined(OS_MACOSX)
+base::WeakPtr<BluetoothAdapter> BluetoothAdapter::GetWeakPtrForTesting() {
+ return weak_ptr_factory_.GetWeakPtr();
+}
+
#if defined(OS_CHROMEOS)
void BluetoothAdapter::Shutdown() {
NOTIMPLEMENTED();
}
#endif
-BluetoothAdapter::BluetoothAdapter()
- : weak_ptr_factory_(this) {
-}
-
-BluetoothAdapter::~BluetoothAdapter() {
- STLDeleteValues(&devices_);
-}
-
-base::WeakPtr<BluetoothAdapter> BluetoothAdapter::GetWeakPtrForTesting() {
- return weak_ptr_factory_.GetWeakPtr();
+void BluetoothAdapter::StartDiscoverySession(
+ const DiscoverySessionCallback& callback,
+ const ErrorCallback& error_callback) {
+ StartDiscoverySessionWithFilter(nullptr, callback, error_callback);
}
void BluetoothAdapter::StartDiscoverySessionWithFilter(
@@ -53,50 +51,6 @@ void BluetoothAdapter::StartDiscoverySessionWithFilter(
error_callback);
}
-void BluetoothAdapter::StartDiscoverySession(
- const DiscoverySessionCallback& callback,
- const ErrorCallback& error_callback) {
- StartDiscoverySessionWithFilter(nullptr, callback, error_callback);
-}
-
-scoped_ptr<BluetoothDiscoveryFilter>
-BluetoothAdapter::GetMergedDiscoveryFilterHelper(
- const BluetoothDiscoveryFilter* masked_filter,
- bool omit) const {
- scoped_ptr<BluetoothDiscoveryFilter> result;
- bool first_merge = true;
-
- std::set<BluetoothDiscoverySession*> temp(discovery_sessions_);
- for (const auto& iter : temp) {
- const BluetoothDiscoveryFilter* curr_filter = iter->GetDiscoveryFilter();
-
- if (!iter->IsActive())
- continue;
-
- if (omit && curr_filter == masked_filter) {
- // if masked_filter is pointing to empty filter, and there are
- // multiple empty filters in discovery_sessions_, make sure we'll
- // process next empty sessions.
- omit = false;
- continue;
- }
-
- if (first_merge) {
- first_merge = false;
- if (curr_filter) {
- result.reset(new BluetoothDiscoveryFilter(
- BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL));
- result->CopyFrom(*curr_filter);
- }
- continue;
- }
-
- result = BluetoothDiscoveryFilter::Merge(result.get(), curr_filter);
- }
-
- return result.Pass();
-}
-
scoped_ptr<BluetoothDiscoveryFilter>
BluetoothAdapter::GetMergedDiscoveryFilter() const {
return GetMergedDiscoveryFilterHelper(nullptr, false);
@@ -183,6 +137,13 @@ BluetoothDevice::PairingDelegate* BluetoothAdapter::DefaultPairingDelegate() {
return pairing_delegates_.front().first;
}
+BluetoothAdapter::BluetoothAdapter() : weak_ptr_factory_(this) {
+}
+
+BluetoothAdapter::~BluetoothAdapter() {
+ STLDeleteValues(&devices_);
+}
+
void BluetoothAdapter::OnStartDiscoverySession(
scoped_ptr<BluetoothDiscoveryFilter> discovery_filter,
const DiscoverySessionCallback& callback) {
@@ -213,4 +174,42 @@ void BluetoothAdapter::DiscoverySessionBecameInactive(
discovery_sessions_.erase(discovery_session);
}
+scoped_ptr<BluetoothDiscoveryFilter>
+BluetoothAdapter::GetMergedDiscoveryFilterHelper(
+ const BluetoothDiscoveryFilter* masked_filter,
+ bool omit) const {
+ scoped_ptr<BluetoothDiscoveryFilter> result;
+ bool first_merge = true;
+
+ std::set<BluetoothDiscoverySession*> temp(discovery_sessions_);
+ for (const auto& iter : temp) {
+ const BluetoothDiscoveryFilter* curr_filter = iter->GetDiscoveryFilter();
+
+ if (!iter->IsActive())
+ continue;
+
+ if (omit && curr_filter == masked_filter) {
+ // if masked_filter is pointing to empty filter, and there are
+ // multiple empty filters in discovery_sessions_, make sure we'll
+ // process next empty sessions.
+ omit = false;
+ continue;
+ }
+
+ if (first_merge) {
+ first_merge = false;
+ if (curr_filter) {
+ result.reset(new BluetoothDiscoveryFilter(
+ BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL));
+ result->CopyFrom(*curr_filter);
+ }
+ continue;
+ }
+
+ result = BluetoothDiscoveryFilter::Merge(result.get(), curr_filter);
+ }
+
+ return result.Pass();
+}
+
} // namespace device
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698