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

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

Issue 10880078: Linux removable device notifications: notify about non-dcim devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 3 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 | Annotate | Revision Log
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/media_gallery/removable_device_notifications_linux.h" 7 #include "chrome/browser/media_gallery/removable_device_notifications_linux.h"
8 8
9 #include <libudev.h> 9 #include <libudev.h>
10 #include <mntent.h> 10 #include <mntent.h>
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 const FilePath& mount_device = old_iter->second.mount_device; 378 const FilePath& mount_device = old_iter->second.mount_device;
379 MountPointDeviceMap::iterator new_iter = new_mtab.find(mount_point); 379 MountPointDeviceMap::iterator new_iter = new_mtab.find(mount_point);
380 // |mount_point| not in |new_mtab| or |mount_device| is no longer mounted at 380 // |mount_point| not in |new_mtab| or |mount_device| is no longer mounted at
381 // |mount_point|. 381 // |mount_point|.
382 if (new_iter == new_mtab.end() || (new_iter->second != mount_device)) { 382 if (new_iter == new_mtab.end() || (new_iter->second != mount_device)) {
383 MountPriorityMap::iterator priority = 383 MountPriorityMap::iterator priority =
384 mount_priority_map_.find(mount_device); 384 mount_priority_map_.find(mount_device);
385 DCHECK(priority != mount_priority_map_.end()); 385 DCHECK(priority != mount_priority_map_.end());
386 ReferencedMountPoint::const_iterator has_priority = 386 ReferencedMountPoint::const_iterator has_priority =
387 priority->second.find(mount_point); 387 priority->second.find(mount_point);
388 if (old_iter->second.has_dcim) { 388 if (MediaStorageUtil::IsRemovableDevice(old_iter->second.device_id)) {
389 DCHECK(has_priority != priority->second.end()); 389 DCHECK(has_priority != priority->second.end());
390 if (has_priority->second) 390 if (has_priority->second)
kmadhusu 2012/08/29 01:12:02 nit : {}
vandebo (ex-Chrome) 2012/08/29 06:10:13 Done.
391 RemoveMediaMount(old_iter->second.device_id); 391 SystemMonitor::Get()->ProcessRemovableStorageDetached(
392 old_iter->second.device_id);
392 if (priority->second.size() > 1) 393 if (priority->second.size() > 1)
393 multiple_mounted_devices_needing_reattachment.push_back(mount_device); 394 multiple_mounted_devices_needing_reattachment.push_back(mount_device);
394 } 395 }
395 priority->second.erase(mount_point); 396 priority->second.erase(mount_point);
396 if (priority->second.empty()) 397 if (priority->second.empty())
397 mount_priority_map_.erase(mount_device); 398 mount_priority_map_.erase(mount_device);
398 mount_points_to_erase.push_back(mount_point); 399 mount_points_to_erase.push_back(mount_point);
399 } 400 }
400 } 401 }
401 402
(...skipping 13 matching lines...) Expand all
415 multiple_mounted_devices_needing_reattachment.begin(); 416 multiple_mounted_devices_needing_reattachment.begin();
416 it != multiple_mounted_devices_needing_reattachment.end(); 417 it != multiple_mounted_devices_needing_reattachment.end();
417 ++it) { 418 ++it) {
418 ReferencedMountPoint::iterator first_mount_point_info = 419 ReferencedMountPoint::iterator first_mount_point_info =
419 mount_priority_map_.find(*it)->second.begin(); 420 mount_priority_map_.find(*it)->second.begin();
420 const FilePath& mount_point = first_mount_point_info->first; 421 const FilePath& mount_point = first_mount_point_info->first;
421 first_mount_point_info->second = true; 422 first_mount_point_info->second = true;
422 423
423 const MountPointInfo& mount_info = 424 const MountPointInfo& mount_info =
424 mount_info_map_.find(mount_point)->second; 425 mount_info_map_.find(mount_point)->second;
425 DCHECK(mount_info.has_dcim); 426 DCHECK(MediaStorageUtil::IsRemovableDevice(mount_info.device_id));
426 base::SystemMonitor::Get()->ProcessRemovableStorageAttached( 427 base::SystemMonitor::Get()->ProcessRemovableStorageAttached(
427 mount_info.device_id, mount_info.device_name, mount_point.value()); 428 mount_info.device_id, mount_info.device_name, mount_point.value());
428 } 429 }
429 430
430 // Check new mtab entries against existing ones. 431 // Check new mtab entries against existing ones.
431 for (MountPointDeviceMap::iterator new_iter = new_mtab.begin(); 432 for (MountPointDeviceMap::iterator new_iter = new_mtab.begin();
432 new_iter != new_mtab.end(); ++new_iter) { 433 new_iter != new_mtab.end(); ++new_iter) {
433 const FilePath& mount_point = new_iter->first; 434 const FilePath& mount_point = new_iter->first;
434 const FilePath& mount_device = new_iter->second; 435 const FilePath& mount_device = new_iter->second;
435 MountMap::iterator old_iter = mount_info_map_.find(mount_point); 436 MountMap::iterator old_iter = mount_info_map_.find(mount_point);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 } 487 }
487 } else { 488 } else {
488 type = MediaStorageUtil::FIXED_MASS_STORAGE; 489 type = MediaStorageUtil::FIXED_MASS_STORAGE;
489 } 490 }
490 std::string device_id = MediaStorageUtil::MakeDeviceId(type, unique_id); 491 std::string device_id = MediaStorageUtil::MakeDeviceId(type, unique_id);
491 492
492 MountPointInfo mount_point_info; 493 MountPointInfo mount_point_info;
493 mount_point_info.mount_device = mount_device; 494 mount_point_info.mount_device = mount_device;
494 mount_point_info.device_id = device_id; 495 mount_point_info.device_id = device_id;
495 mount_point_info.device_name = name; 496 mount_point_info.device_name = name;
496 mount_point_info.has_dcim = has_dcim;
497 497
498 mount_info_map_[mount_point] = mount_point_info; 498 mount_info_map_[mount_point] = mount_point_info;
499 mount_priority_map_[mount_device][mount_point] = has_dcim; 499 mount_priority_map_[mount_device][mount_point] = removable;
500 500
501 if (mount_point_info.has_dcim) { 501 if (removable) {
502 SystemMonitor::Get()->ProcessRemovableStorageAttached(device_id, name, 502 SystemMonitor::Get()->ProcessRemovableStorageAttached(device_id, name,
503 mount_point.value()); 503 mount_point.value());
504 } 504 }
505 } 505 }
506 506
507 void RemovableDeviceNotificationsLinux::RemoveMediaMount(
508 const std::string& device_id) {
509 SystemMonitor::Get()->ProcessRemovableStorageDetached(device_id);
510 }
511
512 } // namespace chrome 507 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698