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

Unified Diff: device/bluetooth/test/device_connection_helper.h

Issue 2448713002: bluetooth: Add Device connection logic and accompanying user interface. (Closed)
Patch Set: Merge upstream, fix issues Created 4 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/test/device_connection_helper.h
diff --git a/device/bluetooth/test/device_connection_helper.h b/device/bluetooth/test/device_connection_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..a3c447890e61c23c4b9a3e1635ca4692d5476172
--- /dev/null
+++ b/device/bluetooth/test/device_connection_helper.h
@@ -0,0 +1,37 @@
+// Copyright 2016 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.
+
+#ifndef DEVICE_BLUETOOTH_DEVICE_CONNECTION_HELPER_H_
+#define DEVICE_BLUETOOTH_DEVICE_CONNECTION_HELPER_H_
+
+#include "device/bluetooth/public/interfaces/device.mojom.h"
+#include "mojo/public/cpp/bindings/binding.h"
+
+namespace bluetooth {
+
+// Helper class to verify the order of destruction of callbacks and Mojo message
+// pipe. DeviceConnectionHelper is owned by the callback, and DCHECKs when
+// the owning callback is destroyed before the message pipe is closed.
+class DeviceConnectionHelper {
+ public:
+ explicit DeviceConnectionHelper(mojo::Binding<mojom::Device>* binding);
+ ~DeviceConnectionHelper();
+
+ // Sets the callback ran flag. If callback ran flag is set to true, no check
+ // is performed when this instance is detroyed.
+ void SetCallbackRan(bool callback_ran);
+
+ private:
+ // Flag that marks when a callback has been run.
+ bool callback_ran_;
+
+ // Device binding that holds the message pipe that's checked on destruction.
+ mojo::Binding<mojom::Device>* binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(DeviceConnectionHelper);
+};
+
+} // namespace bluetooth
+
+#endif // DEVICE_BLUETOOTH_DEVICE_CONNECTION_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698