| 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 // StorageMonitorLinux implementation. | 5 // StorageMonitorLinux implementation. |
| 6 | 6 |
| 7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" | 7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" |
| 8 | 8 |
| 9 #include <mntent.h> | 9 #include <mntent.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| 11 #include <sys/vfs.h> |
| 11 | 12 |
| 12 #include <list> | 13 #include <list> |
| 13 | 14 |
| 14 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 15 #include "base/bind.h" | 16 #include "base/bind.h" |
| 16 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 17 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
| 18 #include "base/process.h" | 19 #include "base/process.h" |
| 19 #include "base/process_util.h" | 20 #include "base/process_util.h" |
| 20 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 scoped_refptr<base::MessageLoopProxy> loop_proxy = | 287 scoped_refptr<base::MessageLoopProxy> loop_proxy = |
| 287 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); | 288 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); |
| 288 media_transfer_protocol_manager_.reset( | 289 media_transfer_protocol_manager_.reset( |
| 289 device::MediaTransferProtocolManager::Initialize(loop_proxy)); | 290 device::MediaTransferProtocolManager::Initialize(loop_proxy)); |
| 290 } | 291 } |
| 291 | 292 |
| 292 media_transfer_protocol_device_observer_.reset( | 293 media_transfer_protocol_device_observer_.reset( |
| 293 new MediaTransferProtocolDeviceObserverLinux(receiver())); | 294 new MediaTransferProtocolDeviceObserverLinux(receiver())); |
| 294 } | 295 } |
| 295 | 296 |
| 297 std::vector<StorageInfo> StorageMonitorLinux::GetAllAvailableStorages() const { |
| 298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 299 std::vector<StorageInfo> results; |
| 300 |
| 301 for (MountMap::const_iterator it = mount_info_map_.begin(); |
| 302 it != mount_info_map_.end(); ++it) |
| 303 results.push_back(it->second.storage_info); |
| 304 |
| 305 return results; |
| 306 } |
| 307 |
| 296 bool StorageMonitorLinux::GetStorageInfoForPath( | 308 bool StorageMonitorLinux::GetStorageInfoForPath( |
| 297 const base::FilePath& path, | 309 const base::FilePath& path, |
| 298 StorageInfo* device_info) const { | 310 StorageInfo* device_info) const { |
| 299 DCHECK(device_info); | 311 DCHECK(device_info); |
| 300 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 312 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 301 | 313 |
| 302 // TODO(thestig) |media_transfer_protocol_device_observer_| should always be | 314 // TODO(thestig) |media_transfer_protocol_device_observer_| should always be |
| 303 // valid. | 315 // valid. |
| 304 if (media_transfer_protocol_device_observer_ && | 316 if (media_transfer_protocol_device_observer_ && |
| 305 media_transfer_protocol_device_observer_->GetStorageInfoForPath( | 317 media_transfer_protocol_device_observer_->GetStorageInfoForPath( |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 MountPointInfo mount_point_info; | 517 MountPointInfo mount_point_info; |
| 506 mount_point_info.mount_device = mount_device; | 518 mount_point_info.mount_device = mount_device; |
| 507 mount_point_info.storage_info = *storage_info; | 519 mount_point_info.storage_info = *storage_info; |
| 508 mount_info_map_[mount_point] = mount_point_info; | 520 mount_info_map_[mount_point] = mount_point_info; |
| 509 mount_priority_map_[mount_device][mount_point] = removable; | 521 mount_priority_map_[mount_device][mount_point] = removable; |
| 510 if (removable) | 522 if (removable) |
| 511 receiver()->ProcessAttach(*storage_info); | 523 receiver()->ProcessAttach(*storage_info); |
| 512 } | 524 } |
| 513 | 525 |
| 514 } // namespace chrome | 526 } // namespace chrome |
| OLD | NEW |