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

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

Issue 2448713002: bluetooth: Add Device connection logic and accompanying user interface. (Closed)
Patch Set: Fix comments, add ConnectionStatus enum, other fixes 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..7b02b6814d9581cce2ecb7ed12ab0826f77bb114
--- /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.
dcheng 2016/11/11 01:25:33 The test code is pretty complex, and part of that
mbrunson 2016/11/11 21:26:15 It's mainly to test whether the callbacks for a De
+class DeviceConnectionHelper {
+ public:
+ DeviceConnectionHelper(mojo::Binding<mojom::Device>* binding);
dcheng 2016/11/11 01:25:33 Nit: explicit
mbrunson 2016/11/11 21:26:15 Done.
+ ~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