blob: d2e8068df7781a64bda22eaaa72a7563eb41dc9c [file] [log] [blame]
Ben Chan6e726922011-06-28 15:54:32 -07001// Copyright (c) 2011 The Chromium OS 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 CROS_DISKS_DEVICE_EVENT_H_
6#define CROS_DISKS_DEVICE_EVENT_H_
7
Ben Chan7599f992011-12-13 16:04:34 -08008#include <list>
Ben Chan6e726922011-06-28 15:54:32 -07009#include <string>
10
11namespace cros_disks {
12
13// A simple data structure for holding a device event.
14struct DeviceEvent {
15 enum EventType {
16 kIgnored,
17 kDeviceAdded,
18 kDeviceScanned,
19 kDeviceRemoved,
20 kDiskAdded,
Ben Chan6e726922011-06-28 15:54:32 -070021 kDiskChanged,
22 kDiskRemoved,
23 };
24
Ben Chande0e3f62017-09-26 06:28:39 -070025 DeviceEvent() : event_type(kIgnored) {}
Ben Chan6e726922011-06-28 15:54:32 -070026
27 DeviceEvent(EventType type, const std::string& path)
Ben Chande0e3f62017-09-26 06:28:39 -070028 : event_type(type), device_path(path) {}
Ben Chan6e726922011-06-28 15:54:32 -070029
Ben Chan89cf29e2011-08-10 13:11:05 -070030 // NOTE: This operator== is needed due to the use of gmock matcher in
31 // DeviceEventModeratorTest.
32 bool operator==(const DeviceEvent& event) const;
33
Ben Chan7599f992011-12-13 16:04:34 -080034 // Returns true if the event type is DiskAdded, DiskChanged or DiskRemoved.
Ben Chan6e726922011-06-28 15:54:32 -070035 bool IsDiskEvent() const;
36
37 EventType event_type;
38 std::string device_path;
39};
40
Ben Chan478a7042016-09-22 23:05:24 -070041using DeviceEventList = std::list<DeviceEvent>;
Ben Chan7599f992011-12-13 16:04:34 -080042
Ben Chan6e726922011-06-28 15:54:32 -070043} // namespace cros_disks
44
45#endif // CROS_DISKS_DEVICE_EVENT_H_