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

Unified Diff: device/bluetooth/bluetooth_gatt_notify_session_chromeos.cc

Issue 1415573014: Reland "Add Linux support for the Bluetooth API" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build fix. Created 5 years, 1 month 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: device/bluetooth/bluetooth_gatt_notify_session_chromeos.cc
diff --git a/device/bluetooth/bluetooth_gatt_notify_session_chromeos.cc b/device/bluetooth/bluetooth_gatt_notify_session_chromeos.cc
deleted file mode 100644
index 02f7ed8bbbe37f09af1694dc505fb6c0fc0a0bb3..0000000000000000000000000000000000000000
--- a/device/bluetooth/bluetooth_gatt_notify_session_chromeos.cc
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "device/bluetooth/bluetooth_gatt_notify_session_chromeos.h"
-
-#include "base/bind.h"
-#include "base/logging.h"
-#include "device/bluetooth/bluetooth_adapter.h"
-#include "device/bluetooth/bluetooth_device.h"
-#include "device/bluetooth/bluetooth_gatt_service.h"
-#include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h"
-#include "device/bluetooth/dbus/bluez_dbus_manager.h"
-
-namespace chromeos {
-
-BluetoothGattNotifySessionChromeOS::BluetoothGattNotifySessionChromeOS(
- scoped_refptr<device::BluetoothAdapter> adapter,
- const std::string& device_address,
- const std::string& service_identifier,
- const std::string& characteristic_identifier,
- const dbus::ObjectPath& characteristic_path)
- : active_(true),
- adapter_(adapter),
- device_address_(device_address),
- service_id_(service_identifier),
- characteristic_id_(characteristic_identifier),
- object_path_(characteristic_path) {
- DCHECK(adapter_.get());
- DCHECK(!device_address_.empty());
- DCHECK(!service_id_.empty());
- DCHECK(!characteristic_id_.empty());
- DCHECK(object_path_.IsValid());
-
- bluez::BluezDBusManager::Get()
- ->GetBluetoothGattCharacteristicClient()
- ->AddObserver(this);
-}
-
-BluetoothGattNotifySessionChromeOS::~BluetoothGattNotifySessionChromeOS() {
- bluez::BluezDBusManager::Get()
- ->GetBluetoothGattCharacteristicClient()
- ->RemoveObserver(this);
- Stop(base::Bind(&base::DoNothing));
-}
-
-std::string BluetoothGattNotifySessionChromeOS::GetCharacteristicIdentifier()
- const {
- return characteristic_id_;
-}
-
-bool BluetoothGattNotifySessionChromeOS::IsActive() {
- // Determine if the session is active. If |active_| is false, then it's
- // been explicitly marked, so return false.
- if (!active_)
- return false;
-
- // The fact that |active_| is true doesn't mean that the session is
- // actually active, since the characteristic might have stopped sending
- // notifications yet this method was called before we processed the
- // observer event (e.g. because somebody else called this method in their
- // bluez::BluetoothGattCharacteristicClient::Observer implementation, which
- // was
- // called before ours). Check the client to see if notifications are still
- // being sent.
- bluez::BluetoothGattCharacteristicClient::Properties* properties =
- bluez::BluezDBusManager::Get()
- ->GetBluetoothGattCharacteristicClient()
- ->GetProperties(object_path_);
- if (!properties || !properties->notifying.value())
- active_ = false;
-
- return active_;
-}
-
-void BluetoothGattNotifySessionChromeOS::Stop(const base::Closure& callback) {
- if (!active_) {
- VLOG(1) << "Notify session already inactive.";
- callback.Run();
- return;
- }
-
- // Mark this session as inactive no matter what.
- active_ = false;
-
- device::BluetoothDevice* device = adapter_->GetDevice(device_address_);
- if (!device)
- return;
-
- device::BluetoothGattService* service = device->GetGattService(service_id_);
- if (!service)
- return;
-
- BluetoothRemoteGattCharacteristicChromeOS* chrc =
- static_cast<BluetoothRemoteGattCharacteristicChromeOS*>(
- service->GetCharacteristic(characteristic_id_));
- if (!chrc)
- return;
-
- chrc->RemoveNotifySession(callback);
-}
-
-void BluetoothGattNotifySessionChromeOS::GattCharacteristicRemoved(
- const dbus::ObjectPath& object_path) {
- if (object_path != object_path_)
- return;
-
- active_ = false;
-}
-
-void BluetoothGattNotifySessionChromeOS::GattCharacteristicPropertyChanged(
- const dbus::ObjectPath& object_path,
- const std::string& property_name) {
- if (object_path != object_path_)
- return;
-
- if (!active_)
- return;
-
- bluez::BluetoothGattCharacteristicClient::Properties* properties =
- bluez::BluezDBusManager::Get()
- ->GetBluetoothGattCharacteristicClient()
- ->GetProperties(object_path_);
- if (!properties) {
- active_ = false;
- return;
- }
-
- if (property_name == properties->notifying.name() &&
- !properties->notifying.value())
- active_ = false;
-}
-
-} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698