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(); | |
50 } | 49 } |
51 | 50 |
52 MediaDeviceNotifications::~MediaDeviceNotifications() { | 51 MediaDeviceNotifications::~MediaDeviceNotifications() { |
53 disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); | 52 disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); |
54 if (manager) { | 53 if (manager) { |
55 manager->RemoveObserver(this); | 54 manager->RemoveObserver(this); |
56 } | 55 } |
57 } | 56 } |
58 | 57 |
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 | |
72 void MediaDeviceNotifications::DiskChanged( | 58 void MediaDeviceNotifications::DiskChanged( |
73 disks::DiskMountManagerEventType event, | 59 disks::DiskMountManagerEventType event, |
74 const disks::DiskMountManager::Disk* disk) { | 60 const disks::DiskMountManager::Disk* disk) { |
75 } | 61 } |
76 | 62 |
77 void MediaDeviceNotifications::DeviceChanged( | 63 void MediaDeviceNotifications::DeviceChanged( |
78 disks::DiskMountManagerEventType event, | 64 disks::DiskMountManagerEventType event, |
79 const std::string& device_path) { | 65 const std::string& device_path) { |
80 } | 66 } |
81 | 67 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 140 |
155 mount_map_.insert(std::make_pair(mount_info.mount_path, device_id)); | 141 mount_map_.insert(std::make_pair(mount_info.mount_path, device_id)); |
156 base::SystemMonitor::Get()->ProcessMediaDeviceAttached( | 142 base::SystemMonitor::Get()->ProcessMediaDeviceAttached( |
157 device_id, | 143 device_id, |
158 device_label, | 144 device_label, |
159 base::SystemMonitor::TYPE_PATH, | 145 base::SystemMonitor::TYPE_PATH, |
160 mount_info.mount_path); | 146 mount_info.mount_path); |
161 } | 147 } |
162 | 148 |
163 } // namespace chrome | 149 } // namespace chrome |
OLD | NEW |