Chromium Code Reviews| OLD | NEW | 
|---|---|
| 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 <stdio.h> | 10 #include <stdio.h> | 
| 11 | 11 | 
| 12 #include <list> | 12 #include <list> | 
| 13 | 13 | 
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" | 
| 15 #include "base/bind.h" | 15 #include "base/bind.h" | 
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" | 
| 17 #include "base/process/kill.h" | 17 #include "base/process/kill.h" | 
| 18 #include "base/process/launch.h" | 18 #include "base/process/launch.h" | 
| 19 #include "base/process/process.h" | 19 #include "base/process/process.h" | 
| 20 #include "base/single_thread_task_runner.h" | |
| 20 #include "base/stl_util.h" | 21 #include "base/stl_util.h" | 
| 21 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" | 
| 22 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" | 
| 23 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" | 
| 24 #include "components/storage_monitor/media_storage_util.h" | 25 #include "components/storage_monitor/media_storage_util.h" | 
| 25 #include "components/storage_monitor/media_transfer_protocol_device_observer_lin ux.h" | 26 #include "components/storage_monitor/media_transfer_protocol_device_observer_lin ux.h" | 
| 26 #include "components/storage_monitor/removable_device_constants.h" | 27 #include "components/storage_monitor/removable_device_constants.h" | 
| 27 #include "components/storage_monitor/storage_info.h" | 28 #include "components/storage_monitor/storage_info.h" | 
| 28 #include "components/storage_monitor/udev_util_linux.h" | 29 #include "components/storage_monitor/udev_util_linux.h" | 
| 29 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" | 30 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" | 
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 | 257 | 
| 257 BrowserThread::PostTaskAndReplyWithResult( | 258 BrowserThread::PostTaskAndReplyWithResult( | 
| 258 BrowserThread::FILE, FROM_HERE, | 259 BrowserThread::FILE, FROM_HERE, | 
| 259 base::Bind(&CreateMtabWatcherLinuxOnFileThread, | 260 base::Bind(&CreateMtabWatcherLinuxOnFileThread, | 
| 260 mtab_path_, | 261 mtab_path_, | 
| 261 weak_ptr_factory_.GetWeakPtr()), | 262 weak_ptr_factory_.GetWeakPtr()), | 
| 262 base::Bind(&StorageMonitorLinux::OnMtabWatcherCreated, | 263 base::Bind(&StorageMonitorLinux::OnMtabWatcherCreated, | 
| 263 weak_ptr_factory_.GetWeakPtr())); | 264 weak_ptr_factory_.GetWeakPtr())); | 
| 264 | 265 | 
| 265 if (!media_transfer_protocol_manager_) { | 266 if (!media_transfer_protocol_manager_) { | 
| 266 scoped_refptr<base::MessageLoopProxy> loop_proxy = | |
| 267 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); | 267 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); | 
| 268 media_transfer_protocol_manager_.reset( | 268 media_transfer_protocol_manager_.reset( | 
| 269 device::MediaTransferProtocolManager::Initialize(loop_proxy)); | 269 device::MediaTransferProtocolManager::Initialize( | 
| 270 scoped_refptr<base::SingleThreadTaskRunner>())); | |
| 
 
Lei Zhang
2015/05/14 18:54:38
Uh, this isn't right. Look closely.
 
Pranay
2015/05/15 03:44:05
Oops! I'm sorry. Thanks for pointing out, Lei.
 
 | |
| 270 } | 271 } | 
| 271 | 272 | 
| 272 media_transfer_protocol_device_observer_.reset( | 273 media_transfer_protocol_device_observer_.reset( | 
| 273 new MediaTransferProtocolDeviceObserverLinux( | 274 new MediaTransferProtocolDeviceObserverLinux( | 
| 274 receiver(), media_transfer_protocol_manager_.get())); | 275 receiver(), media_transfer_protocol_manager_.get())); | 
| 275 } | 276 } | 
| 276 | 277 | 
| 277 bool StorageMonitorLinux::GetStorageInfoForPath( | 278 bool StorageMonitorLinux::GetStorageInfoForPath( | 
| 278 const base::FilePath& path, | 279 const base::FilePath& path, | 
| 279 StorageInfo* device_info) const { | 280 StorageInfo* device_info) const { | 
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 mount_priority_map_[mount_device][mount_point] = removable; | 502 mount_priority_map_[mount_device][mount_point] = removable; | 
| 502 receiver()->ProcessAttach(*storage_info); | 503 receiver()->ProcessAttach(*storage_info); | 
| 503 } | 504 } | 
| 504 | 505 | 
| 505 StorageMonitor* StorageMonitor::CreateInternal() { | 506 StorageMonitor* StorageMonitor::CreateInternal() { | 
| 506 const base::FilePath kDefaultMtabPath("/etc/mtab"); | 507 const base::FilePath kDefaultMtabPath("/etc/mtab"); | 
| 507 return new StorageMonitorLinux(kDefaultMtabPath); | 508 return new StorageMonitorLinux(kDefaultMtabPath); | 
| 508 } | 509 } | 
| 509 | 510 | 
| 510 } // namespace storage_monitor | 511 } // namespace storage_monitor | 
| OLD | NEW |