Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Side by Side Diff: components/storage_monitor/transient_device_ids.cc

Issue 2231753002: components: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more call site Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // TransientDeviceIds implementation. 5 // TransientDeviceIds implementation.
6 6
7 #include "components/storage_monitor/transient_device_ids.h" 7 #include "components/storage_monitor/transient_device_ids.h"
8 8
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "components/storage_monitor/storage_info.h" 12 #include "components/storage_monitor/storage_info.h"
13 13
14 namespace storage_monitor { 14 namespace storage_monitor {
15 15
16 TransientDeviceIds::TransientDeviceIds() {} 16 TransientDeviceIds::TransientDeviceIds() {}
17 17
18 TransientDeviceIds::~TransientDeviceIds() {} 18 TransientDeviceIds::~TransientDeviceIds() {}
19 19
20 std::string TransientDeviceIds::GetTransientIdForDeviceId( 20 std::string TransientDeviceIds::GetTransientIdForDeviceId(
21 const std::string& device_id) { 21 const std::string& device_id) {
22 DCHECK(thread_checker_.CalledOnValidThread()); 22 DCHECK(thread_checker_.CalledOnValidThread());
23 23
24 if (!ContainsKey(device_id_map_, device_id)) { 24 if (!base::ContainsKey(device_id_map_, device_id)) {
25 std::string transient_id; 25 std::string transient_id;
26 do { 26 do {
27 transient_id = base::GenerateGUID(); 27 transient_id = base::GenerateGUID();
28 } while (ContainsKey(transient_id_map_, transient_id)); 28 } while (base::ContainsKey(transient_id_map_, transient_id));
29 29
30 device_id_map_[device_id] = transient_id; 30 device_id_map_[device_id] = transient_id;
31 transient_id_map_[transient_id] = device_id; 31 transient_id_map_[transient_id] = device_id;
32 } 32 }
33 33
34 return device_id_map_[device_id]; 34 return device_id_map_[device_id];
35 } 35 }
36 36
37 std::string TransientDeviceIds::DeviceIdFromTransientId( 37 std::string TransientDeviceIds::DeviceIdFromTransientId(
38 const std::string& transient_id) const { 38 const std::string& transient_id) const {
39 IdMap::const_iterator it = transient_id_map_.find(transient_id); 39 IdMap::const_iterator it = transient_id_map_.find(transient_id);
40 if (it == transient_id_map_.end()) 40 if (it == transient_id_map_.end())
41 return std::string(); 41 return std::string();
42 return it->second; 42 return it->second;
43 } 43 }
44 44
45 } // namespace storage_monitor 45 } // namespace storage_monitor
OLDNEW
« no previous file with comments | « components/storage_monitor/storage_monitor_linux.cc ('k') | components/storage_monitor/volume_mount_watcher_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698