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

Side by Side Diff: chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc

Issue 14247034: Move Media Galleries FileAPI code out of webkit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cr-14352004
Patch Set: Formatting fixes. Created 7 years, 8 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
OLDNEW
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 "chrome/browser/media_galleries/fileapi/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 "chrome/browser/media_galleries/fileapi/filtering_file_enumerator.h"
11 #include "chrome/browser/media_galleries/fileapi/media_file_system_mount_point_p rovider.h"
12 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h"
13 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h"
14 #include "chrome/browser/media_galleries/fileapi/mtp_device_map_service.h"
10 #include "webkit/fileapi/file_system_context.h" 15 #include "webkit/fileapi/file_system_context.h"
11 #include "webkit/fileapi/file_system_operation_context.h" 16 #include "webkit/fileapi/file_system_operation_context.h"
12 #include "webkit/fileapi/file_system_task_runners.h" 17 #include "webkit/fileapi/file_system_task_runners.h"
13 #include "webkit/fileapi/file_system_url.h" 18 #include "webkit/fileapi/file_system_url.h"
14 #include "webkit/fileapi/isolated_context.h" 19 #include "webkit/fileapi/isolated_context.h"
15 #include "webkit/fileapi/media/filtering_file_enumerator.h"
16 #include "webkit/fileapi/media/media_file_system_mount_point_provider.h"
17 #include "webkit/fileapi/media/media_path_filter.h"
18 #include "webkit/fileapi/media/mtp_device_async_delegate.h"
19 #include "webkit/fileapi/media/mtp_device_map_service.h"
20 20
21 namespace fileapi { 21 using fileapi::FileSystemOperationContext;
22 using fileapi::FileSystemURL;
23
24 namespace chrome {
22 25
23 namespace { 26 namespace {
24 27
25 const base::FilePath::CharType kDeviceMediaAsyncFileUtilTempDir[] = 28 const base::FilePath::CharType kDeviceMediaAsyncFileUtilTempDir[] =
26 FILE_PATH_LITERAL("DeviceMediaFileSystem"); 29 FILE_PATH_LITERAL("DeviceMediaFileSystem");
27 30
28 // Returns true if the current thread is IO thread. 31 // Returns true if the current thread is IO thread.
29 bool IsOnIOThread(FileSystemOperationContext* context) { 32 bool IsOnIOThread(FileSystemOperationContext* context) {
30 return context->file_system_context()->task_runners()-> 33 return context->file_system_context()->task_runners()->
31 io_task_runner()->RunsTasksOnCurrentThread(); 34 io_task_runner()->RunsTasksOnCurrentThread();
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 if (!callback.is_null()) 306 if (!callback.is_null())
304 callback.Run(error, AsyncFileUtil::EntryList(), false /*no more*/); 307 callback.Run(error, AsyncFileUtil::EntryList(), false /*no more*/);
305 } 308 }
306 309
307 void DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile( 310 void DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile(
308 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 311 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
309 const base::PlatformFileInfo& file_info, 312 const base::PlatformFileInfo& file_info,
310 const base::FilePath& platform_path) { 313 const base::FilePath& platform_path) {
311 if (!callback.is_null()) 314 if (!callback.is_null())
312 callback.Run(base::PLATFORM_FILE_OK, file_info, platform_path, 315 callback.Run(base::PLATFORM_FILE_OK, file_info, platform_path,
313 kSnapshotFileTemporary); 316 fileapi::kSnapshotFileTemporary);
314 } 317 }
315 318
316 void DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError( 319 void DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError(
317 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 320 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
318 base::PlatformFileError error) { 321 base::PlatformFileError error) {
319 if (!callback.is_null()) 322 if (!callback.is_null())
320 callback.Run(error, base::PlatformFileInfo(), base::FilePath(), 323 callback.Run(error, base::PlatformFileInfo(), base::FilePath(),
321 kSnapshotFileTemporary); 324 fileapi::kSnapshotFileTemporary);
322 } 325 }
323 326
324 void DeviceMediaAsyncFileUtil::OnSnapshotFileCreatedRunTask( 327 void DeviceMediaAsyncFileUtil::OnSnapshotFileCreatedRunTask(
325 FileSystemOperationContext* context, 328 FileSystemOperationContext* context,
326 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 329 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
327 const base::FilePath& device_file_path, 330 const base::FilePath& device_file_path,
328 base::FilePath* snapshot_file_path) { 331 base::FilePath* snapshot_file_path) {
329 DCHECK(IsOnIOThread(context)); 332 DCHECK(IsOnIOThread(context));
330 if (!snapshot_file_path || snapshot_file_path->empty()) { 333 if (!snapshot_file_path || snapshot_file_path->empty()) {
331 OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_FAILED); 334 OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_FAILED);
332 return; 335 return;
333 } 336 }
334 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(context); 337 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(context);
335 if (!delegate) { 338 if (!delegate) {
336 OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND); 339 OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND);
337 return; 340 return;
338 } 341 }
339 delegate->CreateSnapshotFile( 342 delegate->CreateSnapshotFile(
340 device_file_path, 343 device_file_path,
341 *snapshot_file_path, 344 *snapshot_file_path,
342 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile, 345 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile,
343 weak_ptr_factory_.GetWeakPtr(), 346 weak_ptr_factory_.GetWeakPtr(),
344 callback), 347 callback),
345 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError, 348 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError,
346 weak_ptr_factory_.GetWeakPtr(), 349 weak_ptr_factory_.GetWeakPtr(),
347 callback)); 350 callback));
348 } 351 }
349 352
350 } // namespace fileapi 353 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698