[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / components / storage_monitor / transient_device_ids.h
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.
4
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.
9
10 #ifndef COMPONENTS_STORAGE_MONITOR_TRANSIENT_DEVICE_IDS_H_
11 #define COMPONENTS_STORAGE_MONITOR_TRANSIENT_DEVICE_IDS_H_
12
13 #include <map>
14 #include <string>
15
16 #include "base/threading/thread_checker.h"
17
18 namespace storage_monitor {
19
20 class TransientDeviceIds {
21  public:
22   TransientDeviceIds();
23
24   TransientDeviceIds(const TransientDeviceIds&) = delete;
25   TransientDeviceIds& operator=(const TransientDeviceIds&) = delete;
26
27   ~TransientDeviceIds();
28
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
32   // be assigned.
33   std::string GetTransientIdForDeviceId(const std::string& device_id);
34
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;
38
39  private:
40   typedef std::map<std::string, std::string> IdMap;
41
42   IdMap device_id_map_;
43   IdMap transient_id_map_;
44
45   base::ThreadChecker thread_checker_;
46 };
47
48 }  // namespace storage_monitor
49
50 #endif  // COMPONENTS_STORAGE_MONITOR_TRANSIENT_DEVICE_IDS_H_