Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: chrome/browser/media_galleries/linux/mtp_read_file_worker.cc

Issue 377383002: Media Galleries: Access MTP devices by file ids rather than file paths. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/linux/mtp_read_file_worker.h" 5 #include "chrome/browser/media_galleries/linux/mtp_read_file_worker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 scoped_ptr<SnapshotFileDetails> snapshot_file_details) { 59 scoped_ptr<SnapshotFileDetails> snapshot_file_details) {
60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
61 DCHECK(snapshot_file_details.get()); 61 DCHECK(snapshot_file_details.get());
62 62
63 // To avoid calling |snapshot_file_details| methods and passing ownership of 63 // To avoid calling |snapshot_file_details| methods and passing ownership of
64 // |snapshot_file_details| in the same_line. 64 // |snapshot_file_details| in the same_line.
65 SnapshotFileDetails* snapshot_file_details_ptr = snapshot_file_details.get(); 65 SnapshotFileDetails* snapshot_file_details_ptr = snapshot_file_details.get();
66 66
67 device::MediaTransferProtocolManager* mtp_device_manager = 67 device::MediaTransferProtocolManager* mtp_device_manager =
68 StorageMonitor::GetInstance()->media_transfer_protocol_manager(); 68 StorageMonitor::GetInstance()->media_transfer_protocol_manager();
69 mtp_device_manager->ReadFileChunkByPath( 69 mtp_device_manager->ReadFileChunkById(
70 device_handle_, 70 device_handle_,
71 snapshot_file_details_ptr->device_file_path(), 71 snapshot_file_details_ptr->file_id(),
72 snapshot_file_details_ptr->bytes_written(), 72 snapshot_file_details_ptr->bytes_written(),
73 snapshot_file_details_ptr->BytesToRead(), 73 snapshot_file_details_ptr->BytesToRead(),
74 base::Bind(&MTPReadFileWorker::OnDidReadDataChunkFromDeviceFile, 74 base::Bind(&MTPReadFileWorker::OnDidReadDataChunkFromDeviceFile,
75 weak_ptr_factory_.GetWeakPtr(), 75 weak_ptr_factory_.GetWeakPtr(),
76 base::Passed(&snapshot_file_details))); 76 base::Passed(&snapshot_file_details)));
77 } 77 }
78 78
79 void MTPReadFileWorker::OnDidReadDataChunkFromDeviceFile( 79 void MTPReadFileWorker::OnDidReadDataChunkFromDeviceFile(
80 scoped_ptr<SnapshotFileDetails> snapshot_file_details, 80 scoped_ptr<SnapshotFileDetails> snapshot_file_details,
81 const std::string& data, 81 const std::string& data,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 base::File::FILE_ERROR_FAILED)); 132 base::File::FILE_ERROR_FAILED));
133 return; 133 return;
134 } 134 }
135 content::BrowserThread::PostTask( 135 content::BrowserThread::PostTask(
136 content::BrowserThread::IO, 136 content::BrowserThread::IO,
137 FROM_HERE, 137 FROM_HERE,
138 base::Bind(snapshot_file_details->success_callback(), 138 base::Bind(snapshot_file_details->success_callback(),
139 snapshot_file_details->file_info(), 139 snapshot_file_details->file_info(),
140 snapshot_file_details->snapshot_file_path())); 140 snapshot_file_details->snapshot_file_path()));
141 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698