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 // chromeos::MediaDeviceNotifications implementation. | 5 // chromeos::MediaDeviceNotifications implementation. |
6 | 6 |
7 #include "chrome/browser/media_gallery/media_device_notifications_chromeos.h" | 7 #include "chrome/browser/media_gallery/media_device_notifications_chromeos.h" |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.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 "base/string_number_conversions.h" |
| 13 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/media_gallery/media_device_notifications_utils.h" | 14 #include "chrome/browser/media_gallery/media_device_notifications_utils.h" |
13 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
14 | 16 |
15 namespace chromeos { | 17 namespace chromeos { |
16 | 18 |
17 using content::BrowserThread; | 19 using content::BrowserThread; |
18 | 20 |
19 MediaDeviceNotifications::MediaDeviceNotifications() | 21 MediaDeviceNotifications::MediaDeviceNotifications() |
20 : current_device_id_(0U) { | 22 : current_device_id_(0) { |
21 DCHECK(disks::DiskMountManager::GetInstance()); | 23 DCHECK(disks::DiskMountManager::GetInstance()); |
22 disks::DiskMountManager::GetInstance()->AddObserver(this); | 24 disks::DiskMountManager::GetInstance()->AddObserver(this); |
23 } | 25 } |
24 | 26 |
25 MediaDeviceNotifications::~MediaDeviceNotifications() { | 27 MediaDeviceNotifications::~MediaDeviceNotifications() { |
26 disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); | 28 disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); |
27 if (manager) { | 29 if (manager) { |
28 manager->RemoveObserver(this); | 30 manager->RemoveObserver(this); |
29 } | 31 } |
30 } | 32 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 94 } |
93 | 95 |
94 void MediaDeviceNotifications::AddMountedPathOnUIThread( | 96 void MediaDeviceNotifications::AddMountedPathOnUIThread( |
95 const disks::DiskMountManager::MountPointInfo& mount_info) { | 97 const disks::DiskMountManager::MountPointInfo& mount_info) { |
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
97 | 99 |
98 if (ContainsKey(mount_map_, mount_info.mount_path)) { | 100 if (ContainsKey(mount_map_, mount_info.mount_path)) { |
99 NOTREACHED(); | 101 NOTREACHED(); |
100 return; | 102 return; |
101 } | 103 } |
102 mount_map_.insert(std::make_pair(mount_info.mount_path, current_device_id_)); | 104 const std::string device_id_str = base::IntToString(current_device_id_++); |
| 105 mount_map_.insert(std::make_pair(mount_info.mount_path, device_id_str)); |
103 base::SystemMonitor::Get()->ProcessMediaDeviceAttached( | 106 base::SystemMonitor::Get()->ProcessMediaDeviceAttached( |
104 current_device_id_++, | 107 device_id_str, |
105 FilePath(mount_info.source_path).BaseName().value(), | 108 UTF8ToUTF16(FilePath(mount_info.source_path).BaseName().value()), |
106 FilePath(mount_info.mount_path)); | 109 base::SystemMonitor::TYPE_PATH, |
| 110 mount_info.mount_path); |
107 } | 111 } |
108 | 112 |
109 } // namespace chrome | 113 } // namespace chrome |
OLD | NEW |