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 #include "webkit/fileapi/media/device_media_async_file_util.h" | 5 #include "webkit/fileapi/media/device_media_async_file_util.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "webkit/fileapi/file_system_context.h" | 10 #include "webkit/fileapi/file_system_context.h" |
11 #include "webkit/fileapi/file_system_operation_context.h" | 11 #include "webkit/fileapi/file_system_operation_context.h" |
12 #include "webkit/fileapi/file_system_task_runners.h" | 12 #include "webkit/fileapi/file_system_task_runners.h" |
13 #include "webkit/fileapi/file_system_url.h" | 13 #include "webkit/fileapi/file_system_url.h" |
14 #include "webkit/fileapi/isolated_context.h" | 14 #include "webkit/fileapi/isolated_context.h" |
15 #include "webkit/fileapi/media/filtering_file_enumerator.h" | 15 #include "webkit/fileapi/media/filtering_file_enumerator.h" |
16 #include "webkit/fileapi/media/media_path_filter.h" | 16 #include "webkit/fileapi/media/media_path_filter.h" |
17 #include "webkit/fileapi/media/mtp_device_async_delegate.h" | 17 #include "webkit/fileapi/media/mtp_device_async_delegate.h" |
18 #include "webkit/fileapi/media/mtp_device_file_system_config.h" | 18 #include "webkit/fileapi/media/mtp_device_file_system_config.h" |
19 #include "webkit/fileapi/media/mtp_device_map_service.h" | 19 #include "webkit/fileapi/media/mtp_device_map_service.h" |
20 #include "webkit/fileapi/media/native_media_file_util.h" | |
20 | 21 |
21 namespace fileapi { | 22 namespace fileapi { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 const base::FilePath::CharType kDeviceMediaAsyncFileUtilTempDir[] = | 26 const base::FilePath::CharType kDeviceMediaAsyncFileUtilTempDir[] = |
26 FILE_PATH_LITERAL("DeviceMediaFileSystem"); | 27 FILE_PATH_LITERAL("DeviceMediaFileSystem"); |
27 | 28 |
28 // Returns true if the current thread is IO thread. | 29 // Returns true if the current thread is IO thread. |
29 bool IsOnIOThread(FileSystemOperationContext* context) { | 30 bool IsOnIOThread(FileSystemOperationContext* context) { |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 const AsyncFileUtil::ReadDirectoryCallback& callback, | 306 const AsyncFileUtil::ReadDirectoryCallback& callback, |
306 base::PlatformFileError error) { | 307 base::PlatformFileError error) { |
307 if (!callback.is_null()) | 308 if (!callback.is_null()) |
308 callback.Run(error, AsyncFileUtil::EntryList(), false /*no more*/); | 309 callback.Run(error, AsyncFileUtil::EntryList(), false /*no more*/); |
309 } | 310 } |
310 | 311 |
311 void DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile( | 312 void DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile( |
312 const AsyncFileUtil::CreateSnapshotFileCallback& callback, | 313 const AsyncFileUtil::CreateSnapshotFileCallback& callback, |
313 const base::PlatformFileInfo& file_info, | 314 const base::PlatformFileInfo& file_info, |
314 const base::FilePath& platform_path) { | 315 const base::FilePath& platform_path) { |
315 if (!callback.is_null()) | 316 if (!callback.is_null()) { |
316 callback.Run(base::PLATFORM_FILE_OK, file_info, platform_path, | 317 base::PlatformFileError error = |
317 kSnapshotFileTemporary); | 318 NativeMediaFileUtil::IsMediaFile(platform_path); |
vandebo (ex-Chrome)
2013/03/21 16:51:12
nit: two more spaces.
| |
319 callback.Run(error, file_info, platform_path, kSnapshotFileTemporary); | |
320 } | |
318 } | 321 } |
319 | 322 |
320 void DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError( | 323 void DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError( |
321 const AsyncFileUtil::CreateSnapshotFileCallback& callback, | 324 const AsyncFileUtil::CreateSnapshotFileCallback& callback, |
322 base::PlatformFileError error) { | 325 base::PlatformFileError error) { |
323 if (!callback.is_null()) | 326 if (!callback.is_null()) |
324 callback.Run(error, base::PlatformFileInfo(), base::FilePath(), | 327 callback.Run(error, base::PlatformFileInfo(), base::FilePath(), |
325 kSnapshotFileTemporary); | 328 kSnapshotFileTemporary); |
326 } | 329 } |
327 | 330 |
(...skipping 17 matching lines...) Expand all Loading... | |
345 *snapshot_file_path, | 348 *snapshot_file_path, |
346 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile, | 349 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile, |
347 weak_ptr_factory_.GetWeakPtr(), | 350 weak_ptr_factory_.GetWeakPtr(), |
348 callback), | 351 callback), |
349 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError, | 352 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError, |
350 weak_ptr_factory_.GetWeakPtr(), | 353 weak_ptr_factory_.GetWeakPtr(), |
351 callback)); | 354 callback)); |
352 } | 355 } |
353 | 356 |
354 } // namespace fileapi | 357 } // namespace fileapi |
OLD | NEW |