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