OLD | NEW |
| (Empty) |
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. | |
4 | |
5 // TransientDeviceIds implementation. | |
6 | |
7 #include "chrome/browser/media_gallery/transient_device_ids.h" | |
8 | |
9 #include "base/logging.h" | |
10 #include "chrome/browser/system_monitor/media_storage_util.h" | |
11 | |
12 namespace chrome { | |
13 | |
14 TransientDeviceIds::TransientDeviceIds() : next_transient_id_(1) {} | |
15 | |
16 TransientDeviceIds::~TransientDeviceIds() {} | |
17 | |
18 uint64 TransientDeviceIds::GetTransientIdForDeviceId( | |
19 const std::string& device_id) { | |
20 DCHECK(thread_checker_.CalledOnValidThread()); | |
21 DCHECK(MediaStorageUtil::IsRemovableDevice(device_id)); | |
22 | |
23 bool inserted = | |
24 id_map_.insert(std::make_pair(device_id, next_transient_id_)).second; | |
25 if (inserted) { | |
26 // Inserted a device that has never been seen before. | |
27 ++next_transient_id_; | |
28 } | |
29 return id_map_[device_id]; | |
30 } | |
31 | |
32 } // namespace chrome | |
OLD | NEW |