1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // TransientDeviceIds keep track of transient IDs for removable devices, so
6 // persistent device IDs are not exposed to renderers. Once a removable device
7 // gets mapped to a transient ID, the mapping remains valid for the duration of
8 // TransientDeviceIds' lifetime.
10 #ifndef COMPONENTS_STORAGE_MONITOR_TRANSIENT_DEVICE_IDS_H_
11 #define COMPONENTS_STORAGE_MONITOR_TRANSIENT_DEVICE_IDS_H_
16 #include "base/threading/thread_checker.h"
18 namespace storage_monitor {
20 class TransientDeviceIds {
24 TransientDeviceIds(const TransientDeviceIds&) = delete;
25 TransientDeviceIds& operator=(const TransientDeviceIds&) = delete;
27 ~TransientDeviceIds();
29 // Returns the transient ID for a given |device_id|.
30 // |device_id| must be for a fixed or removable storage device.
31 // If |device_id| has never been seen before, a new, unique transient id will
33 std::string GetTransientIdForDeviceId(const std::string& device_id);
35 // Get the reverse mapping for a transient ID. Returns an empty string if the
36 // |transient_id| cannot be found.
37 std::string DeviceIdFromTransientId(const std::string& transient_id) const;
40 typedef std::map<std::string, std::string> IdMap;
43 IdMap transient_id_map_;
45 base::ThreadChecker thread_checker_;
48 } // namespace storage_monitor
50 #endif // COMPONENTS_STORAGE_MONITOR_TRANSIENT_DEVICE_IDS_H_