| Index: base/system_monitor/system_monitor.cc
|
| diff --git a/base/system_monitor/system_monitor.cc b/base/system_monitor/system_monitor.cc
|
| index f30c8935c9a999b38382f78e879c9319a4eba13f..29937d8bced3818f78f57fb09f8774e446437a94 100644
|
| --- a/base/system_monitor/system_monitor.cc
|
| +++ b/base/system_monitor/system_monitor.cc
|
| @@ -39,7 +39,8 @@ SystemMonitor::SystemMonitor()
|
| devices_changed_observer_list_(
|
| new ObserverListThreadSafe<DevicesChangedObserver>()),
|
| battery_in_use_(false),
|
| - suspended_(false) {
|
| + suspended_(false),
|
| + free_space_delegate_(NULL) {
|
| DCHECK(!g_system_monitor);
|
| g_system_monitor = this;
|
|
|
| @@ -121,6 +122,43 @@ void SystemMonitor::ProcessRemovableStorageDetached(const std::string& id) {
|
| NotifyRemovableStorageDetached(id);
|
| }
|
|
|
| +void SystemMonitor::ProcessStorageFreeSpaceChanged(
|
| + const FilePath::StringType& path) {
|
| + DVLOG(1) << "Free Space Changing";
|
| + devices_changed_observer_list_->Notify(
|
| + &DevicesChangedObserver::OnStorageFreeSpaceChanged, path);
|
| +}
|
| +
|
| +bool SystemMonitor::StartWatchingStorage(const FilePath::StringType& path) {
|
| + if (!free_space_delegate_)
|
| + return false;
|
| +
|
| + // Try to start watching if the first one is requested.
|
| + if (watched_storages_.find(path) == watched_storages_.end() &&
|
| + !free_space_delegate_->StartWatchingStorage(path)) {
|
| + return false;
|
| + }
|
| +
|
| + // The free space watcher has been started for the storage identifed by
|
| + // |path|.
|
| + watched_storages_.insert(path);
|
| + return true;
|
| +}
|
| +
|
| +bool SystemMonitor::StopWatchingStorage(const FilePath::StringType& path) {
|
| + if (!free_space_delegate_)
|
| + return false;
|
| +
|
| + watched_storages_.erase(path);
|
| +
|
| + // Try to stop watching when the last one is erased.
|
| + if (watched_storages_.find(path) == watched_storages_.end() &&
|
| + !free_space_delegate_->StopWatchingStorage(path))
|
| + return false;
|
| +
|
| + return true;
|
| +}
|
| +
|
| std::vector<SystemMonitor::RemovableStorageInfo>
|
| SystemMonitor::GetAttachedRemovableStorage() const {
|
| std::vector<RemovableStorageInfo> results;
|
|
|