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" |
12 #include "chrome/browser/media_gallery/media_device_notifications_utils.h" | 13 #include "chrome/browser/media_gallery/media_device_notifications_utils.h" |
13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
14 | 15 |
15 namespace chromeos { | 16 namespace chromeos { |
16 | 17 |
17 using content::BrowserThread; | 18 using content::BrowserThread; |
18 | 19 |
19 MediaDeviceNotifications::MediaDeviceNotifications() | 20 MediaDeviceNotifications::MediaDeviceNotifications() |
20 : current_device_id_(0U) { | 21 : current_device_id_(0) { |
21 DCHECK(disks::DiskMountManager::GetInstance()); | 22 DCHECK(disks::DiskMountManager::GetInstance()); |
22 disks::DiskMountManager::GetInstance()->AddObserver(this); | 23 disks::DiskMountManager::GetInstance()->AddObserver(this); |
23 } | 24 } |
24 | 25 |
25 MediaDeviceNotifications::~MediaDeviceNotifications() { | 26 MediaDeviceNotifications::~MediaDeviceNotifications() { |
26 disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); | 27 disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); |
27 if (manager) { | 28 if (manager) { |
28 manager->RemoveObserver(this); | 29 manager->RemoveObserver(this); |
29 } | 30 } |
30 } | 31 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 93 } |
93 | 94 |
94 void MediaDeviceNotifications::AddMountedPathOnUIThread( | 95 void MediaDeviceNotifications::AddMountedPathOnUIThread( |
95 const disks::DiskMountManager::MountPointInfo& mount_info) { | 96 const disks::DiskMountManager::MountPointInfo& mount_info) { |
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
97 | 98 |
98 if (ContainsKey(mount_map_, mount_info.mount_path)) { | 99 if (ContainsKey(mount_map_, mount_info.mount_path)) { |
99 NOTREACHED(); | 100 NOTREACHED(); |
100 return; | 101 return; |
101 } | 102 } |
102 mount_map_.insert(std::make_pair(mount_info.mount_path, current_device_id_)); | 103 const std::string16 device_id_str = |
| 104 base::IntToString16(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 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 |