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

Side by Side Diff: device/media_transfer_protocol/media_transfer_protocol_manager.cc

Issue 378263002: Devices: Remove MTP functions that use file paths. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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
« no previous file with comments | « device/media_transfer_protocol/media_transfer_protocol_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "device/media_transfer_protocol/media_transfer_protocol_manager.h" 5 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h"
6 6
7 #include <map> 7 #include <map>
8 #include <queue> 8 #include <queue>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 close_storage_callbacks_.push(std::make_pair(callback, storage_handle)); 142 close_storage_callbacks_.push(std::make_pair(callback, storage_handle));
143 mtp_client_->CloseStorage( 143 mtp_client_->CloseStorage(
144 storage_handle, 144 storage_handle,
145 base::Bind(&MediaTransferProtocolManagerImpl::OnCloseStorage, 145 base::Bind(&MediaTransferProtocolManagerImpl::OnCloseStorage,
146 weak_ptr_factory_.GetWeakPtr()), 146 weak_ptr_factory_.GetWeakPtr()),
147 base::Bind(&MediaTransferProtocolManagerImpl::OnCloseStorageError, 147 base::Bind(&MediaTransferProtocolManagerImpl::OnCloseStorageError,
148 weak_ptr_factory_.GetWeakPtr())); 148 weak_ptr_factory_.GetWeakPtr()));
149 } 149 }
150 150
151 // MediaTransferProtocolManager override. 151 // MediaTransferProtocolManager override.
152 virtual void ReadDirectoryByPath(
153 const std::string& storage_handle,
154 const std::string& path,
155 const ReadDirectoryCallback& callback) OVERRIDE {
156 DCHECK(thread_checker_.CalledOnValidThread());
157 if (!ContainsKey(handles_, storage_handle) || !mtp_client_) {
158 callback.Run(std::vector<MtpFileEntry>(), true);
159 return;
160 }
161 read_directory_callbacks_.push(callback);
162 mtp_client_->ReadDirectoryByPath(
163 storage_handle,
164 path,
165 base::Bind(&MediaTransferProtocolManagerImpl::OnReadDirectory,
166 weak_ptr_factory_.GetWeakPtr()),
167 base::Bind(&MediaTransferProtocolManagerImpl::OnReadDirectoryError,
168 weak_ptr_factory_.GetWeakPtr()));
169 }
170
171 // MediaTransferProtocolManager override.
172 virtual void ReadDirectoryById( 152 virtual void ReadDirectoryById(
173 const std::string& storage_handle, 153 const std::string& storage_handle,
174 uint32 file_id, 154 uint32 file_id,
175 const ReadDirectoryCallback& callback) OVERRIDE { 155 const ReadDirectoryCallback& callback) OVERRIDE {
176 DCHECK(thread_checker_.CalledOnValidThread()); 156 DCHECK(thread_checker_.CalledOnValidThread());
177 if (!ContainsKey(handles_, storage_handle) || !mtp_client_) { 157 if (!ContainsKey(handles_, storage_handle) || !mtp_client_) {
178 callback.Run(std::vector<MtpFileEntry>(), true); 158 callback.Run(std::vector<MtpFileEntry>(), true);
179 return; 159 return;
180 } 160 }
181 read_directory_callbacks_.push(callback); 161 read_directory_callbacks_.push(callback);
182 mtp_client_->ReadDirectoryById( 162 mtp_client_->ReadDirectoryById(
183 storage_handle, 163 storage_handle,
184 file_id, 164 file_id,
185 base::Bind(&MediaTransferProtocolManagerImpl::OnReadDirectory, 165 base::Bind(&MediaTransferProtocolManagerImpl::OnReadDirectory,
186 weak_ptr_factory_.GetWeakPtr()), 166 weak_ptr_factory_.GetWeakPtr()),
187 base::Bind(&MediaTransferProtocolManagerImpl::OnReadDirectoryError, 167 base::Bind(&MediaTransferProtocolManagerImpl::OnReadDirectoryError,
188 weak_ptr_factory_.GetWeakPtr())); 168 weak_ptr_factory_.GetWeakPtr()));
189 } 169 }
190 170
191 // MediaTransferProtocolManager override. 171 // MediaTransferProtocolManager override.
192 virtual void ReadFileChunkByPath(const std::string& storage_handle,
193 const std::string& path,
194 uint32 offset,
195 uint32 count,
196 const ReadFileCallback& callback) OVERRIDE {
197 DCHECK(thread_checker_.CalledOnValidThread());
198 if (!ContainsKey(handles_, storage_handle) || !mtp_client_) {
199 callback.Run(std::string(), true);
200 return;
201 }
202 read_file_callbacks_.push(callback);
203 mtp_client_->ReadFileChunkByPath(
204 storage_handle, path, offset, count,
205 base::Bind(&MediaTransferProtocolManagerImpl::OnReadFile,
206 weak_ptr_factory_.GetWeakPtr()),
207 base::Bind(&MediaTransferProtocolManagerImpl::OnReadFileError,
208 weak_ptr_factory_.GetWeakPtr()));
209 }
210
211 // MediaTransferProtocolManager override.
212 virtual void ReadFileChunkById(const std::string& storage_handle, 172 virtual void ReadFileChunkById(const std::string& storage_handle,
213 uint32 file_id, 173 uint32 file_id,
214 uint32 offset, 174 uint32 offset,
215 uint32 count, 175 uint32 count,
216 const ReadFileCallback& callback) OVERRIDE { 176 const ReadFileCallback& callback) OVERRIDE {
217 DCHECK(thread_checker_.CalledOnValidThread()); 177 DCHECK(thread_checker_.CalledOnValidThread());
218 if (!ContainsKey(handles_, storage_handle) || !mtp_client_) { 178 if (!ContainsKey(handles_, storage_handle) || !mtp_client_) {
219 callback.Run(std::string(), true); 179 callback.Run(std::string(), true);
220 return; 180 return;
221 } 181 }
222 read_file_callbacks_.push(callback); 182 read_file_callbacks_.push(callback);
223 mtp_client_->ReadFileChunkById( 183 mtp_client_->ReadFileChunkById(
224 storage_handle, file_id, offset, count, 184 storage_handle, file_id, offset, count,
225 base::Bind(&MediaTransferProtocolManagerImpl::OnReadFile, 185 base::Bind(&MediaTransferProtocolManagerImpl::OnReadFile,
226 weak_ptr_factory_.GetWeakPtr()), 186 weak_ptr_factory_.GetWeakPtr()),
227 base::Bind(&MediaTransferProtocolManagerImpl::OnReadFileError, 187 base::Bind(&MediaTransferProtocolManagerImpl::OnReadFileError,
228 weak_ptr_factory_.GetWeakPtr())); 188 weak_ptr_factory_.GetWeakPtr()));
229 } 189 }
230 190
231 virtual void GetFileInfoByPath(const std::string& storage_handle,
232 const std::string& path,
233 const GetFileInfoCallback& callback) OVERRIDE {
234 DCHECK(thread_checker_.CalledOnValidThread());
235 if (!ContainsKey(handles_, storage_handle) || !mtp_client_) {
236 callback.Run(MtpFileEntry(), true);
237 return;
238 }
239 get_file_info_callbacks_.push(callback);
240 mtp_client_->GetFileInfoByPath(
241 storage_handle,
242 path,
243 base::Bind(&MediaTransferProtocolManagerImpl::OnGetFileInfo,
244 weak_ptr_factory_.GetWeakPtr()),
245 base::Bind(&MediaTransferProtocolManagerImpl::OnGetFileInfoError,
246 weak_ptr_factory_.GetWeakPtr()));
247 }
248
249 virtual void GetFileInfoById(const std::string& storage_handle, 191 virtual void GetFileInfoById(const std::string& storage_handle,
250 uint32 file_id, 192 uint32 file_id,
251 const GetFileInfoCallback& callback) OVERRIDE { 193 const GetFileInfoCallback& callback) OVERRIDE {
252 DCHECK(thread_checker_.CalledOnValidThread()); 194 DCHECK(thread_checker_.CalledOnValidThread());
253 if (!ContainsKey(handles_, storage_handle) || !mtp_client_) { 195 if (!ContainsKey(handles_, storage_handle) || !mtp_client_) {
254 callback.Run(MtpFileEntry(), true); 196 callback.Run(MtpFileEntry(), true);
255 return; 197 return;
256 } 198 }
257 get_file_info_callbacks_.push(callback); 199 get_file_info_callbacks_.push(callback);
258 mtp_client_->GetFileInfoById( 200 mtp_client_->GetFileInfoById(
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 DCHECK(!g_media_transfer_protocol_manager); 453 DCHECK(!g_media_transfer_protocol_manager);
512 454
513 g_media_transfer_protocol_manager = 455 g_media_transfer_protocol_manager =
514 new MediaTransferProtocolManagerImpl(task_runner); 456 new MediaTransferProtocolManagerImpl(task_runner);
515 VLOG(1) << "MediaTransferProtocolManager initialized"; 457 VLOG(1) << "MediaTransferProtocolManager initialized";
516 458
517 return g_media_transfer_protocol_manager; 459 return g_media_transfer_protocol_manager;
518 } 460 }
519 461
520 } // namespace device 462 } // namespace device
OLDNEW
« no previous file with comments | « device/media_transfer_protocol/media_transfer_protocol_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698