Renamed NQP to EEPAndroid
[chromium-blink-merge.git] / components / storage_monitor / transient_device_ids.cc
blob3f1930224aa13f41d04ffe7b180e658b42a72402
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 implementation.
7 #include "components/storage_monitor/transient_device_ids.h"
9 #include "base/guid.h"
10 #include "base/logging.h"
11 #include "base/stl_util.h"
12 #include "components/storage_monitor/storage_info.h"
14 namespace storage_monitor {
16 TransientDeviceIds::TransientDeviceIds() {}
18 TransientDeviceIds::~TransientDeviceIds() {}
20 std::string TransientDeviceIds::GetTransientIdForDeviceId(
21 const std::string& device_id) {
22 DCHECK(thread_checker_.CalledOnValidThread());
24 if (!ContainsKey(device_id_map_, device_id)) {
25 std::string transient_id;
26 do {
27 transient_id = base::GenerateGUID();
28 } while (ContainsKey(transient_id_map_, transient_id));
30 device_id_map_[device_id] = transient_id;
31 transient_id_map_[transient_id] = device_id;
34 return device_id_map_[device_id];
37 std::string TransientDeviceIds::DeviceIdFromTransientId(
38 const std::string& transient_id) const {
39 IdMap::const_iterator it = transient_id_map_.find(transient_id);
40 if (it == transient_id_map_.end())
41 return std::string();
42 return it->second;
45 } // namespace storage_monitor