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" |
(...skipping 28 matching lines...) Expand all Loading... |
39 return true; | 39 return true; |
40 } | 40 } |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 using content::BrowserThread; | 44 using content::BrowserThread; |
45 | 45 |
46 MediaDeviceNotifications::MediaDeviceNotifications() { | 46 MediaDeviceNotifications::MediaDeviceNotifications() { |
47 DCHECK(disks::DiskMountManager::GetInstance()); | 47 DCHECK(disks::DiskMountManager::GetInstance()); |
48 disks::DiskMountManager::GetInstance()->AddObserver(this); | 48 disks::DiskMountManager::GetInstance()->AddObserver(this); |
| 49 CheckExistingMountPointsOnUIThread(); |
49 } | 50 } |
50 | 51 |
51 MediaDeviceNotifications::~MediaDeviceNotifications() { | 52 MediaDeviceNotifications::~MediaDeviceNotifications() { |
52 disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); | 53 disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); |
53 if (manager) { | 54 if (manager) { |
54 manager->RemoveObserver(this); | 55 manager->RemoveObserver(this); |
55 } | 56 } |
56 } | 57 } |
57 | 58 |
| 59 void MediaDeviceNotifications::CheckExistingMountPointsOnUIThread() { |
| 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 61 const disks::DiskMountManager::MountPointMap& mount_point_map = |
| 62 disks::DiskMountManager::GetInstance()->mount_points(); |
| 63 for (disks::DiskMountManager::MountPointMap::const_iterator it = |
| 64 mount_point_map.begin(); it != mount_point_map.end(); ++it) { |
| 65 BrowserThread::PostTask( |
| 66 BrowserThread::FILE, FROM_HERE, |
| 67 base::Bind(&MediaDeviceNotifications::CheckMountedPathOnFileThread, |
| 68 this, it->second)); |
| 69 } |
| 70 } |
| 71 |
58 void MediaDeviceNotifications::DiskChanged( | 72 void MediaDeviceNotifications::DiskChanged( |
59 disks::DiskMountManagerEventType event, | 73 disks::DiskMountManagerEventType event, |
60 const disks::DiskMountManager::Disk* disk) { | 74 const disks::DiskMountManager::Disk* disk) { |
61 } | 75 } |
62 | 76 |
63 void MediaDeviceNotifications::DeviceChanged( | 77 void MediaDeviceNotifications::DeviceChanged( |
64 disks::DiskMountManagerEventType event, | 78 disks::DiskMountManagerEventType event, |
65 const std::string& device_path) { | 79 const std::string& device_path) { |
66 } | 80 } |
67 | 81 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 154 |
141 mount_map_.insert(std::make_pair(mount_info.mount_path, device_id)); | 155 mount_map_.insert(std::make_pair(mount_info.mount_path, device_id)); |
142 base::SystemMonitor::Get()->ProcessMediaDeviceAttached( | 156 base::SystemMonitor::Get()->ProcessMediaDeviceAttached( |
143 device_id, | 157 device_id, |
144 device_label, | 158 device_label, |
145 base::SystemMonitor::TYPE_PATH, | 159 base::SystemMonitor::TYPE_PATH, |
146 mount_info.mount_path); | 160 mount_info.mount_path); |
147 } | 161 } |
148 | 162 |
149 } // namespace chrome | 163 } // namespace chrome |
OLD | NEW |