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> |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 current = current.DirName(); | 283 current = current.DirName(); |
284 | 284 |
285 MountMap::const_iterator mount_info = mount_info_map_.find(current); | 285 MountMap::const_iterator mount_info = mount_info_map_.find(current); |
286 if (mount_info == mount_info_map_.end()) | 286 if (mount_info == mount_info_map_.end()) |
287 return false; | 287 return false; |
288 if (device_info) | 288 if (device_info) |
289 *device_info = mount_info->second.storage_info; | 289 *device_info = mount_info->second.storage_info; |
290 return true; | 290 return true; |
291 } | 291 } |
292 | 292 |
293 uint64 StorageMonitorLinux::GetStorageSize(const std::string& location) const { | |
294 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
295 | |
296 MountMap::const_iterator mount_info = mount_info_map_.find( | |
297 base::FilePath(location)); | |
298 return (mount_info != mount_info_map_.end()) ? | |
299 mount_info->second.storage_info.total_size_in_bytes : 0; | |
300 } | |
301 | |
302 void StorageMonitorLinux::SetGetDeviceInfoCallbackForTest( | 293 void StorageMonitorLinux::SetGetDeviceInfoCallbackForTest( |
303 const GetDeviceInfoCallback& get_device_info_callback) { | 294 const GetDeviceInfoCallback& get_device_info_callback) { |
304 get_device_info_callback_ = get_device_info_callback; | 295 get_device_info_callback_ = get_device_info_callback; |
305 } | 296 } |
306 | 297 |
307 void StorageMonitorLinux::OnMtabWatcherCreated(MtabWatcherLinux* watcher) { | 298 void StorageMonitorLinux::OnMtabWatcherCreated(MtabWatcherLinux* watcher) { |
308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 299 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
309 mtab_watcher_.reset(watcher); | 300 mtab_watcher_.reset(watcher); |
310 } | 301 } |
311 | 302 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 | 428 |
438 if (removable) { | 429 if (removable) { |
439 // TODO(gbillock) Do this in a higher level instead of here. | 430 // TODO(gbillock) Do this in a higher level instead of here. |
440 storage_info->name = MediaStorageUtil::GetDisplayNameForDevice( | 431 storage_info->name = MediaStorageUtil::GetDisplayNameForDevice( |
441 storage_info->total_size_in_bytes, storage_info->name); | 432 storage_info->total_size_in_bytes, storage_info->name); |
442 receiver()->ProcessAttach(*storage_info); | 433 receiver()->ProcessAttach(*storage_info); |
443 } | 434 } |
444 } | 435 } |
445 | 436 |
446 } // namespace chrome | 437 } // namespace chrome |
OLD | NEW |