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 // StorageMonitorLinux implementation. | 5 // StorageMonitorLinux implementation. |
6 | 6 |
7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" | 7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" |
8 | 8 |
9 #include <mntent.h> | 9 #include <mntent.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 base::Bind(&StorageMonitorLinux::OnMtabWatcherCreated, | 251 base::Bind(&StorageMonitorLinux::OnMtabWatcherCreated, |
252 weak_ptr_factory_.GetWeakPtr())); | 252 weak_ptr_factory_.GetWeakPtr())); |
253 | 253 |
254 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { | 254 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { |
255 scoped_refptr<base::MessageLoopProxy> loop_proxy; | 255 scoped_refptr<base::MessageLoopProxy> loop_proxy; |
256 loop_proxy = content::BrowserThread::GetMessageLoopProxyForThread( | 256 loop_proxy = content::BrowserThread::GetMessageLoopProxyForThread( |
257 content::BrowserThread::FILE); | 257 content::BrowserThread::FILE); |
258 device::MediaTransferProtocolManager::Initialize(loop_proxy); | 258 device::MediaTransferProtocolManager::Initialize(loop_proxy); |
259 | 259 |
260 media_transfer_protocol_device_observer_.reset( | 260 media_transfer_protocol_device_observer_.reset( |
261 new MediaTransferProtocolDeviceObserverLinux()); | 261 new MediaTransferProtocolDeviceObserverLinux(receiver())); |
262 media_transfer_protocol_device_observer_->SetNotifications(receiver()); | |
263 } | 262 } |
264 } | 263 } |
265 | 264 |
266 bool StorageMonitorLinux::GetStorageInfoForPath( | 265 bool StorageMonitorLinux::GetStorageInfoForPath( |
267 const base::FilePath& path, | 266 const base::FilePath& path, |
268 StorageInfo* device_info) const { | 267 StorageInfo* device_info) const { |
269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
270 | 269 |
| 270 // TODO(thestig) |media_transfer_protocol_device_observer_| should always be |
| 271 // valid. |
| 272 if (media_transfer_protocol_device_observer_ && |
| 273 media_transfer_protocol_device_observer_->GetStorageInfoForPath( |
| 274 path, device_info)) { |
| 275 return true; |
| 276 } |
| 277 |
271 if (!path.IsAbsolute()) | 278 if (!path.IsAbsolute()) |
272 return false; | 279 return false; |
273 | 280 |
274 base::FilePath current = path; | 281 base::FilePath current = path; |
275 while (!ContainsKey(mount_info_map_, current) && current != current.DirName()) | 282 while (!ContainsKey(mount_info_map_, current) && current != current.DirName()) |
276 current = current.DirName(); | 283 current = current.DirName(); |
277 | 284 |
278 MountMap::const_iterator mount_info = mount_info_map_.find(current); | 285 MountMap::const_iterator mount_info = mount_info_map_.find(current); |
279 if (mount_info == mount_info_map_.end()) | 286 if (mount_info == mount_info_map_.end()) |
280 return false; | 287 return false; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 | 437 |
431 if (removable) { | 438 if (removable) { |
432 // TODO(gbillock) Do this in a higher level instead of here. | 439 // TODO(gbillock) Do this in a higher level instead of here. |
433 storage_info->name = MediaStorageUtil::GetDisplayNameForDevice( | 440 storage_info->name = MediaStorageUtil::GetDisplayNameForDevice( |
434 storage_info->total_size_in_bytes, storage_info->name); | 441 storage_info->total_size_in_bytes, storage_info->name); |
435 receiver()->ProcessAttach(*storage_info); | 442 receiver()->ProcessAttach(*storage_info); |
436 } | 443 } |
437 } | 444 } |
438 | 445 |
439 } // namespace chrome | 446 } // namespace chrome |
OLD | NEW |