| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 // MTPDeviceDelegateImplWin implementation. | 5 // MTPDeviceDelegateImplWin implementation. |
| 6 | 6 |
| 7 #include "chrome/browser/media_galleries/win/mtp_device_delegate_impl_win.h" | 7 #include "chrome/browser/media_galleries/win/mtp_device_delegate_impl_win.h" |
| 8 | 8 |
| 9 #include <portabledevice.h> | 9 #include <portabledevice.h> |
| 10 | 10 |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 DCHECK(storage_object_id); | 308 DCHECK(storage_object_id); |
| 309 if (!succeeded) | 309 if (!succeeded) |
| 310 return; | 310 return; |
| 311 callback.Run(new MTPDeviceDelegateImplWin(device_location, | 311 callback.Run(new MTPDeviceDelegateImplWin(device_location, |
| 312 *pnp_device_id, | 312 *pnp_device_id, |
| 313 *storage_object_id)); | 313 *storage_object_id)); |
| 314 } | 314 } |
| 315 | 315 |
| 316 void CreateMTPDeviceAsyncDelegate( | 316 void CreateMTPDeviceAsyncDelegate( |
| 317 const base::string16& device_location, | 317 const base::string16& device_location, |
| 318 const bool read_only, |
| 318 const CreateMTPDeviceAsyncDelegateCallback& callback) { | 319 const CreateMTPDeviceAsyncDelegateCallback& callback) { |
| 319 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 320 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 321 |
| 322 // Write operation is not supported on Windows. |
| 323 DCHECK(read_only); |
| 324 |
| 320 DCHECK(!device_location.empty()); | 325 DCHECK(!device_location.empty()); |
| 321 base::string16* pnp_device_id = new base::string16; | 326 base::string16* pnp_device_id = new base::string16; |
| 322 base::string16* storage_object_id = new base::string16; | 327 base::string16* storage_object_id = new base::string16; |
| 323 content::BrowserThread::PostTaskAndReplyWithResult<bool>( | 328 content::BrowserThread::PostTaskAndReplyWithResult<bool>( |
| 324 content::BrowserThread::UI, | 329 content::BrowserThread::UI, |
| 325 FROM_HERE, | 330 FROM_HERE, |
| 326 base::Bind(&GetStorageInfoOnUIThread, | 331 base::Bind(&GetStorageInfoOnUIThread, |
| 327 device_location, | 332 device_location, |
| 328 base::Unretained(pnp_device_id), | 333 base::Unretained(pnp_device_id), |
| 329 base::Unretained(storage_object_id)), | 334 base::Unretained(storage_object_id)), |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 void MTPDeviceDelegateImplWin::ReadBytes( | 454 void MTPDeviceDelegateImplWin::ReadBytes( |
| 450 const base::FilePath& device_file_path, | 455 const base::FilePath& device_file_path, |
| 451 const scoped_refptr<net::IOBuffer>& buf, | 456 const scoped_refptr<net::IOBuffer>& buf, |
| 452 int64 offset, | 457 int64 offset, |
| 453 int buf_len, | 458 int buf_len, |
| 454 const ReadBytesSuccessCallback& success_callback, | 459 const ReadBytesSuccessCallback& success_callback, |
| 455 const ErrorCallback& error_callback) { | 460 const ErrorCallback& error_callback) { |
| 456 NOTREACHED(); | 461 NOTREACHED(); |
| 457 } | 462 } |
| 458 | 463 |
| 464 bool MTPDeviceDelegateImplWin::IsReadOnly() { |
| 465 return true; |
| 466 } |
| 467 |
| 468 void MTPDeviceDelegateImplWin::CopyFileFromLocal( |
| 469 const base::FilePath& source_file_path, |
| 470 const base::FilePath& device_file_path, |
| 471 const CopyFileFromLocalSuccessCallback& success_callback, |
| 472 const ErrorCallback& error_callback) { |
| 473 NOTREACHED(); |
| 474 } |
| 475 |
| 459 void MTPDeviceDelegateImplWin::CancelPendingTasksAndDeleteDelegate() { | 476 void MTPDeviceDelegateImplWin::CancelPendingTasksAndDeleteDelegate() { |
| 460 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 477 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 461 PortableDeviceMapService::GetInstance()->MarkPortableDeviceForDeletion( | 478 PortableDeviceMapService::GetInstance()->MarkPortableDeviceForDeletion( |
| 462 storage_device_info_.registered_device_path); | 479 storage_device_info_.registered_device_path); |
| 463 media_task_runner_->PostTask( | 480 media_task_runner_->PostTask( |
| 464 FROM_HERE, | 481 FROM_HERE, |
| 465 base::Bind(&DeletePortableDeviceOnBlockingPoolThread, | 482 base::Bind(&DeletePortableDeviceOnBlockingPoolThread, |
| 466 storage_device_info_.registered_device_path)); | 483 storage_device_info_.registered_device_path)); |
| 467 while (!pending_tasks_.empty()) | 484 while (!pending_tasks_.empty()) |
| 468 pending_tasks_.pop(); | 485 pending_tasks_.pop(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 current_snapshot_details_->file_info(), | 628 current_snapshot_details_->file_info(), |
| 612 current_snapshot_details_->request_info().snapshot_file_path); | 629 current_snapshot_details_->request_info().snapshot_file_path); |
| 613 } else { | 630 } else { |
| 614 current_snapshot_details_->request_info().error_callback.Run( | 631 current_snapshot_details_->request_info().error_callback.Run( |
| 615 base::File::FILE_ERROR_FAILED); | 632 base::File::FILE_ERROR_FAILED); |
| 616 } | 633 } |
| 617 task_in_progress_ = false; | 634 task_in_progress_ = false; |
| 618 current_snapshot_details_.reset(); | 635 current_snapshot_details_.reset(); |
| 619 ProcessNextPendingRequest(); | 636 ProcessNextPendingRequest(); |
| 620 } | 637 } |
| OLD | NEW |