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 "chrome/browser/media_galleries/fileapi/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 "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // contents of |device_file_path|. The snapshot file is created in | 42 // contents of |device_file_path|. The snapshot file is created in |
43 // "profile_path/kDeviceMediaAsyncFileUtilTempDir" directory. If the snapshot | 43 // "profile_path/kDeviceMediaAsyncFileUtilTempDir" directory. If the snapshot |
44 // file is created successfully, |snapshot_file_path| will be a non-empty file | 44 // file is created successfully, |snapshot_file_path| will be a non-empty file |
45 // path. In case of failure, the |snapshot_file_path| will be an empty file | 45 // path. In case of failure, the |snapshot_file_path| will be an empty file |
46 // path. | 46 // path. |
47 void CreateSnapshotFileOnBlockingPool( | 47 void CreateSnapshotFileOnBlockingPool( |
48 const base::FilePath& device_file_path, | 48 const base::FilePath& device_file_path, |
49 const base::FilePath& profile_path, | 49 const base::FilePath& profile_path, |
50 base::FilePath* snapshot_file_path) { | 50 base::FilePath* snapshot_file_path) { |
51 DCHECK(snapshot_file_path); | 51 DCHECK(snapshot_file_path); |
52 base::FilePath isolated_media_file_system_dir_path = | 52 base::FilePath media_file_system_dir_path = |
53 profile_path.AppendASCII(kDeviceMediaAsyncFileUtilTempDir); | 53 profile_path.AppendASCII(kDeviceMediaAsyncFileUtilTempDir); |
54 if (!base::CreateDirectory(isolated_media_file_system_dir_path) || | 54 if (!base::CreateDirectory(media_file_system_dir_path) || |
55 !base::CreateTemporaryFileInDir(isolated_media_file_system_dir_path, | 55 !base::CreateTemporaryFileInDir(media_file_system_dir_path, |
56 snapshot_file_path)) { | 56 snapshot_file_path)) { |
57 LOG(WARNING) << "Could not create media snapshot file " | 57 LOG(WARNING) << "Could not create media snapshot file " |
58 << isolated_media_file_system_dir_path.value(); | 58 << media_file_system_dir_path.value(); |
59 *snapshot_file_path = base::FilePath(); | 59 *snapshot_file_path = base::FilePath(); |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 } // namespace | 63 } // namespace |
64 | 64 |
65 DeviceMediaAsyncFileUtil::~DeviceMediaAsyncFileUtil() { | 65 DeviceMediaAsyncFileUtil::~DeviceMediaAsyncFileUtil() { |
66 } | 66 } |
67 | 67 |
68 // static | 68 // static |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 url.path(), // device file path | 365 url.path(), // device file path |
366 *snapshot_file_path, | 366 *snapshot_file_path, |
367 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile, | 367 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile, |
368 weak_ptr_factory_.GetWeakPtr(), | 368 weak_ptr_factory_.GetWeakPtr(), |
369 callback, | 369 callback, |
370 make_scoped_refptr(context->task_runner())), | 370 make_scoped_refptr(context->task_runner())), |
371 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError, | 371 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError, |
372 weak_ptr_factory_.GetWeakPtr(), | 372 weak_ptr_factory_.GetWeakPtr(), |
373 callback)); | 373 callback)); |
374 } | 374 } |
OLD | NEW |