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

Side by Side Diff: components/storage_monitor/storage_monitor_linux.cc

Issue 2231753002: components: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more call site Created 4 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/storage_monitor/storage_monitor_linux.h" 7 #include "components/storage_monitor/storage_monitor_linux.h"
8 8
9 #include <mntent.h> 9 #include <mntent.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 if (media_transfer_protocol_device_observer_ && 287 if (media_transfer_protocol_device_observer_ &&
288 media_transfer_protocol_device_observer_->GetStorageInfoForPath( 288 media_transfer_protocol_device_observer_->GetStorageInfoForPath(
289 path, device_info)) { 289 path, device_info)) {
290 return true; 290 return true;
291 } 291 }
292 292
293 if (!path.IsAbsolute()) 293 if (!path.IsAbsolute())
294 return false; 294 return false;
295 295
296 base::FilePath current = path; 296 base::FilePath current = path;
297 while (!ContainsKey(mount_info_map_, current) && current != current.DirName()) 297 while (!base::ContainsKey(mount_info_map_, current) &&
298 current != current.DirName())
298 current = current.DirName(); 299 current = current.DirName();
299 300
300 MountMap::const_iterator mount_info = mount_info_map_.find(current); 301 MountMap::const_iterator mount_info = mount_info_map_.find(current);
301 if (mount_info == mount_info_map_.end()) 302 if (mount_info == mount_info_map_.end())
302 return false; 303 return false;
303 *device_info = mount_info->second.storage_info; 304 *device_info = mount_info->second.storage_info;
304 return true; 305 return true;
305 } 306 }
306 307
307 device::MediaTransferProtocolManager* 308 device::MediaTransferProtocolManager*
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 BrowserThread::FILE, FROM_HERE, 462 BrowserThread::FILE, FROM_HERE,
462 base::Bind(&base::DoNothing), 463 base::Bind(&base::DoNothing),
463 base::Bind(&StorageMonitorLinux::MarkInitialized, 464 base::Bind(&StorageMonitorLinux::MarkInitialized,
464 weak_ptr_factory_.GetWeakPtr())); 465 weak_ptr_factory_.GetWeakPtr()));
465 } 466 }
466 } 467 }
467 468
468 bool StorageMonitorLinux::IsDeviceAlreadyMounted( 469 bool StorageMonitorLinux::IsDeviceAlreadyMounted(
469 const base::FilePath& mount_device) const { 470 const base::FilePath& mount_device) const {
470 DCHECK_CURRENTLY_ON(BrowserThread::UI); 471 DCHECK_CURRENTLY_ON(BrowserThread::UI);
471 return ContainsKey(mount_priority_map_, mount_device); 472 return base::ContainsKey(mount_priority_map_, mount_device);
472 } 473 }
473 474
474 void StorageMonitorLinux::HandleDeviceMountedMultipleTimes( 475 void StorageMonitorLinux::HandleDeviceMountedMultipleTimes(
475 const base::FilePath& mount_device, 476 const base::FilePath& mount_device,
476 const base::FilePath& mount_point) { 477 const base::FilePath& mount_point) {
477 DCHECK_CURRENTLY_ON(BrowserThread::UI); 478 DCHECK_CURRENTLY_ON(BrowserThread::UI);
478 479
479 MountPriorityMap::iterator priority = mount_priority_map_.find(mount_device); 480 MountPriorityMap::iterator priority = mount_priority_map_.find(mount_device);
480 DCHECK(priority != mount_priority_map_.end()); 481 DCHECK(priority != mount_priority_map_.end());
481 const base::FilePath& other_mount_point = priority->second.begin()->first; 482 const base::FilePath& other_mount_point = priority->second.begin()->first;
(...skipping 22 matching lines...) Expand all
504 mount_priority_map_[mount_device][mount_point] = removable; 505 mount_priority_map_[mount_device][mount_point] = removable;
505 receiver()->ProcessAttach(*storage_info); 506 receiver()->ProcessAttach(*storage_info);
506 } 507 }
507 508
508 StorageMonitor* StorageMonitor::CreateInternal() { 509 StorageMonitor* StorageMonitor::CreateInternal() {
509 const base::FilePath kDefaultMtabPath("/etc/mtab"); 510 const base::FilePath kDefaultMtabPath("/etc/mtab");
510 return new StorageMonitorLinux(kDefaultMtabPath); 511 return new StorageMonitorLinux(kDefaultMtabPath);
511 } 512 }
512 513
513 } // namespace storage_monitor 514 } // namespace storage_monitor
OLDNEW
« no previous file with comments | « components/storage_monitor/storage_monitor_chromeos.cc ('k') | components/storage_monitor/transient_device_ids.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698