| 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 // 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 <libudev.h> | 9 #include <libudev.h> |
| 10 #include <mntent.h> | 10 #include <mntent.h> |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 355 |
| 356 void RemovableDeviceNotificationsLinux::InitOnFileThread() { | 356 void RemovableDeviceNotificationsLinux::InitOnFileThread() { |
| 357 DCHECK(!initialized_); | 357 DCHECK(!initialized_); |
| 358 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 358 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 359 initialized_ = true; | 359 initialized_ = true; |
| 360 | 360 |
| 361 // The callback passed to Watch() has to be unretained. Otherwise | 361 // The callback passed to Watch() has to be unretained. Otherwise |
| 362 // RemovableDeviceNotificationsLinux will live longer than expected, and | 362 // RemovableDeviceNotificationsLinux will live longer than expected, and |
| 363 // FilePathWatcher will get in trouble at shutdown time. | 363 // FilePathWatcher will get in trouble at shutdown time. |
| 364 bool ret = file_watcher_.Watch( | 364 bool ret = file_watcher_.Watch( |
| 365 mtab_path_, | 365 mtab_path_, false, |
| 366 base::Bind(&RemovableDeviceNotificationsLinux::OnFilePathChanged, | 366 base::Bind(&RemovableDeviceNotificationsLinux::OnFilePathChanged, |
| 367 base::Unretained(this))); | 367 base::Unretained(this))); |
| 368 if (!ret) { | 368 if (!ret) { |
| 369 LOG(ERROR) << "Adding watch for " << mtab_path_.value() << " failed"; | 369 LOG(ERROR) << "Adding watch for " << mtab_path_.value() << " failed"; |
| 370 return; | 370 return; |
| 371 } | 371 } |
| 372 | 372 |
| 373 UpdateMtab(); | 373 UpdateMtab(); |
| 374 } | 374 } |
| 375 | 375 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 mount_priority_map_[mount_device][mount_point] = removable; | 502 mount_priority_map_[mount_device][mount_point] = removable; |
| 503 | 503 |
| 504 if (removable) { | 504 if (removable) { |
| 505 base::SystemMonitor::Get()->ProcessRemovableStorageAttached( | 505 base::SystemMonitor::Get()->ProcessRemovableStorageAttached( |
| 506 device_id, GetDisplayNameForDevice(partition_size_in_bytes, name), | 506 device_id, GetDisplayNameForDevice(partition_size_in_bytes, name), |
| 507 mount_point.value()); | 507 mount_point.value()); |
| 508 } | 508 } |
| 509 } | 509 } |
| 510 | 510 |
| 511 } // namespace chrome | 511 } // namespace chrome |
| OLD | NEW |