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

Side by Side Diff: chrome/browser/system_monitor/removable_device_notifications_linux.cc

Issue 12147002: Add a receiver interface to RemovableStorageNotifications. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merging Created 7 years, 10 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 // RemovableDeviceNotificationsLinux implementation. 5 // RemovableDeviceNotificationsLinux implementation.
6 6
7 #include "chrome/browser/system_monitor/removable_device_notifications_linux.h" 7 #include "chrome/browser/system_monitor/removable_device_notifications_linux.h"
8 8
9 #include <mntent.h> 9 #include <mntent.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 // |mount_point|. 345 // |mount_point|.
346 if (new_iter == new_mtab.end() || (new_iter->second != mount_device)) { 346 if (new_iter == new_mtab.end() || (new_iter->second != mount_device)) {
347 MountPriorityMap::iterator priority = 347 MountPriorityMap::iterator priority =
348 mount_priority_map_.find(mount_device); 348 mount_priority_map_.find(mount_device);
349 DCHECK(priority != mount_priority_map_.end()); 349 DCHECK(priority != mount_priority_map_.end());
350 ReferencedMountPoint::const_iterator has_priority = 350 ReferencedMountPoint::const_iterator has_priority =
351 priority->second.find(mount_point); 351 priority->second.find(mount_point);
352 if (MediaStorageUtil::IsRemovableDevice(old_iter->second.device_id)) { 352 if (MediaStorageUtil::IsRemovableDevice(old_iter->second.device_id)) {
353 DCHECK(has_priority != priority->second.end()); 353 DCHECK(has_priority != priority->second.end());
354 if (has_priority->second) { 354 if (has_priority->second) {
355 ProcessDetach(old_iter->second.device_id); 355 receiver()->ProcessDetach(old_iter->second.device_id);
356 } 356 }
357 if (priority->second.size() > 1) 357 if (priority->second.size() > 1)
358 multiple_mounted_devices_needing_reattachment.push_back(mount_device); 358 multiple_mounted_devices_needing_reattachment.push_back(mount_device);
359 } 359 }
360 priority->second.erase(mount_point); 360 priority->second.erase(mount_point);
361 if (priority->second.empty()) 361 if (priority->second.empty())
362 mount_priority_map_.erase(mount_device); 362 mount_priority_map_.erase(mount_device);
363 mount_points_to_erase.push_back(mount_point); 363 mount_points_to_erase.push_back(mount_point);
364 } 364 }
365 } 365 }
(...skipping 16 matching lines...) Expand all
382 it != multiple_mounted_devices_needing_reattachment.end(); 382 it != multiple_mounted_devices_needing_reattachment.end();
383 ++it) { 383 ++it) {
384 ReferencedMountPoint::iterator first_mount_point_info = 384 ReferencedMountPoint::iterator first_mount_point_info =
385 mount_priority_map_.find(*it)->second.begin(); 385 mount_priority_map_.find(*it)->second.begin();
386 const base::FilePath& mount_point = first_mount_point_info->first; 386 const base::FilePath& mount_point = first_mount_point_info->first;
387 first_mount_point_info->second = true; 387 first_mount_point_info->second = true;
388 388
389 const MountPointInfo& mount_info = 389 const MountPointInfo& mount_info =
390 mount_info_map_.find(mount_point)->second; 390 mount_info_map_.find(mount_point)->second;
391 DCHECK(MediaStorageUtil::IsRemovableDevice(mount_info.device_id)); 391 DCHECK(MediaStorageUtil::IsRemovableDevice(mount_info.device_id));
392 ProcessAttach( 392 receiver()->ProcessAttach(
393 mount_info.device_id, mount_info.device_name, mount_point.value()); 393 mount_info.device_id, mount_info.device_name, mount_point.value());
394 } 394 }
395 395
396 // Check new mtab entries against existing ones. 396 // Check new mtab entries against existing ones.
397 for (MountPointDeviceMap::iterator new_iter = new_mtab.begin(); 397 for (MountPointDeviceMap::iterator new_iter = new_mtab.begin();
398 new_iter != new_mtab.end(); ++new_iter) { 398 new_iter != new_mtab.end(); ++new_iter) {
399 const base::FilePath& mount_point = new_iter->first; 399 const base::FilePath& mount_point = new_iter->first;
400 const base::FilePath& mount_device = new_iter->second; 400 const base::FilePath& mount_device = new_iter->second;
401 MountMap::iterator old_iter = mount_info_map_.find(mount_point); 401 MountMap::iterator old_iter = mount_info_map_.find(mount_point);
402 if (old_iter == mount_info_map_.end() || 402 if (old_iter == mount_info_map_.end() ||
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 MountPointInfo mount_point_info; 448 MountPointInfo mount_point_info;
449 mount_point_info.mount_device = mount_device; 449 mount_point_info.mount_device = mount_device;
450 mount_point_info.device_id = device_id; 450 mount_point_info.device_id = device_id;
451 mount_point_info.device_name = name; 451 mount_point_info.device_name = name;
452 mount_point_info.partition_size_in_bytes = partition_size_in_bytes; 452 mount_point_info.partition_size_in_bytes = partition_size_in_bytes;
453 453
454 mount_info_map_[mount_point] = mount_point_info; 454 mount_info_map_[mount_point] = mount_point_info;
455 mount_priority_map_[mount_device][mount_point] = removable; 455 mount_priority_map_[mount_device][mount_point] = removable;
456 456
457 if (removable) { 457 if (removable) {
458 ProcessAttach( 458 receiver()->ProcessAttach(
459 device_id, GetDisplayNameForDevice(partition_size_in_bytes, name), 459 device_id, GetDisplayNameForDevice(partition_size_in_bytes, name),
460 mount_point.value()); 460 mount_point.value());
461 } 461 }
462 } 462 }
463 463
464 } // namespace chrome 464 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698