| 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 #include "chrome/browser/media_galleries/mac/mtp_device_delegate_impl_mac.h" | 5 #include "chrome/browser/media_galleries/mac/mtp_device_delegate_impl_mac.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| 11 #include "components/storage_monitor/image_capture_device.h" | 11 #include "components/storage_monitor/image_capture_device.h" |
| 12 #include "components/storage_monitor/image_capture_device_manager.h" | 12 #include "components/storage_monitor/image_capture_device_manager.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "webkit/browser/fileapi/async_file_util.h" | 14 #include "storage/browser/fileapi/async_file_util.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 int kReadDirectoryTimeLimitSeconds = 20; | 18 int kReadDirectoryTimeLimitSeconds = 20; |
| 19 | 19 |
| 20 typedef MTPDeviceAsyncDelegate::CreateSnapshotFileSuccessCallback | 20 typedef MTPDeviceAsyncDelegate::CreateSnapshotFileSuccessCallback |
| 21 CreateSnapshotFileSuccessCallback; | 21 CreateSnapshotFileSuccessCallback; |
| 22 typedef MTPDeviceAsyncDelegate::ErrorCallback ErrorCallback; | 22 typedef MTPDeviceAsyncDelegate::ErrorCallback ErrorCallback; |
| 23 typedef MTPDeviceAsyncDelegate::GetFileInfoSuccessCallback | 23 typedef MTPDeviceAsyncDelegate::GetFileInfoSuccessCallback |
| 24 GetFileInfoSuccessCallback; | 24 GetFileInfoSuccessCallback; |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 } | 363 } |
| 364 | 364 |
| 365 void MTPDeviceDelegateImplMac::NotifyReadDir() { | 365 void MTPDeviceDelegateImplMac::NotifyReadDir() { |
| 366 for (ReadDirTransactionList::iterator iter = read_dir_transactions_.begin(); | 366 for (ReadDirTransactionList::iterator iter = read_dir_transactions_.begin(); |
| 367 iter != read_dir_transactions_.end(); ++iter) { | 367 iter != read_dir_transactions_.end(); ++iter) { |
| 368 base::FilePath read_path = iter->directory; | 368 base::FilePath read_path = iter->directory; |
| 369 // This code assumes that the list of paths is sorted, so we skip to | 369 // This code assumes that the list of paths is sorted, so we skip to |
| 370 // where we find the entry for the directory, then read out all first-level | 370 // where we find the entry for the directory, then read out all first-level |
| 371 // children. We then break when the DirName is greater than the read_path, | 371 // children. We then break when the DirName is greater than the read_path, |
| 372 // as that means we've passed the subdir we're reading. | 372 // as that means we've passed the subdir we're reading. |
| 373 fileapi::AsyncFileUtil::EntryList entry_list; | 373 storage::AsyncFileUtil::EntryList entry_list; |
| 374 bool found_path = false; | 374 bool found_path = false; |
| 375 for (size_t i = 0; i < file_paths_.size(); ++i) { | 375 for (size_t i = 0; i < file_paths_.size(); ++i) { |
| 376 if (file_paths_[i] == read_path) { | 376 if (file_paths_[i] == read_path) { |
| 377 found_path = true; | 377 found_path = true; |
| 378 continue; | 378 continue; |
| 379 } | 379 } |
| 380 if (!read_path.IsParent(file_paths_[i])) { | 380 if (!read_path.IsParent(file_paths_[i])) { |
| 381 if (read_path < file_paths_[i].DirName()) | 381 if (read_path < file_paths_[i].DirName()) |
| 382 break; | 382 break; |
| 383 continue; | 383 continue; |
| 384 } | 384 } |
| 385 if (file_paths_[i].DirName() != read_path) | 385 if (file_paths_[i].DirName() != read_path) |
| 386 continue; | 386 continue; |
| 387 | 387 |
| 388 base::FilePath relative_path; | 388 base::FilePath relative_path; |
| 389 read_path.AppendRelativePath(file_paths_[i], &relative_path); | 389 read_path.AppendRelativePath(file_paths_[i], &relative_path); |
| 390 base::File::Info info = file_info_[file_paths_[i].value()]; | 390 base::File::Info info = file_info_[file_paths_[i].value()]; |
| 391 fileapi::DirectoryEntry entry; | 391 storage::DirectoryEntry entry; |
| 392 entry.name = relative_path.value(); | 392 entry.name = relative_path.value(); |
| 393 entry.is_directory = info.is_directory; | 393 entry.is_directory = info.is_directory; |
| 394 entry.size = info.size; | 394 entry.size = info.size; |
| 395 entry.last_modified_time = info.last_modified; | 395 entry.last_modified_time = info.last_modified; |
| 396 entry_list.push_back(entry); | 396 entry_list.push_back(entry); |
| 397 } | 397 } |
| 398 | 398 |
| 399 if (found_path) { | 399 if (found_path) { |
| 400 content::BrowserThread::PostTask(content::BrowserThread::IO, | 400 content::BrowserThread::PostTask(content::BrowserThread::IO, |
| 401 FROM_HERE, | 401 FROM_HERE, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 std::string device_name = base::FilePath(device_location).BaseName().value(); | 482 std::string device_name = base::FilePath(device_location).BaseName().value(); |
| 483 std::string device_id; | 483 std::string device_id; |
| 484 storage_monitor::StorageInfo::Type type; | 484 storage_monitor::StorageInfo::Type type; |
| 485 bool cracked = storage_monitor::StorageInfo::CrackDeviceId( | 485 bool cracked = storage_monitor::StorageInfo::CrackDeviceId( |
| 486 device_name, &type, &device_id); | 486 device_name, &type, &device_id); |
| 487 DCHECK(cracked); | 487 DCHECK(cracked); |
| 488 DCHECK_EQ(storage_monitor::StorageInfo::MAC_IMAGE_CAPTURE, type); | 488 DCHECK_EQ(storage_monitor::StorageInfo::MAC_IMAGE_CAPTURE, type); |
| 489 | 489 |
| 490 cb.Run(new MTPDeviceDelegateImplMac(device_id, device_location)); | 490 cb.Run(new MTPDeviceDelegateImplMac(device_id, device_location)); |
| 491 } | 491 } |
| OLD | NEW |