Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/storage_monitor/storage_monitor_linux.cc

Issue 16186002: Refine StorageMonitor storage device getter (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 scoped_refptr<base::MessageLoopProxy> loop_proxy = 290 scoped_refptr<base::MessageLoopProxy> loop_proxy =
290 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); 291 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE);
291 media_transfer_protocol_manager_.reset( 292 media_transfer_protocol_manager_.reset(
292 device::MediaTransferProtocolManager::Initialize(loop_proxy)); 293 device::MediaTransferProtocolManager::Initialize(loop_proxy));
293 } 294 }
294 295
295 media_transfer_protocol_device_observer_.reset( 296 media_transfer_protocol_device_observer_.reset(
296 new MediaTransferProtocolDeviceObserverLinux(receiver())); 297 new MediaTransferProtocolDeviceObserverLinux(receiver()));
297 } 298 }
298 299
300 std::vector<StorageInfo> StorageMonitorLinux::GetAllAvailableStorages() const {
301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
302 std::vector<StorageInfo> results;
303
304 for (MountMap::const_iterator it = mount_info_map_.begin();
305 it != mount_info_map_.end(); ++it)
306 results.push_back(it->second.storage_info);
307
308 return results;
309 }
310
299 bool StorageMonitorLinux::GetStorageInfoForPath( 311 bool StorageMonitorLinux::GetStorageInfoForPath(
300 const base::FilePath& path, 312 const base::FilePath& path,
301 StorageInfo* device_info) const { 313 StorageInfo* device_info) const {
302 DCHECK(device_info); 314 DCHECK(device_info);
303 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 315 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
304 316
305 // TODO(thestig) |media_transfer_protocol_device_observer_| should always be 317 // TODO(thestig) |media_transfer_protocol_device_observer_| should always be
306 // valid. 318 // valid.
307 if (media_transfer_protocol_device_observer_ && 319 if (media_transfer_protocol_device_observer_ &&
308 media_transfer_protocol_device_observer_->GetStorageInfoForPath( 320 media_transfer_protocol_device_observer_->GetStorageInfoForPath(
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 MountPointInfo mount_point_info; 520 MountPointInfo mount_point_info;
509 mount_point_info.mount_device = mount_device; 521 mount_point_info.mount_device = mount_device;
510 mount_point_info.storage_info = *storage_info; 522 mount_point_info.storage_info = *storage_info;
511 mount_info_map_[mount_point] = mount_point_info; 523 mount_info_map_[mount_point] = mount_point_info;
512 mount_priority_map_[mount_device][mount_point] = removable; 524 mount_priority_map_[mount_device][mount_point] = removable;
513 if (removable) 525 if (removable)
514 receiver()->ProcessAttach(*storage_info); 526 receiver()->ProcessAttach(*storage_info);
515 } 527 }
516 528
517 } // namespace chrome 529 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698