Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / storage_monitor / transient_device_ids.h
bloba0c9a82b2e078c5bf545d2e28915ec0063e85b14
1 // Copyright (c) 2012 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 CHROME_BROWSER_STORAGE_MONITOR_TRANSIENT_DEVICE_IDS_H_
11 #define CHROME_BROWSER_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 class TransientDeviceIds {
20 public:
21 TransientDeviceIds();
22 ~TransientDeviceIds();
24 // Returns the transient ID for a given |device_id|.
25 // |device_id| must be for a fixed or removable storage device.
26 // If |device_id| has never been seen before, a new, unique transient id will
27 // be assigned.
28 std::string GetTransientIdForDeviceId(const std::string& device_id);
30 // Get the reverse mapping for a transient ID. Returns an empty string if the
31 // |transient_id| cannot be found.
32 std::string DeviceIdFromTransientId(const std::string& transient_id) const;
34 private:
35 typedef std::map<std::string, std::string> IdMap;
37 IdMap device_id_map_;
38 IdMap transient_id_map_;
40 base::ThreadChecker thread_checker_;
42 DISALLOW_COPY_AND_ASSIGN(TransientDeviceIds);
45 #endif // CHROME_BROWSER_STORAGE_MONITOR_TRANSIENT_DEVICE_IDS_H_