Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 1 | // 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 Chan | 7599f99 | 2011-12-13 16:04:34 -0800 | [diff] [blame] | 8 | #include <list> |
Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 9 | #include <string> |
| 10 | |
| 11 | namespace cros_disks { |
| 12 | |
| 13 | // A simple data structure for holding a device event. |
| 14 | struct DeviceEvent { |
| 15 | enum EventType { |
| 16 | kIgnored, |
| 17 | kDeviceAdded, |
| 18 | kDeviceScanned, |
| 19 | kDeviceRemoved, |
| 20 | kDiskAdded, |
Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 21 | kDiskChanged, |
| 22 | kDiskRemoved, |
| 23 | }; |
| 24 | |
Ben Chan | de0e3f6 | 2017-09-26 06:28:39 -0700 | [diff] [blame] | 25 | DeviceEvent() : event_type(kIgnored) {} |
Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 26 | |
| 27 | DeviceEvent(EventType type, const std::string& path) |
Ben Chan | de0e3f6 | 2017-09-26 06:28:39 -0700 | [diff] [blame] | 28 | : event_type(type), device_path(path) {} |
Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 29 | |
Ben Chan | 89cf29e | 2011-08-10 13:11:05 -0700 | [diff] [blame] | 30 | // NOTE: This operator== is needed due to the use of gmock matcher in |
| 31 | // DeviceEventModeratorTest. |
| 32 | bool operator==(const DeviceEvent& event) const; |
| 33 | |
Ben Chan | 7599f99 | 2011-12-13 16:04:34 -0800 | [diff] [blame] | 34 | // Returns true if the event type is DiskAdded, DiskChanged or DiskRemoved. |
Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 35 | bool IsDiskEvent() const; |
| 36 | |
| 37 | EventType event_type; |
| 38 | std::string device_path; |
| 39 | }; |
| 40 | |
Ben Chan | 478a704 | 2016-09-22 23:05:24 -0700 | [diff] [blame] | 41 | using DeviceEventList = std::list<DeviceEvent>; |
Ben Chan | 7599f99 | 2011-12-13 16:04:34 -0800 | [diff] [blame] | 42 | |
Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 43 | } // namespace cros_disks |
| 44 | |
| 45 | #endif // CROS_DISKS_DEVICE_EVENT_H_ |