Simple Cache: remove experiment code for flush intervals.
[chromium-blink-merge.git] / components / storage_monitor / transient_device_ids.h
blob53227a997e10421baeccb8cef6f4fbe816aeb409
1 // Copyright 2014 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.
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_
13 #include <map>
14 #include <string>
16 #include "base/basictypes.h"
17 #include "base/threading/thread_checker.h"
19 namespace storage_monitor {
21 class TransientDeviceIds {
22 public:
23 TransientDeviceIds();
24 ~TransientDeviceIds();
26 // Returns the transient ID for a given |device_id|.
27 // |device_id| must be for a fixed or removable storage device.
28 // If |device_id| has never been seen before, a new, unique transient id will
29 // be assigned.
30 std::string GetTransientIdForDeviceId(const std::string& device_id);
32 // Get the reverse mapping for a transient ID. Returns an empty string if the
33 // |transient_id| cannot be found.
34 std::string DeviceIdFromTransientId(const std::string& transient_id) const;
36 private:
37 typedef std::map<std::string, std::string> IdMap;
39 IdMap device_id_map_;
40 IdMap transient_id_map_;
42 base::ThreadChecker thread_checker_;
44 DISALLOW_COPY_AND_ASSIGN(TransientDeviceIds);
47 } // namespace storage_monitor
49 #endif // COMPONENTS_STORAGE_MONITOR_TRANSIENT_DEVICE_IDS_H_