| 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" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 : delegate_(delegate) {} | 40 : delegate_(delegate) {} |
| 41 virtual ~DeviceListener() {} | 41 virtual ~DeviceListener() {} |
| 42 | 42 |
| 43 void OpenCameraSession(const std::string& device_id); | 43 void OpenCameraSession(const std::string& device_id); |
| 44 void CloseCameraSessionAndDelete(); | 44 void CloseCameraSessionAndDelete(); |
| 45 | 45 |
| 46 void DownloadFile(const std::string& name, const base::FilePath& local_path); | 46 void DownloadFile(const std::string& name, const base::FilePath& local_path); |
| 47 | 47 |
| 48 // ImageCaptureDeviceListener | 48 // ImageCaptureDeviceListener |
| 49 virtual void ItemAdded(const std::string& name, | 49 virtual void ItemAdded(const std::string& name, |
| 50 const base::PlatformFileInfo& info) OVERRIDE; | 50 const base::File::Info& info) OVERRIDE; |
| 51 virtual void NoMoreItems() OVERRIDE; | 51 virtual void NoMoreItems() OVERRIDE; |
| 52 virtual void DownloadedFile(const std::string& name, | 52 virtual void DownloadedFile(const std::string& name, |
| 53 base::PlatformFileError error) OVERRIDE; | 53 base::File::Error error) OVERRIDE; |
| 54 virtual void DeviceRemoved() OVERRIDE; | 54 virtual void DeviceRemoved() OVERRIDE; |
| 55 | 55 |
| 56 // Used during delegate destruction to ensure there are no more calls | 56 // Used during delegate destruction to ensure there are no more calls |
| 57 // to the delegate by the listener. | 57 // to the delegate by the listener. |
| 58 virtual void ResetDelegate(); | 58 virtual void ResetDelegate(); |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 base::scoped_nsobject<ImageCaptureDevice> camera_device_; | 61 base::scoped_nsobject<ImageCaptureDevice> camera_device_; |
| 62 | 62 |
| 63 // Weak pointer | 63 // Weak pointer |
| (...skipping 18 matching lines...) Expand all Loading... |
| 82 } | 82 } |
| 83 | 83 |
| 84 void MTPDeviceDelegateImplMac::DeviceListener::DownloadFile( | 84 void MTPDeviceDelegateImplMac::DeviceListener::DownloadFile( |
| 85 const std::string& name, | 85 const std::string& name, |
| 86 const base::FilePath& local_path) { | 86 const base::FilePath& local_path) { |
| 87 [camera_device_ downloadFile:name localPath:local_path]; | 87 [camera_device_ downloadFile:name localPath:local_path]; |
| 88 } | 88 } |
| 89 | 89 |
| 90 void MTPDeviceDelegateImplMac::DeviceListener::ItemAdded( | 90 void MTPDeviceDelegateImplMac::DeviceListener::ItemAdded( |
| 91 const std::string& name, | 91 const std::string& name, |
| 92 const base::PlatformFileInfo& info) { | 92 const base::File::Info& info) { |
| 93 if (delegate_) | 93 if (delegate_) |
| 94 delegate_->ItemAdded(name, info); | 94 delegate_->ItemAdded(name, info); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void MTPDeviceDelegateImplMac::DeviceListener::NoMoreItems() { | 97 void MTPDeviceDelegateImplMac::DeviceListener::NoMoreItems() { |
| 98 if (delegate_) | 98 if (delegate_) |
| 99 delegate_->NoMoreItems(); | 99 delegate_->NoMoreItems(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void MTPDeviceDelegateImplMac::DeviceListener::DownloadedFile( | 102 void MTPDeviceDelegateImplMac::DeviceListener::DownloadedFile( |
| 103 const std::string& name, | 103 const std::string& name, |
| 104 base::PlatformFileError error) { | 104 base::File::Error error) { |
| 105 if (delegate_) | 105 if (delegate_) |
| 106 delegate_->DownloadedFile(name, error); | 106 delegate_->DownloadedFile(name, error); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void MTPDeviceDelegateImplMac::DeviceListener::DeviceRemoved() { | 109 void MTPDeviceDelegateImplMac::DeviceListener::DeviceRemoved() { |
| 110 [camera_device_ close]; | 110 [camera_device_ close]; |
| 111 camera_device_.reset(); | 111 camera_device_.reset(); |
| 112 if (delegate_) | 112 if (delegate_) |
| 113 delegate_->NoMoreItems(); | 113 delegate_->NoMoreItems(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void MTPDeviceDelegateImplMac::DeviceListener::ResetDelegate() { | 116 void MTPDeviceDelegateImplMac::DeviceListener::ResetDelegate() { |
| 117 delegate_ = NULL; | 117 delegate_ = NULL; |
| 118 } | 118 } |
| 119 | 119 |
| 120 MTPDeviceDelegateImplMac::MTPDeviceDelegateImplMac( | 120 MTPDeviceDelegateImplMac::MTPDeviceDelegateImplMac( |
| 121 const std::string& device_id, | 121 const std::string& device_id, |
| 122 const base::FilePath::StringType& synthetic_path) | 122 const base::FilePath::StringType& synthetic_path) |
| 123 : device_id_(device_id), | 123 : device_id_(device_id), |
| 124 root_path_(synthetic_path), | 124 root_path_(synthetic_path), |
| 125 received_all_files_(false), | 125 received_all_files_(false), |
| 126 weak_factory_(this) { | 126 weak_factory_(this) { |
| 127 | 127 |
| 128 // Make a synthetic entry for the root of the filesystem. | 128 // Make a synthetic entry for the root of the filesystem. |
| 129 base::PlatformFileInfo info; | 129 base::File::Info info; |
| 130 info.is_directory = true; | 130 info.is_directory = true; |
| 131 file_paths_.push_back(root_path_); | 131 file_paths_.push_back(root_path_); |
| 132 file_info_[root_path_.value()] = info; | 132 file_info_[root_path_.value()] = info; |
| 133 | 133 |
| 134 camera_interface_.reset(new DeviceListener(this)); | 134 camera_interface_.reset(new DeviceListener(this)); |
| 135 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 135 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| 136 base::Bind(&DeviceListener::OpenCameraSession, | 136 base::Bind(&DeviceListener::OpenCameraSession, |
| 137 base::Unretained(camera_interface_.get()), | 137 base::Unretained(camera_interface_.get()), |
| 138 device_id_)); | 138 device_id_)); |
| 139 } | 139 } |
| 140 | 140 |
| 141 MTPDeviceDelegateImplMac::~MTPDeviceDelegateImplMac() { | 141 MTPDeviceDelegateImplMac::~MTPDeviceDelegateImplMac() { |
| 142 } | 142 } |
| 143 | 143 |
| 144 namespace { | 144 namespace { |
| 145 | 145 |
| 146 void ForwardGetFileInfo( | 146 void ForwardGetFileInfo( |
| 147 base::PlatformFileInfo* info, | 147 base::File::Info* info, |
| 148 base::PlatformFileError* error, | 148 base::File::Error* error, |
| 149 const GetFileInfoSuccessCallback& success_callback, | 149 const GetFileInfoSuccessCallback& success_callback, |
| 150 const ErrorCallback& error_callback) { | 150 const ErrorCallback& error_callback) { |
| 151 if (*error == base::PLATFORM_FILE_OK) | 151 if (*error == base::File::FILE_OK) |
| 152 success_callback.Run(*info); | 152 success_callback.Run(*info); |
| 153 else | 153 else |
| 154 error_callback.Run(*error); | 154 error_callback.Run(*error); |
| 155 } | 155 } |
| 156 | 156 |
| 157 } // namespace | 157 } // namespace |
| 158 | 158 |
| 159 void MTPDeviceDelegateImplMac::GetFileInfo( | 159 void MTPDeviceDelegateImplMac::GetFileInfo( |
| 160 const base::FilePath& file_path, | 160 const base::FilePath& file_path, |
| 161 const GetFileInfoSuccessCallback& success_callback, | 161 const GetFileInfoSuccessCallback& success_callback, |
| 162 const ErrorCallback& error_callback) { | 162 const ErrorCallback& error_callback) { |
| 163 base::PlatformFileInfo* info = new base::PlatformFileInfo; | 163 base::File::Info* info = new base::File::Info; |
| 164 base::PlatformFileError* error = new base::PlatformFileError; | 164 base::File::Error* error = new base::File::Error; |
| 165 // Note: ownership of these objects passed into the reply callback. | 165 // Note: ownership of these objects passed into the reply callback. |
| 166 content::BrowserThread::PostTaskAndReply(content::BrowserThread::UI, | 166 content::BrowserThread::PostTaskAndReply(content::BrowserThread::UI, |
| 167 FROM_HERE, | 167 FROM_HERE, |
| 168 base::Bind(&MTPDeviceDelegateImplMac::GetFileInfoImpl, | 168 base::Bind(&MTPDeviceDelegateImplMac::GetFileInfoImpl, |
| 169 base::Unretained(this), file_path, info, error), | 169 base::Unretained(this), file_path, info, error), |
| 170 base::Bind(&ForwardGetFileInfo, | 170 base::Bind(&ForwardGetFileInfo, |
| 171 base::Owned(info), base::Owned(error), | 171 base::Owned(info), base::Owned(error), |
| 172 success_callback, error_callback)); | 172 success_callback, error_callback)); |
| 173 } | 173 } |
| 174 | 174 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 195 } | 195 } |
| 196 | 196 |
| 197 void MTPDeviceDelegateImplMac::CancelPendingTasksAndDeleteDelegate() { | 197 void MTPDeviceDelegateImplMac::CancelPendingTasksAndDeleteDelegate() { |
| 198 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 198 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| 199 base::Bind(&MTPDeviceDelegateImplMac::CancelAndDelete, | 199 base::Bind(&MTPDeviceDelegateImplMac::CancelAndDelete, |
| 200 base::Unretained(this))); | 200 base::Unretained(this))); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void MTPDeviceDelegateImplMac::GetFileInfoImpl( | 203 void MTPDeviceDelegateImplMac::GetFileInfoImpl( |
| 204 const base::FilePath& file_path, | 204 const base::FilePath& file_path, |
| 205 base::PlatformFileInfo* file_info, | 205 base::File::Info* file_info, |
| 206 base::PlatformFileError* error) { | 206 base::File::Error* error) { |
| 207 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 207 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 208 base::hash_map<base::FilePath::StringType, | 208 base::hash_map<base::FilePath::StringType, |
| 209 base::PlatformFileInfo>::const_iterator i = | 209 base::File::Info>::const_iterator i = |
| 210 file_info_.find(file_path.value()); | 210 file_info_.find(file_path.value()); |
| 211 if (i == file_info_.end()) { | 211 if (i == file_info_.end()) { |
| 212 *error = base::PLATFORM_FILE_ERROR_NOT_FOUND; | 212 *error = base::File::FILE_ERROR_NOT_FOUND; |
| 213 return; | 213 return; |
| 214 } | 214 } |
| 215 *file_info = i->second; | 215 *file_info = i->second; |
| 216 *error = base::PLATFORM_FILE_OK; | 216 *error = base::File::FILE_OK; |
| 217 } | 217 } |
| 218 | 218 |
| 219 void MTPDeviceDelegateImplMac::ReadDirectoryImpl( | 219 void MTPDeviceDelegateImplMac::ReadDirectoryImpl( |
| 220 const base::FilePath& root, | 220 const base::FilePath& root, |
| 221 const ReadDirectorySuccessCallback& success_callback, | 221 const ReadDirectorySuccessCallback& success_callback, |
| 222 const ErrorCallback& error_callback) { | 222 const ErrorCallback& error_callback) { |
| 223 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 223 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 224 | 224 |
| 225 read_dir_transactions_.push_back(ReadDirectoryRequest( | 225 read_dir_transactions_.push_back(ReadDirectoryRequest( |
| 226 root, success_callback, error_callback)); | 226 root, success_callback, error_callback)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 242 const base::FilePath& root) { | 242 const base::FilePath& root) { |
| 243 if (received_all_files_) | 243 if (received_all_files_) |
| 244 return; | 244 return; |
| 245 | 245 |
| 246 for (ReadDirTransactionList::iterator iter = read_dir_transactions_.begin(); | 246 for (ReadDirTransactionList::iterator iter = read_dir_transactions_.begin(); |
| 247 iter != read_dir_transactions_.end();) { | 247 iter != read_dir_transactions_.end();) { |
| 248 if (iter->directory != root) { | 248 if (iter->directory != root) { |
| 249 iter++; | 249 iter++; |
| 250 continue; | 250 continue; |
| 251 } | 251 } |
| 252 iter->error_callback.Run(base::PLATFORM_FILE_ERROR_ABORT); | 252 iter->error_callback.Run(base::File::FILE_ERROR_ABORT); |
| 253 iter = read_dir_transactions_.erase(iter); | 253 iter = read_dir_transactions_.erase(iter); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 | 256 |
| 257 void MTPDeviceDelegateImplMac::DownloadFile( | 257 void MTPDeviceDelegateImplMac::DownloadFile( |
| 258 const base::FilePath& device_file_path, | 258 const base::FilePath& device_file_path, |
| 259 const base::FilePath& local_path, | 259 const base::FilePath& local_path, |
| 260 const CreateSnapshotFileSuccessCallback& success_callback, | 260 const CreateSnapshotFileSuccessCallback& success_callback, |
| 261 const ErrorCallback& error_callback) { | 261 const ErrorCallback& error_callback) { |
| 262 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 262 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 263 | 263 |
| 264 base::PlatformFileError error; | 264 base::File::Error error; |
| 265 base::PlatformFileInfo info; | 265 base::File::Info info; |
| 266 GetFileInfoImpl(device_file_path, &info, &error); | 266 GetFileInfoImpl(device_file_path, &info, &error); |
| 267 if (error != base::PLATFORM_FILE_OK) { | 267 if (error != base::File::FILE_OK) { |
| 268 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | 268 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
| 269 base::Bind(error_callback, | 269 base::Bind(error_callback, |
| 270 error)); | 270 error)); |
| 271 return; | 271 return; |
| 272 } | 272 } |
| 273 | 273 |
| 274 base::FilePath relative_path; | 274 base::FilePath relative_path; |
| 275 root_path_.AppendRelativePath(device_file_path, &relative_path); | 275 root_path_.AppendRelativePath(device_file_path, &relative_path); |
| 276 | 276 |
| 277 read_file_transactions_.push_back( | 277 read_file_transactions_.push_back( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 298 | 298 |
| 299 delete this; | 299 delete this; |
| 300 } | 300 } |
| 301 | 301 |
| 302 void MTPDeviceDelegateImplMac::CancelDownloads() { | 302 void MTPDeviceDelegateImplMac::CancelDownloads() { |
| 303 // Cancel any outstanding callbacks. | 303 // Cancel any outstanding callbacks. |
| 304 for (ReadFileTransactionList::iterator iter = read_file_transactions_.begin(); | 304 for (ReadFileTransactionList::iterator iter = read_file_transactions_.begin(); |
| 305 iter != read_file_transactions_.end(); ++iter) { | 305 iter != read_file_transactions_.end(); ++iter) { |
| 306 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | 306 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
| 307 base::Bind(iter->error_callback, | 307 base::Bind(iter->error_callback, |
| 308 base::PLATFORM_FILE_ERROR_ABORT)); | 308 base::File::FILE_ERROR_ABORT)); |
| 309 } | 309 } |
| 310 read_file_transactions_.clear(); | 310 read_file_transactions_.clear(); |
| 311 | 311 |
| 312 for (ReadDirTransactionList::iterator iter = read_dir_transactions_.begin(); | 312 for (ReadDirTransactionList::iterator iter = read_dir_transactions_.begin(); |
| 313 iter != read_dir_transactions_.end(); ++iter) { | 313 iter != read_dir_transactions_.end(); ++iter) { |
| 314 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | 314 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
| 315 base::Bind(iter->error_callback, base::PLATFORM_FILE_ERROR_ABORT)); | 315 base::Bind(iter->error_callback, base::File::FILE_ERROR_ABORT)); |
| 316 } | 316 } |
| 317 read_dir_transactions_.clear(); | 317 read_dir_transactions_.clear(); |
| 318 } | 318 } |
| 319 | 319 |
| 320 // Called on the UI thread by the listener | 320 // Called on the UI thread by the listener |
| 321 void MTPDeviceDelegateImplMac::ItemAdded( | 321 void MTPDeviceDelegateImplMac::ItemAdded( |
| 322 const std::string& name, const base::PlatformFileInfo& info) { | 322 const std::string& name, const base::File::Info& info) { |
| 323 if (received_all_files_) | 323 if (received_all_files_) |
| 324 return; | 324 return; |
| 325 | 325 |
| 326 // This kinda should go in a Join method in FilePath... | 326 // This kinda should go in a Join method in FilePath... |
| 327 base::FilePath relative_path(name); | 327 base::FilePath relative_path(name); |
| 328 std::vector<base::FilePath::StringType> components; | 328 std::vector<base::FilePath::StringType> components; |
| 329 relative_path.GetComponents(&components); | 329 relative_path.GetComponents(&components); |
| 330 base::FilePath item_filename = root_path_; | 330 base::FilePath item_filename = root_path_; |
| 331 for (std::vector<base::FilePath::StringType>::iterator iter = | 331 for (std::vector<base::FilePath::StringType>::iterator iter = |
| 332 components.begin(); | 332 components.begin(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 if (!read_path.IsParent(file_paths_[i])) { | 367 if (!read_path.IsParent(file_paths_[i])) { |
| 368 if (read_path < file_paths_[i].DirName()) | 368 if (read_path < file_paths_[i].DirName()) |
| 369 break; | 369 break; |
| 370 continue; | 370 continue; |
| 371 } | 371 } |
| 372 if (file_paths_[i].DirName() != read_path) | 372 if (file_paths_[i].DirName() != read_path) |
| 373 continue; | 373 continue; |
| 374 | 374 |
| 375 base::FilePath relative_path; | 375 base::FilePath relative_path; |
| 376 read_path.AppendRelativePath(file_paths_[i], &relative_path); | 376 read_path.AppendRelativePath(file_paths_[i], &relative_path); |
| 377 base::PlatformFileInfo info = file_info_[file_paths_[i].value()]; | 377 base::File::Info info = file_info_[file_paths_[i].value()]; |
| 378 fileapi::DirectoryEntry entry; | 378 fileapi::DirectoryEntry entry; |
| 379 entry.name = relative_path.value(); | 379 entry.name = relative_path.value(); |
| 380 entry.is_directory = info.is_directory; | 380 entry.is_directory = info.is_directory; |
| 381 entry.size = info.size; | 381 entry.size = info.size; |
| 382 entry.last_modified_time = info.last_modified; | 382 entry.last_modified_time = info.last_modified; |
| 383 entry_list.push_back(entry); | 383 entry_list.push_back(entry); |
| 384 } | 384 } |
| 385 | 385 |
| 386 if (found_path) { | 386 if (found_path) { |
| 387 content::BrowserThread::PostTask(content::BrowserThread::IO, | 387 content::BrowserThread::PostTask(content::BrowserThread::IO, |
| 388 FROM_HERE, | 388 FROM_HERE, |
| 389 base::Bind(iter->success_callback, entry_list, false)); | 389 base::Bind(iter->success_callback, entry_list, false)); |
| 390 } else { | 390 } else { |
| 391 content::BrowserThread::PostTask(content::BrowserThread::IO, | 391 content::BrowserThread::PostTask(content::BrowserThread::IO, |
| 392 FROM_HERE, | 392 FROM_HERE, |
| 393 base::Bind(iter->error_callback, | 393 base::Bind(iter->error_callback, |
| 394 base::PLATFORM_FILE_ERROR_NOT_FOUND)); | 394 base::File::FILE_ERROR_NOT_FOUND)); |
| 395 } | 395 } |
| 396 } | 396 } |
| 397 | 397 |
| 398 read_dir_transactions_.clear(); | 398 read_dir_transactions_.clear(); |
| 399 } | 399 } |
| 400 | 400 |
| 401 // Invoked on UI thread from the listener. | 401 // Invoked on UI thread from the listener. |
| 402 void MTPDeviceDelegateImplMac::DownloadedFile( | 402 void MTPDeviceDelegateImplMac::DownloadedFile( |
| 403 const std::string& name, base::PlatformFileError error) { | 403 const std::string& name, base::File::Error error) { |
| 404 // If we're cancelled and deleting, we may have deleted the camera. | 404 // If we're cancelled and deleting, we may have deleted the camera. |
| 405 if (!camera_interface_.get()) | 405 if (!camera_interface_.get()) |
| 406 return; | 406 return; |
| 407 | 407 |
| 408 bool found = false; | 408 bool found = false; |
| 409 ReadFileTransactionList::iterator iter = read_file_transactions_.begin(); | 409 ReadFileTransactionList::iterator iter = read_file_transactions_.begin(); |
| 410 for (; iter != read_file_transactions_.end(); ++iter) { | 410 for (; iter != read_file_transactions_.end(); ++iter) { |
| 411 if (iter->request_file == name) { | 411 if (iter->request_file == name) { |
| 412 found = true; | 412 found = true; |
| 413 break; | 413 break; |
| 414 } | 414 } |
| 415 } | 415 } |
| 416 if (!found) | 416 if (!found) |
| 417 return; | 417 return; |
| 418 | 418 |
| 419 if (error != base::PLATFORM_FILE_OK) { | 419 if (error != base::File::FILE_OK) { |
| 420 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | 420 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
| 421 base::Bind(iter->error_callback, error)); | 421 base::Bind(iter->error_callback, error)); |
| 422 read_file_transactions_.erase(iter); | 422 read_file_transactions_.erase(iter); |
| 423 return; | 423 return; |
| 424 } | 424 } |
| 425 | 425 |
| 426 base::FilePath relative_path(name); | 426 base::FilePath relative_path(name); |
| 427 std::vector<base::FilePath::StringType> components; | 427 std::vector<base::FilePath::StringType> components; |
| 428 relative_path.GetComponents(&components); | 428 relative_path.GetComponents(&components); |
| 429 base::FilePath item_filename = root_path_; | 429 base::FilePath item_filename = root_path_; |
| 430 for (std::vector<base::FilePath::StringType>::iterator i = | 430 for (std::vector<base::FilePath::StringType>::iterator i = |
| 431 components.begin(); | 431 components.begin(); |
| 432 i != components.end(); ++i) { | 432 i != components.end(); ++i) { |
| 433 item_filename = item_filename.Append(*i); | 433 item_filename = item_filename.Append(*i); |
| 434 } | 434 } |
| 435 | 435 |
| 436 base::PlatformFileInfo info = file_info_[item_filename.value()]; | 436 base::File::Info info = file_info_[item_filename.value()]; |
| 437 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | 437 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
| 438 base::Bind(iter->success_callback, info, iter->snapshot_file)); | 438 base::Bind(iter->success_callback, info, iter->snapshot_file)); |
| 439 read_file_transactions_.erase(iter); | 439 read_file_transactions_.erase(iter); |
| 440 } | 440 } |
| 441 | 441 |
| 442 MTPDeviceDelegateImplMac::ReadFileRequest::ReadFileRequest( | 442 MTPDeviceDelegateImplMac::ReadFileRequest::ReadFileRequest( |
| 443 const std::string& file, | 443 const std::string& file, |
| 444 const base::FilePath& snapshot_filename, | 444 const base::FilePath& snapshot_filename, |
| 445 CreateSnapshotFileSuccessCallback success_cb, | 445 CreateSnapshotFileSuccessCallback success_cb, |
| 446 ErrorCallback error_cb) | 446 ErrorCallback error_cb) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 468 const CreateMTPDeviceAsyncDelegateCallback& cb) { | 468 const CreateMTPDeviceAsyncDelegateCallback& cb) { |
| 469 std::string device_name = base::FilePath(device_location).BaseName().value(); | 469 std::string device_name = base::FilePath(device_location).BaseName().value(); |
| 470 std::string device_id; | 470 std::string device_id; |
| 471 StorageInfo::Type type; | 471 StorageInfo::Type type; |
| 472 bool cracked = StorageInfo::CrackDeviceId(device_name, &type, &device_id); | 472 bool cracked = StorageInfo::CrackDeviceId(device_name, &type, &device_id); |
| 473 DCHECK(cracked); | 473 DCHECK(cracked); |
| 474 DCHECK_EQ(StorageInfo::MAC_IMAGE_CAPTURE, type); | 474 DCHECK_EQ(StorageInfo::MAC_IMAGE_CAPTURE, type); |
| 475 | 475 |
| 476 cb.Run(new MTPDeviceDelegateImplMac(device_id, device_location)); | 476 cb.Run(new MTPDeviceDelegateImplMac(device_id, device_location)); |
| 477 } | 477 } |
| OLD | NEW |