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::StorageMonitorCros implementation. | 5 // chromeos::StorageMonitorCros implementation. |
6 | 6 |
7 #include "chrome/browser/storage_monitor/storage_monitor_chromeos.h" | 7 #include "chrome/browser/storage_monitor/storage_monitor_chromeos.h" |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 void StorageMonitorCros::Init() { | 124 void StorageMonitorCros::Init() { |
125 DCHECK(disks::DiskMountManager::GetInstance()); | 125 DCHECK(disks::DiskMountManager::GetInstance()); |
126 disks::DiskMountManager::GetInstance()->AddObserver(this); | 126 disks::DiskMountManager::GetInstance()->AddObserver(this); |
127 CheckExistingMountPointsOnUIThread(); | 127 CheckExistingMountPointsOnUIThread(); |
128 | 128 |
129 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { | 129 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { |
130 scoped_refptr<base::MessageLoopProxy> loop_proxy; | 130 scoped_refptr<base::MessageLoopProxy> loop_proxy; |
131 device::MediaTransferProtocolManager::Initialize(loop_proxy); | 131 device::MediaTransferProtocolManager::Initialize(loop_proxy); |
132 | 132 |
133 media_transfer_protocol_device_observer_.reset( | 133 media_transfer_protocol_device_observer_.reset( |
134 new chrome::MediaTransferProtocolDeviceObserverLinux()); | 134 new chrome::MediaTransferProtocolDeviceObserverLinux(receiver())); |
135 media_transfer_protocol_device_observer_->SetNotifications(receiver()); | |
136 } | 135 } |
137 } | 136 } |
138 | 137 |
139 void StorageMonitorCros::CheckExistingMountPointsOnUIThread() { | 138 void StorageMonitorCros::CheckExistingMountPointsOnUIThread() { |
140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
141 const disks::DiskMountManager::MountPointMap& mount_point_map = | 140 const disks::DiskMountManager::MountPointMap& mount_point_map = |
142 disks::DiskMountManager::GetInstance()->mount_points(); | 141 disks::DiskMountManager::GetInstance()->mount_points(); |
143 for (disks::DiskMountManager::MountPointMap::const_iterator it = | 142 for (disks::DiskMountManager::MountPointMap::const_iterator it = |
144 mount_point_map.begin(); it != mount_point_map.end(); ++it) { | 143 mount_point_map.begin(); it != mount_point_map.end(); ++it) { |
145 BrowserThread::PostTask( | 144 BrowserThread::PostTask( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 199 |
201 void StorageMonitorCros::OnFormatEvent( | 200 void StorageMonitorCros::OnFormatEvent( |
202 disks::DiskMountManager::FormatEvent event, | 201 disks::DiskMountManager::FormatEvent event, |
203 FormatError error_code, | 202 FormatError error_code, |
204 const std::string& device_path) { | 203 const std::string& device_path) { |
205 } | 204 } |
206 | 205 |
207 bool StorageMonitorCros::GetStorageInfoForPath( | 206 bool StorageMonitorCros::GetStorageInfoForPath( |
208 const base::FilePath& path, | 207 const base::FilePath& path, |
209 StorageInfo* device_info) const { | 208 StorageInfo* device_info) const { |
| 209 // TODO(thestig) |media_transfer_protocol_device_observer_| should always be |
| 210 // valid. |
| 211 if (media_transfer_protocol_device_observer_ && |
| 212 media_transfer_protocol_device_observer_->GetStorageInfoForPath( |
| 213 path, device_info)) { |
| 214 return true; |
| 215 } |
| 216 |
210 if (!path.IsAbsolute()) | 217 if (!path.IsAbsolute()) |
211 return false; | 218 return false; |
212 | 219 |
213 base::FilePath current = path; | 220 base::FilePath current = path; |
214 while (!ContainsKey(mount_map_, current.value()) && | 221 while (!ContainsKey(mount_map_, current.value()) && |
215 current != current.DirName()) { | 222 current != current.DirName()) { |
216 current = current.DirName(); | 223 current = current.DirName(); |
217 } | 224 } |
218 | 225 |
219 MountMap::const_iterator info_it = mount_map_.find(current.value()); | 226 MountMap::const_iterator info_it = mount_map_.find(current.value()); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 vendor_name, | 334 vendor_name, |
328 model_name, | 335 model_name, |
329 storage_size_in_bytes); | 336 storage_size_in_bytes); |
330 | 337 |
331 mount_map_.insert(std::make_pair(mount_info.mount_path, object_info)); | 338 mount_map_.insert(std::make_pair(mount_info.mount_path, object_info)); |
332 | 339 |
333 receiver()->ProcessAttach(object_info); | 340 receiver()->ProcessAttach(object_info); |
334 } | 341 } |
335 | 342 |
336 } // namespace chromeos | 343 } // namespace chromeos |
OLD | NEW |