| 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.
|
| +class DeviceConnectionHelper {
|
| + public:
|
| + 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_
|
|
|