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

Side by Side Diff: webkit/fileapi/file_system_file_util_proxy.cc

Issue 10815003: Adding FileUtil::CreateSnapshotFile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
« no previous file with comments | « webkit/fileapi/file_system_file_util_proxy.h ('k') | webkit/fileapi/file_system_operation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "webkit/fileapi/file_system_file_util_proxy.h" 5 #include "webkit/fileapi/file_system_file_util_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/sequenced_task_runner.h" 9 #include "base/sequenced_task_runner.h"
10 #include "webkit/fileapi/file_system_context.h" 10 #include "webkit/fileapi/file_system_context.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 private: 42 private:
43 base::PlatformFileError error_; 43 base::PlatformFileError error_;
44 bool created_; 44 bool created_;
45 DISALLOW_COPY_AND_ASSIGN(EnsureFileExistsHelper); 45 DISALLOW_COPY_AND_ASSIGN(EnsureFileExistsHelper);
46 }; 46 };
47 47
48 class GetFileInfoHelper { 48 class GetFileInfoHelper {
49 public: 49 public:
50 GetFileInfoHelper() : error_(base::PLATFORM_FILE_OK) {} 50 GetFileInfoHelper() : error_(base::PLATFORM_FILE_OK) {}
51 51
52 void RunWork(FileSystemFileUtil* file_util, 52 void GetFileInfo(FileSystemFileUtil* file_util,
53 FileSystemOperationContext* context, 53 FileSystemOperationContext* context,
54 const FileSystemURL& url) { 54 const FileSystemURL& url) {
55 error_ = file_util->GetFileInfo( 55 error_ = file_util->GetFileInfo(context, url, &file_info_, &platform_path_);
56 context, url, &file_info_, &platform_path_);
57 } 56 }
58 57
59 void Reply(const Proxy::GetFileInfoCallback& callback) { 58 void CreateSnapshotFile(FileSystemFileUtil* file_util,
59 FileSystemOperationContext* context,
60 const FileSystemURL& url) {
61 file_ref_ = file_util->CreateSnapshotFile(
62 context, url, &error_, &file_info_, &platform_path_);
63 }
64
65 void ReplyFileInfo(const Proxy::GetFileInfoCallback& callback) {
60 if (!callback.is_null()) 66 if (!callback.is_null())
61 callback.Run(error_, file_info_, platform_path_); 67 callback.Run(error_, file_info_, platform_path_);
62 } 68 }
63 69
70 void ReplySnapshotFile(const Proxy::SnapshotFileCallback& callback) {
71 if (!callback.is_null())
72 callback.Run(error_, file_info_, platform_path_, file_ref_);
73 }
74
64 private: 75 private:
65 base::PlatformFileError error_; 76 base::PlatformFileError error_;
66 base::PlatformFileInfo file_info_; 77 base::PlatformFileInfo file_info_;
67 FilePath platform_path_; 78 FilePath platform_path_;
79 scoped_refptr<webkit_blob::ShareableFileReference> file_ref_;
68 DISALLOW_COPY_AND_ASSIGN(GetFileInfoHelper); 80 DISALLOW_COPY_AND_ASSIGN(GetFileInfoHelper);
69 }; 81 };
70 82
71 class ReadDirectoryHelper { 83 class ReadDirectoryHelper {
72 public: 84 public:
73 ReadDirectoryHelper() : error_(base::PLATFORM_FILE_OK) {} 85 ReadDirectoryHelper() : error_(base::PLATFORM_FILE_OK) {}
74 86
75 void RunWork(FileSystemFileUtil* file_util, 87 void RunWork(FileSystemFileUtil* file_util,
76 FileSystemOperationContext* context, 88 FileSystemOperationContext* context,
77 const FileSystemURL& url) { 89 const FileSystemURL& url) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 193
182 // static 194 // static
183 bool FileSystemFileUtilProxy::GetFileInfo( 195 bool FileSystemFileUtilProxy::GetFileInfo(
184 FileSystemOperationContext* context, 196 FileSystemOperationContext* context,
185 FileSystemFileUtil* file_util, 197 FileSystemFileUtil* file_util,
186 const FileSystemURL& url, 198 const FileSystemURL& url,
187 const GetFileInfoCallback& callback) { 199 const GetFileInfoCallback& callback) {
188 GetFileInfoHelper* helper = new GetFileInfoHelper; 200 GetFileInfoHelper* helper = new GetFileInfoHelper;
189 return context->file_task_runner()->PostTaskAndReply( 201 return context->file_task_runner()->PostTaskAndReply(
190 FROM_HERE, 202 FROM_HERE,
191 Bind(&GetFileInfoHelper::RunWork, Unretained(helper), 203 Bind(&GetFileInfoHelper::GetFileInfo, Unretained(helper),
192 file_util, context, url), 204 file_util, context, url),
193 Bind(&GetFileInfoHelper::Reply, Owned(helper), callback)); 205 Bind(&GetFileInfoHelper::ReplyFileInfo, Owned(helper), callback));
194 } 206 }
195 207
196 // static 208 // static
209 bool FileSystemFileUtilProxy::CreateSnapshotFile(
210 FileSystemOperationContext* context,
211 FileSystemFileUtil* file_util,
212 const FileSystemURL& url,
213 const SnapshotFileCallback& callback) {
214 GetFileInfoHelper* helper = new GetFileInfoHelper;
215 return context->file_task_runner()->PostTaskAndReply(
216 FROM_HERE,
217 Bind(&GetFileInfoHelper::CreateSnapshotFile, Unretained(helper),
218 file_util, context, url),
219 Bind(&GetFileInfoHelper::ReplySnapshotFile, Owned(helper), callback));
220 }
221
222 // static
197 bool FileSystemFileUtilProxy::ReadDirectory( 223 bool FileSystemFileUtilProxy::ReadDirectory(
198 FileSystemOperationContext* context, 224 FileSystemOperationContext* context,
199 FileSystemFileUtil* file_util, 225 FileSystemFileUtil* file_util,
200 const FileSystemURL& url, 226 const FileSystemURL& url,
201 const ReadDirectoryCallback& callback) { 227 const ReadDirectoryCallback& callback) {
202 ReadDirectoryHelper* helper = new ReadDirectoryHelper; 228 ReadDirectoryHelper* helper = new ReadDirectoryHelper;
203 return context->file_task_runner()->PostTaskAndReply( 229 return context->file_task_runner()->PostTaskAndReply(
204 FROM_HERE, 230 FROM_HERE,
205 Bind(&ReadDirectoryHelper::RunWork, Unretained(helper), 231 Bind(&ReadDirectoryHelper::RunWork, Unretained(helper),
206 file_util, context, url), 232 file_util, context, url),
(...skipping 23 matching lines...) Expand all
230 int64 length, 256 int64 length,
231 const StatusCallback& callback) { 257 const StatusCallback& callback) {
232 return base::FileUtilProxy::RelayFileTask( 258 return base::FileUtilProxy::RelayFileTask(
233 context->file_task_runner(), FROM_HERE, 259 context->file_task_runner(), FROM_HERE,
234 Bind(&FileSystemFileUtil::Truncate, Unretained(file_util), 260 Bind(&FileSystemFileUtil::Truncate, Unretained(file_util),
235 context, url, length), 261 context, url, length),
236 callback); 262 callback);
237 } 263 }
238 264
239 } // namespace fileapi 265 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_file_util_proxy.h ('k') | webkit/fileapi/file_system_operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698