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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 } | 207 } |
208 | 208 |
209 void MTPDeviceDelegateImplMac::CancelPendingTasksAndDeleteDelegate() { | 209 void MTPDeviceDelegateImplMac::CancelPendingTasksAndDeleteDelegate() { |
210 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 210 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
211 base::Bind(&MTPDeviceDelegateImplMac::CancelAndDelete, | 211 base::Bind(&MTPDeviceDelegateImplMac::CancelAndDelete, |
212 base::Unretained(this))); | 212 base::Unretained(this))); |
213 } | 213 } |
214 | 214 |
215 void MTPDeviceDelegateImplMac::GetFileInfoImpl( | 215 void MTPDeviceDelegateImplMac::GetFileInfoImpl( |
216 const base::FilePath& file_path, | 216 const base::FilePath& file_path, |
217 base::PlatformFileInfo* file_info, | 217 base::File::Info* file_info, |
218 base::PlatformFileError* error) { | 218 base::File::Error* error) { |
219 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 219 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
220 base::hash_map<base::FilePath::StringType, | 220 base::hash_map<base::FilePath::StringType, |
221 base::PlatformFileInfo>::const_iterator i = | 221 base::File::Info>::const_iterator i = |
222 file_info_.find(file_path.value()); | 222 file_info_.find(file_path.value()); |
223 if (i == file_info_.end()) { | 223 if (i == file_info_.end()) { |
224 *error = base::PLATFORM_FILE_ERROR_NOT_FOUND; | 224 *error = base::File::FILE_ERROR_NOT_FOUND; |
225 return; | 225 return; |
226 } | 226 } |
227 *file_info = i->second; | 227 *file_info = i->second; |
228 *error = base::PLATFORM_FILE_OK; | 228 *error = base::File::FILE_OK; |
229 } | 229 } |
230 | 230 |
231 void MTPDeviceDelegateImplMac::ReadDirectoryImpl( | 231 void MTPDeviceDelegateImplMac::ReadDirectoryImpl( |
232 const base::FilePath& root, | 232 const base::FilePath& root, |
233 const ReadDirectorySuccessCallback& success_callback, | 233 const ReadDirectorySuccessCallback& success_callback, |
234 const ErrorCallback& error_callback) { | 234 const ErrorCallback& error_callback) { |
235 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 235 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
236 | 236 |
237 read_dir_transactions_.push_back(ReadDirectoryRequest( | 237 read_dir_transactions_.push_back(ReadDirectoryRequest( |
238 root, success_callback, error_callback)); | 238 root, success_callback, error_callback)); |
(...skipping 15 matching lines...) Expand all Loading... |
254 const base::FilePath& root) { | 254 const base::FilePath& root) { |
255 if (received_all_files_) | 255 if (received_all_files_) |
256 return; | 256 return; |
257 | 257 |
258 for (ReadDirTransactionList::iterator iter = read_dir_transactions_.begin(); | 258 for (ReadDirTransactionList::iterator iter = read_dir_transactions_.begin(); |
259 iter != read_dir_transactions_.end();) { | 259 iter != read_dir_transactions_.end();) { |
260 if (iter->directory != root) { | 260 if (iter->directory != root) { |
261 iter++; | 261 iter++; |
262 continue; | 262 continue; |
263 } | 263 } |
264 iter->error_callback.Run(base::PLATFORM_FILE_ERROR_ABORT); | 264 iter->error_callback.Run(base::File::FILE_ERROR_ABORT); |
265 iter = read_dir_transactions_.erase(iter); | 265 iter = read_dir_transactions_.erase(iter); |
266 } | 266 } |
267 } | 267 } |
268 | 268 |
269 void MTPDeviceDelegateImplMac::DownloadFile( | 269 void MTPDeviceDelegateImplMac::DownloadFile( |
270 const base::FilePath& device_file_path, | 270 const base::FilePath& device_file_path, |
271 const base::FilePath& local_path, | 271 const base::FilePath& local_path, |
272 const CreateSnapshotFileSuccessCallback& success_callback, | 272 const CreateSnapshotFileSuccessCallback& success_callback, |
273 const ErrorCallback& error_callback) { | 273 const ErrorCallback& error_callback) { |
274 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 274 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
275 | 275 |
276 base::PlatformFileError error; | 276 base::File::Error error; |
277 base::PlatformFileInfo info; | 277 base::File::Info info; |
278 GetFileInfoImpl(device_file_path, &info, &error); | 278 GetFileInfoImpl(device_file_path, &info, &error); |
279 if (error != base::PLATFORM_FILE_OK) { | 279 if (error != base::File::FILE_OK) { |
280 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | 280 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
281 base::Bind(error_callback, | 281 base::Bind(error_callback, |
282 error)); | 282 error)); |
283 return; | 283 return; |
284 } | 284 } |
285 | 285 |
286 base::FilePath relative_path; | 286 base::FilePath relative_path; |
287 root_path_.AppendRelativePath(device_file_path, &relative_path); | 287 root_path_.AppendRelativePath(device_file_path, &relative_path); |
288 | 288 |
289 read_file_transactions_.push_back( | 289 read_file_transactions_.push_back( |
(...skipping 20 matching lines...) Expand all Loading... |
310 | 310 |
311 delete this; | 311 delete this; |
312 } | 312 } |
313 | 313 |
314 void MTPDeviceDelegateImplMac::CancelDownloads() { | 314 void MTPDeviceDelegateImplMac::CancelDownloads() { |
315 // Cancel any outstanding callbacks. | 315 // Cancel any outstanding callbacks. |
316 for (ReadFileTransactionList::iterator iter = read_file_transactions_.begin(); | 316 for (ReadFileTransactionList::iterator iter = read_file_transactions_.begin(); |
317 iter != read_file_transactions_.end(); ++iter) { | 317 iter != read_file_transactions_.end(); ++iter) { |
318 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | 318 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
319 base::Bind(iter->error_callback, | 319 base::Bind(iter->error_callback, |
320 base::PLATFORM_FILE_ERROR_ABORT)); | 320 base::File::FILE_ERROR_ABORT)); |
321 } | 321 } |
322 read_file_transactions_.clear(); | 322 read_file_transactions_.clear(); |
323 | 323 |
324 for (ReadDirTransactionList::iterator iter = read_dir_transactions_.begin(); | 324 for (ReadDirTransactionList::iterator iter = read_dir_transactions_.begin(); |
325 iter != read_dir_transactions_.end(); ++iter) { | 325 iter != read_dir_transactions_.end(); ++iter) { |
326 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | 326 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
327 base::Bind(iter->error_callback, base::PLATFORM_FILE_ERROR_ABORT)); | 327 base::Bind(iter->error_callback, base::File::FILE_ERROR_ABORT)); |
328 } | 328 } |
329 read_dir_transactions_.clear(); | 329 read_dir_transactions_.clear(); |
330 } | 330 } |
331 | 331 |
332 // Called on the UI thread by the listener | 332 // Called on the UI thread by the listener |
333 void MTPDeviceDelegateImplMac::ItemAdded( | 333 void MTPDeviceDelegateImplMac::ItemAdded( |
334 const std::string& name, const base::PlatformFileInfo& info) { | 334 const std::string& name, const base::File::Info& info) { |
335 if (received_all_files_) | 335 if (received_all_files_) |
336 return; | 336 return; |
337 | 337 |
338 // This kinda should go in a Join method in FilePath... | 338 // This kinda should go in a Join method in FilePath... |
339 base::FilePath relative_path(name); | 339 base::FilePath relative_path(name); |
340 std::vector<base::FilePath::StringType> components; | 340 std::vector<base::FilePath::StringType> components; |
341 relative_path.GetComponents(&components); | 341 relative_path.GetComponents(&components); |
342 base::FilePath item_filename = root_path_; | 342 base::FilePath item_filename = root_path_; |
343 for (std::vector<base::FilePath::StringType>::iterator iter = | 343 for (std::vector<base::FilePath::StringType>::iterator iter = |
344 components.begin(); | 344 components.begin(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 if (!read_path.IsParent(file_paths_[i])) { | 379 if (!read_path.IsParent(file_paths_[i])) { |
380 if (read_path < file_paths_[i].DirName()) | 380 if (read_path < file_paths_[i].DirName()) |
381 break; | 381 break; |
382 continue; | 382 continue; |
383 } | 383 } |
384 if (file_paths_[i].DirName() != read_path) | 384 if (file_paths_[i].DirName() != read_path) |
385 continue; | 385 continue; |
386 | 386 |
387 base::FilePath relative_path; | 387 base::FilePath relative_path; |
388 read_path.AppendRelativePath(file_paths_[i], &relative_path); | 388 read_path.AppendRelativePath(file_paths_[i], &relative_path); |
389 base::PlatformFileInfo info = file_info_[file_paths_[i].value()]; | 389 base::File::Info info = file_info_[file_paths_[i].value()]; |
390 fileapi::DirectoryEntry entry; | 390 fileapi::DirectoryEntry entry; |
391 entry.name = relative_path.value(); | 391 entry.name = relative_path.value(); |
392 entry.is_directory = info.is_directory; | 392 entry.is_directory = info.is_directory; |
393 entry.size = info.size; | 393 entry.size = info.size; |
394 entry.last_modified_time = info.last_modified; | 394 entry.last_modified_time = info.last_modified; |
395 entry_list.push_back(entry); | 395 entry_list.push_back(entry); |
396 } | 396 } |
397 | 397 |
398 if (found_path) { | 398 if (found_path) { |
399 content::BrowserThread::PostTask(content::BrowserThread::IO, | 399 content::BrowserThread::PostTask(content::BrowserThread::IO, |
400 FROM_HERE, | 400 FROM_HERE, |
401 base::Bind(iter->success_callback, entry_list, false)); | 401 base::Bind(iter->success_callback, entry_list, false)); |
402 } else { | 402 } else { |
403 content::BrowserThread::PostTask(content::BrowserThread::IO, | 403 content::BrowserThread::PostTask(content::BrowserThread::IO, |
404 FROM_HERE, | 404 FROM_HERE, |
405 base::Bind(iter->error_callback, | 405 base::Bind(iter->error_callback, |
406 base::PLATFORM_FILE_ERROR_NOT_FOUND)); | 406 base::File::FILE_ERROR_NOT_FOUND)); |
407 } | 407 } |
408 } | 408 } |
409 | 409 |
410 read_dir_transactions_.clear(); | 410 read_dir_transactions_.clear(); |
411 } | 411 } |
412 | 412 |
413 // Invoked on UI thread from the listener. | 413 // Invoked on UI thread from the listener. |
414 void MTPDeviceDelegateImplMac::DownloadedFile( | 414 void MTPDeviceDelegateImplMac::DownloadedFile( |
415 const std::string& name, base::PlatformFileError error) { | 415 const std::string& name, base::File::Error error) { |
416 // If we're cancelled and deleting, we may have deleted the camera. | 416 // If we're cancelled and deleting, we may have deleted the camera. |
417 if (!camera_interface_.get()) | 417 if (!camera_interface_.get()) |
418 return; | 418 return; |
419 | 419 |
420 bool found = false; | 420 bool found = false; |
421 ReadFileTransactionList::iterator iter = read_file_transactions_.begin(); | 421 ReadFileTransactionList::iterator iter = read_file_transactions_.begin(); |
422 for (; iter != read_file_transactions_.end(); ++iter) { | 422 for (; iter != read_file_transactions_.end(); ++iter) { |
423 if (iter->request_file == name) { | 423 if (iter->request_file == name) { |
424 found = true; | 424 found = true; |
425 break; | 425 break; |
426 } | 426 } |
427 } | 427 } |
428 if (!found) | 428 if (!found) |
429 return; | 429 return; |
430 | 430 |
431 if (error != base::PLATFORM_FILE_OK) { | 431 if (error != base::File::FILE_OK) { |
432 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | 432 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
433 base::Bind(iter->error_callback, error)); | 433 base::Bind(iter->error_callback, error)); |
434 read_file_transactions_.erase(iter); | 434 read_file_transactions_.erase(iter); |
435 return; | 435 return; |
436 } | 436 } |
437 | 437 |
438 base::FilePath relative_path(name); | 438 base::FilePath relative_path(name); |
439 std::vector<base::FilePath::StringType> components; | 439 std::vector<base::FilePath::StringType> components; |
440 relative_path.GetComponents(&components); | 440 relative_path.GetComponents(&components); |
441 base::FilePath item_filename = root_path_; | 441 base::FilePath item_filename = root_path_; |
442 for (std::vector<base::FilePath::StringType>::iterator i = | 442 for (std::vector<base::FilePath::StringType>::iterator i = |
443 components.begin(); | 443 components.begin(); |
444 i != components.end(); ++i) { | 444 i != components.end(); ++i) { |
445 item_filename = item_filename.Append(*i); | 445 item_filename = item_filename.Append(*i); |
446 } | 446 } |
447 | 447 |
448 base::PlatformFileInfo info = file_info_[item_filename.value()]; | 448 base::File::Info info = file_info_[item_filename.value()]; |
449 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | 449 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
450 base::Bind(iter->success_callback, info, iter->snapshot_file)); | 450 base::Bind(iter->success_callback, info, iter->snapshot_file)); |
451 read_file_transactions_.erase(iter); | 451 read_file_transactions_.erase(iter); |
452 } | 452 } |
453 | 453 |
454 MTPDeviceDelegateImplMac::ReadFileRequest::ReadFileRequest( | 454 MTPDeviceDelegateImplMac::ReadFileRequest::ReadFileRequest( |
455 const std::string& file, | 455 const std::string& file, |
456 const base::FilePath& snapshot_filename, | 456 const base::FilePath& snapshot_filename, |
457 CreateSnapshotFileSuccessCallback success_cb, | 457 CreateSnapshotFileSuccessCallback success_cb, |
458 ErrorCallback error_cb) | 458 ErrorCallback error_cb) |
(...skipping 21 matching lines...) Expand all Loading... |
480 const CreateMTPDeviceAsyncDelegateCallback& cb) { | 480 const CreateMTPDeviceAsyncDelegateCallback& cb) { |
481 std::string device_name = base::FilePath(device_location).BaseName().value(); | 481 std::string device_name = base::FilePath(device_location).BaseName().value(); |
482 std::string device_id; | 482 std::string device_id; |
483 StorageInfo::Type type; | 483 StorageInfo::Type type; |
484 bool cracked = StorageInfo::CrackDeviceId(device_name, &type, &device_id); | 484 bool cracked = StorageInfo::CrackDeviceId(device_name, &type, &device_id); |
485 DCHECK(cracked); | 485 DCHECK(cracked); |
486 DCHECK_EQ(StorageInfo::MAC_IMAGE_CAPTURE, type); | 486 DCHECK_EQ(StorageInfo::MAC_IMAGE_CAPTURE, type); |
487 | 487 |
488 cb.Run(new MTPDeviceDelegateImplMac(device_id, device_location)); | 488 cb.Run(new MTPDeviceDelegateImplMac(device_id, device_location)); |
489 } | 489 } |
OLD | NEW |