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

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

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More nits Created 6 years, 11 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
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 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H_ 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H_ 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H_
7 7
8 #include "base/files/file.h"
8 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
11 #include "base/platform_file.h"
12 #include "webkit/browser/fileapi/async_file_util.h" 12 #include "webkit/browser/fileapi/async_file_util.h"
13 #include "webkit/common/blob/shareable_file_reference.h" 13 #include "webkit/common/blob/shareable_file_reference.h"
14 14
15 namespace base { 15 namespace base {
16 class SequencedTaskRunner; 16 class SequencedTaskRunner;
17 class Time; 17 class Time;
18 } 18 }
19 19
20 namespace fileapi { 20 namespace fileapi {
21 class FileSystemOperationContext; 21 class FileSystemOperationContext;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 private: 104 private:
105 // Use Create() to get an instance of DeviceMediaAsyncFileUtil. 105 // Use Create() to get an instance of DeviceMediaAsyncFileUtil.
106 explicit DeviceMediaAsyncFileUtil(const base::FilePath& profile_path); 106 explicit DeviceMediaAsyncFileUtil(const base::FilePath& profile_path);
107 107
108 // Called when GetFileInfo method call succeeds. |file_info| contains the 108 // Called when GetFileInfo method call succeeds. |file_info| contains the
109 // file details of the requested url. |callback| is invoked to complete the 109 // file details of the requested url. |callback| is invoked to complete the
110 // GetFileInfo request. 110 // GetFileInfo request.
111 void OnDidGetFileInfo( 111 void OnDidGetFileInfo(
112 const AsyncFileUtil::GetFileInfoCallback& callback, 112 const AsyncFileUtil::GetFileInfoCallback& callback,
113 const base::PlatformFileInfo& file_info); 113 const base::File::Info& file_info);
114 114
115 // Called when GetFileInfo method call failed to get the details of file 115 // Called when GetFileInfo method call failed to get the details of file
116 // specified by the requested url. |callback| is invoked to notify the 116 // specified by the requested url. |callback| is invoked to notify the
117 // caller about the platform file |error|. 117 // caller about the platform file |error|.
118 void OnGetFileInfoError( 118 void OnGetFileInfoError(
119 const AsyncFileUtil::GetFileInfoCallback& callback, 119 const AsyncFileUtil::GetFileInfoCallback& callback,
120 base::PlatformFileError error); 120 base::File::Error error);
121 121
122 // Called when ReadDirectory method call succeeds. |callback| is invoked to 122 // Called when ReadDirectory method call succeeds. |callback| is invoked to
123 // complete the ReadDirectory request. 123 // complete the ReadDirectory request.
124 // 124 //
125 // If the contents of the given directory are reported in one batch, then 125 // If the contents of the given directory are reported in one batch, then
126 // |file_list| will have the list of all files/directories in the given 126 // |file_list| will have the list of all files/directories in the given
127 // directory and |has_more| will be false. 127 // directory and |has_more| will be false.
128 // 128 //
129 // If the contents of the given directory are reported in multiple chunks, 129 // If the contents of the given directory are reported in multiple chunks,
130 // |file_list| will have only a subset of all contents (the subsets reported 130 // |file_list| will have only a subset of all contents (the subsets reported
131 // in any two calls are disjoint), and |has_more| will be true, except for 131 // in any two calls are disjoint), and |has_more| will be true, except for
132 // the last chunk. 132 // the last chunk.
133 void OnDidReadDirectory( 133 void OnDidReadDirectory(
134 const AsyncFileUtil::ReadDirectoryCallback& callback, 134 const AsyncFileUtil::ReadDirectoryCallback& callback,
135 const AsyncFileUtil::EntryList& file_list, 135 const AsyncFileUtil::EntryList& file_list,
136 bool has_more); 136 bool has_more);
137 137
138 // Called when ReadDirectory method call failed to enumerate the directory 138 // Called when ReadDirectory method call failed to enumerate the directory
139 // objects. |callback| is invoked to notify the caller about the |error| 139 // objects. |callback| is invoked to notify the caller about the |error|
140 // that occured while reading the directory objects. 140 // that occured while reading the directory objects.
141 void OnReadDirectoryError( 141 void OnReadDirectoryError(
142 const AsyncFileUtil::ReadDirectoryCallback& callback, 142 const AsyncFileUtil::ReadDirectoryCallback& callback,
143 base::PlatformFileError error); 143 base::File::Error error);
144 144
145 // Called when the snapshot file specified by the |platform_path| is 145 // Called when the snapshot file specified by the |platform_path| is
146 // successfully created. |file_info| contains the device media file details 146 // successfully created. |file_info| contains the device media file details
147 // for which the snapshot file is created. 147 // for which the snapshot file is created.
148 void OnDidCreateSnapshotFile( 148 void OnDidCreateSnapshotFile(
149 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 149 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
150 base::SequencedTaskRunner* media_task_runner, 150 base::SequencedTaskRunner* media_task_runner,
151 const base::PlatformFileInfo& file_info, 151 const base::File::Info& file_info,
152 const base::FilePath& platform_path); 152 const base::FilePath& platform_path);
153 153
154 // Called after OnDidCreateSnapshotFile finishes media check. 154 // Called after OnDidCreateSnapshotFile finishes media check.
155 // |callback| is invoked to complete the CreateSnapshotFile request. 155 // |callback| is invoked to complete the CreateSnapshotFile request.
156 void OnDidCheckMedia( 156 void OnDidCheckMedia(
157 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 157 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
158 const base::PlatformFileInfo& file_info, 158 const base::File::Info& file_info,
159 scoped_refptr<webkit_blob::ShareableFileReference> platform_file, 159 scoped_refptr<webkit_blob::ShareableFileReference> platform_file,
160 base::PlatformFileError error); 160 base::File::Error error);
161 161
162 // Called when CreateSnapshotFile method call fails. |callback| is invoked to 162 // Called when CreateSnapshotFile method call fails. |callback| is invoked to
163 // notify the caller about the |error|. 163 // notify the caller about the |error|.
164 void OnCreateSnapshotFileError( 164 void OnCreateSnapshotFileError(
165 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 165 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
166 base::PlatformFileError error); 166 base::File::Error error);
167 167
168 // Called when the snapshot file specified by the |snapshot_file_path| is 168 // Called when the snapshot file specified by the |snapshot_file_path| is
169 // created to hold the contents of the url.path(). If the snapshot 169 // created to hold the contents of the url.path(). If the snapshot
170 // file is successfully created, |snapshot_file_path| will be an non-empty 170 // file is successfully created, |snapshot_file_path| will be an non-empty
171 // file path. In case of failure, |snapshot_file_path| will be an empty file 171 // file path. In case of failure, |snapshot_file_path| will be an empty file
172 // path. Forwards the CreateSnapshot request to the delegate to copy the 172 // path. Forwards the CreateSnapshot request to the delegate to copy the
173 // contents of url.path() to |snapshot_file_path|. 173 // contents of url.path() to |snapshot_file_path|.
174 void OnSnapshotFileCreatedRunTask( 174 void OnSnapshotFileCreatedRunTask(
175 scoped_ptr<fileapi::FileSystemOperationContext> context, 175 scoped_ptr<fileapi::FileSystemOperationContext> context,
176 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 176 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
177 const fileapi::FileSystemURL& url, 177 const fileapi::FileSystemURL& url,
178 base::FilePath* snapshot_file_path); 178 base::FilePath* snapshot_file_path);
179 179
180 // Profile path. 180 // Profile path.
181 const base::FilePath profile_path_; 181 const base::FilePath profile_path_;
182 182
183 // For callbacks that may run after destruction. 183 // For callbacks that may run after destruction.
184 base::WeakPtrFactory<DeviceMediaAsyncFileUtil> weak_ptr_factory_; 184 base::WeakPtrFactory<DeviceMediaAsyncFileUtil> weak_ptr_factory_;
185 185
186 DISALLOW_COPY_AND_ASSIGN(DeviceMediaAsyncFileUtil); 186 DISALLOW_COPY_AND_ASSIGN(DeviceMediaAsyncFileUtil);
187 }; 187 };
188 188
189 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H _ 189 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698