OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef DEVICE_BLUETOOTH_DEVICE_CONNECTION_HELPER_H_ | |
6 #define DEVICE_BLUETOOTH_DEVICE_CONNECTION_HELPER_H_ | |
7 | |
8 #include "device/bluetooth/public/interfaces/device.mojom.h" | |
9 #include "mojo/public/cpp/bindings/binding.h" | |
10 | |
11 namespace bluetooth { | |
12 | |
13 // Helper class to verify the order of destruction of callbacks and Mojo message | |
14 // pipe. DeviceConnectionHelper is owned by the callback, and DCHECKs when | |
15 // 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
| |
16 class DeviceConnectionHelper { | |
17 public: | |
18 DeviceConnectionHelper(mojo::Binding<mojom::Device>* binding); | |
dcheng
2016/11/11 01:25:33
Nit: explicit
mbrunson
2016/11/11 21:26:15
Done.
| |
19 ~DeviceConnectionHelper(); | |
20 | |
21 // Sets the callback ran flag. If callback ran flag is set to true, no check | |
22 // is performed when this instance is detroyed. | |
23 void SetCallbackRan(bool callback_ran); | |
24 | |
25 private: | |
26 // Flag that marks when a callback has been run. | |
27 bool callback_ran_; | |
28 | |
29 // Device binding that holds the message pipe that's checked on destruction. | |
30 mojo::Binding<mojom::Device>* binding_; | |
31 | |
32 DISALLOW_COPY_AND_ASSIGN(DeviceConnectionHelper); | |
33 }; | |
34 | |
35 } // namespace bluetooth | |
36 | |
37 #endif // DEVICE_BLUETOOTH_DEVICE_CONNECTION_HELPER_H_ | |
OLD | NEW |