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

Side by Side Diff: base/file_util_proxy.cc

Issue 6286038: Add initial code to do filename munging in the FileSystem.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/file_util_proxy.h" 5 #include "base/file_util_proxy.h"
6 6
7 #include "base/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 8
9 // TODO(jianli): Move the code from anonymous namespace to base namespace so 9 // TODO(jianli): Move the code from anonymous namespace to base namespace so
10 // that all of the base:: prefixes would be unnecessary. 10 // that all of the base:: prefixes would be unnecessary.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_; 113 scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_;
114 base::PlatformFileError error_code_; 114 base::PlatformFileError error_code_;
115 }; 115 };
116 116
117 class RelayCreateOrOpen : public MessageLoopRelay { 117 class RelayCreateOrOpen : public MessageLoopRelay {
118 public: 118 public:
119 RelayCreateOrOpen( 119 RelayCreateOrOpen(
120 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, 120 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
121 const FilePath& file_path, 121 const FilePath& file_path,
122 int file_flags, 122 int file_flags,
123 base::FileUtilProxy::CreateOrOpenCallback* callback) 123 base::FileUtilProxyBase::CreateOrOpenCallback* callback)
124 : message_loop_proxy_(message_loop_proxy), 124 : message_loop_proxy_(message_loop_proxy),
125 file_path_(file_path), 125 file_path_(file_path),
126 file_flags_(file_flags), 126 file_flags_(file_flags),
127 callback_(callback), 127 callback_(callback),
128 file_handle_(base::kInvalidPlatformFileValue), 128 file_handle_(base::kInvalidPlatformFileValue),
129 created_(false) { 129 created_(false) {
130 DCHECK(callback); 130 DCHECK(callback);
131 } 131 }
132 132
133 protected: 133 protected:
134 virtual ~RelayCreateOrOpen() { 134 virtual ~RelayCreateOrOpen() {
135 if (file_handle_ != base::kInvalidPlatformFileValue) 135 if (file_handle_ != base::kInvalidPlatformFileValue)
136 base::FileUtilProxy::Close(message_loop_proxy_, file_handle_, NULL); 136 base::FileUtilProxy::GetInstance()->Close(
137 message_loop_proxy_, file_handle_, NULL);
137 } 138 }
138 139
139 virtual void RunWork() { 140 virtual void RunWork() {
140 if (!file_util::DirectoryExists(file_path_.DirName())) { 141 if (!file_util::DirectoryExists(file_path_.DirName())) {
141 // If its parent does not exist, should return NOT_FOUND error. 142 // If its parent does not exist, should return NOT_FOUND error.
142 set_error_code(base::PLATFORM_FILE_ERROR_NOT_FOUND); 143 set_error_code(base::PLATFORM_FILE_ERROR_NOT_FOUND);
143 return; 144 return;
144 } 145 }
145 base::PlatformFileError error_code = base::PLATFORM_FILE_OK; 146 base::PlatformFileError error_code = base::PLATFORM_FILE_OK;
146 file_handle_ = base::CreatePlatformFile(file_path_, file_flags_, 147 file_handle_ = base::CreatePlatformFile(file_path_, file_flags_,
147 &created_, &error_code); 148 &created_, &error_code);
148 set_error_code(error_code); 149 set_error_code(error_code);
149 } 150 }
150 151
151 virtual void RunCallback() { 152 virtual void RunCallback() {
152 callback_->Run(error_code(), base::PassPlatformFile(&file_handle_), 153 callback_->Run(error_code(), base::PassPlatformFile(&file_handle_),
153 created_); 154 created_);
154 delete callback_; 155 delete callback_;
155 } 156 }
156 157
157 private: 158 private:
158 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 159 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
159 FilePath file_path_; 160 FilePath file_path_;
160 int file_flags_; 161 int file_flags_;
161 base::FileUtilProxy::CreateOrOpenCallback* callback_; 162 base::FileUtilProxyBase::CreateOrOpenCallback* callback_;
162 base::PlatformFile file_handle_; 163 base::PlatformFile file_handle_;
163 bool created_; 164 bool created_;
164 }; 165 };
165 166
166 class RelayCreateTemporary : public MessageLoopRelay { 167 class RelayCreateTemporary : public MessageLoopRelay {
167 public: 168 public:
168 RelayCreateTemporary( 169 RelayCreateTemporary(
169 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, 170 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
170 base::FileUtilProxy::CreateTemporaryCallback* callback) 171 base::FileUtilProxyBase::CreateTemporaryCallback* callback)
171 : message_loop_proxy_(message_loop_proxy), 172 : message_loop_proxy_(message_loop_proxy),
172 callback_(callback), 173 callback_(callback),
173 file_handle_(base::kInvalidPlatformFileValue) { 174 file_handle_(base::kInvalidPlatformFileValue) {
174 DCHECK(callback); 175 DCHECK(callback);
175 } 176 }
176 177
177 protected: 178 protected:
178 virtual ~RelayCreateTemporary() { 179 virtual ~RelayCreateTemporary() {
179 if (file_handle_ != base::kInvalidPlatformFileValue) 180 if (file_handle_ != base::kInvalidPlatformFileValue)
180 base::FileUtilProxy::Close(message_loop_proxy_, file_handle_, NULL); 181 base::FileUtilProxy::GetInstance()->Close(
182 message_loop_proxy_, file_handle_, NULL);
181 } 183 }
182 184
183 virtual void RunWork() { 185 virtual void RunWork() {
184 // TODO(darin): file_util should have a variant of CreateTemporaryFile 186 // TODO(darin): file_util should have a variant of CreateTemporaryFile
185 // that returns a FilePath and a PlatformFile. 187 // that returns a FilePath and a PlatformFile.
186 file_util::CreateTemporaryFile(&file_path_); 188 file_util::CreateTemporaryFile(&file_path_);
187 189
188 // Use a fixed set of flags that are appropriate for writing to a temporary 190 // Use a fixed set of flags that are appropriate for writing to a temporary
189 // file from the IO thread using a net::FileStream. 191 // file from the IO thread using a net::FileStream.
190 int file_flags = 192 int file_flags =
191 base::PLATFORM_FILE_CREATE_ALWAYS | 193 base::PLATFORM_FILE_CREATE_ALWAYS |
192 base::PLATFORM_FILE_WRITE | 194 base::PLATFORM_FILE_WRITE |
193 base::PLATFORM_FILE_ASYNC | 195 base::PLATFORM_FILE_ASYNC |
194 base::PLATFORM_FILE_TEMPORARY; 196 base::PLATFORM_FILE_TEMPORARY;
195 base::PlatformFileError error_code = base::PLATFORM_FILE_OK; 197 base::PlatformFileError error_code = base::PLATFORM_FILE_OK;
196 file_handle_ = base::CreatePlatformFile(file_path_, file_flags, 198 file_handle_ = base::CreatePlatformFile(file_path_, file_flags,
197 NULL, &error_code); 199 NULL, &error_code);
198 set_error_code(error_code); 200 set_error_code(error_code);
199 } 201 }
200 202
201 virtual void RunCallback() { 203 virtual void RunCallback() {
202 callback_->Run(error_code(), base::PassPlatformFile(&file_handle_), 204 callback_->Run(error_code(), base::PassPlatformFile(&file_handle_),
203 file_path_); 205 file_path_);
204 delete callback_; 206 delete callback_;
205 } 207 }
206 208
207 private: 209 private:
208 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 210 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
209 base::FileUtilProxy::CreateTemporaryCallback* callback_; 211 base::FileUtilProxyBase::CreateTemporaryCallback* callback_;
210 base::PlatformFile file_handle_; 212 base::PlatformFile file_handle_;
211 FilePath file_path_; 213 FilePath file_path_;
212 }; 214 };
213 215
214 class RelayWithStatusCallback : public MessageLoopRelay { 216 class RelayWithStatusCallback : public MessageLoopRelay {
215 public: 217 public:
216 explicit RelayWithStatusCallback( 218 explicit RelayWithStatusCallback(
217 base::FileUtilProxy::StatusCallback* callback) 219 base::FileUtilProxyBase::StatusCallback* callback)
218 : callback_(callback) { 220 : callback_(callback) {
219 // It is OK for callback to be NULL. 221 // It is OK for callback to be NULL.
220 } 222 }
221 223
222 protected: 224 protected:
223 virtual void RunCallback() { 225 virtual void RunCallback() {
224 // The caller may not have been interested in the result. 226 // The caller may not have been interested in the result.
225 if (callback_) { 227 if (callback_) {
226 callback_->Run(error_code()); 228 callback_->Run(error_code());
227 delete callback_; 229 delete callback_;
228 } 230 }
229 } 231 }
230 232
231 private: 233 private:
232 base::FileUtilProxy::StatusCallback* callback_; 234 base::FileUtilProxyBase::StatusCallback* callback_;
233 }; 235 };
234 236
235 class RelayClose : public RelayWithStatusCallback { 237 class RelayClose : public RelayWithStatusCallback {
236 public: 238 public:
237 RelayClose(base::PlatformFile file_handle, 239 RelayClose(base::PlatformFile file_handle,
238 base::FileUtilProxy::StatusCallback* callback) 240 base::FileUtilProxyBase::StatusCallback* callback)
239 : RelayWithStatusCallback(callback), 241 : RelayWithStatusCallback(callback),
240 file_handle_(file_handle) { 242 file_handle_(file_handle) {
241 } 243 }
242 244
243 protected: 245 protected:
244 virtual void RunWork() { 246 virtual void RunWork() {
245 if (!base::ClosePlatformFile(file_handle_)) 247 if (!base::ClosePlatformFile(file_handle_))
246 set_error_code(base::PLATFORM_FILE_ERROR_FAILED); 248 set_error_code(base::PLATFORM_FILE_ERROR_FAILED);
247 } 249 }
248 250
249 private: 251 private:
250 base::PlatformFile file_handle_; 252 base::PlatformFile file_handle_;
251 }; 253 };
252 254
253 class RelayEnsureFileExists : public MessageLoopRelay { 255 class RelayEnsureFileExists : public MessageLoopRelay {
254 public: 256 public:
255 RelayEnsureFileExists( 257 RelayEnsureFileExists(
256 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, 258 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
257 const FilePath& file_path, 259 const FilePath& file_path,
258 base::FileUtilProxy::EnsureFileExistsCallback* callback) 260 base::FileUtilProxyBase::EnsureFileExistsCallback* callback)
259 : message_loop_proxy_(message_loop_proxy), 261 : message_loop_proxy_(message_loop_proxy),
260 file_path_(file_path), 262 file_path_(file_path),
261 callback_(callback), 263 callback_(callback),
262 created_(false) { 264 created_(false) {
263 DCHECK(callback); 265 DCHECK(callback);
264 } 266 }
265 267
266 protected: 268 protected:
267 virtual void RunWork() { 269 virtual void RunWork() {
268 if (!file_util::DirectoryExists(file_path_.DirName())) { 270 if (!file_util::DirectoryExists(file_path_.DirName())) {
(...skipping 19 matching lines...) Expand all
288 } 290 }
289 291
290 virtual void RunCallback() { 292 virtual void RunCallback() {
291 callback_->Run(error_code(), created_); 293 callback_->Run(error_code(), created_);
292 delete callback_; 294 delete callback_;
293 } 295 }
294 296
295 private: 297 private:
296 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 298 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
297 FilePath file_path_; 299 FilePath file_path_;
298 base::FileUtilProxy::EnsureFileExistsCallback* callback_; 300 base::FileUtilProxyBase::EnsureFileExistsCallback* callback_;
299 bool created_; 301 bool created_;
300 }; 302 };
301 303
302 class RelayDelete : public RelayWithStatusCallback { 304 class RelayDelete : public RelayWithStatusCallback {
303 public: 305 public:
304 RelayDelete(const FilePath& file_path, 306 RelayDelete(const FilePath& file_path,
305 bool recursive, 307 bool recursive,
306 base::FileUtilProxy::StatusCallback* callback) 308 base::FileUtilProxyBase::StatusCallback* callback)
307 : RelayWithStatusCallback(callback), 309 : RelayWithStatusCallback(callback),
308 file_path_(file_path), 310 file_path_(file_path),
309 recursive_(recursive) { 311 recursive_(recursive) {
310 } 312 }
311 313
312 protected: 314 protected:
313 virtual void RunWork() { 315 virtual void RunWork() {
314 if (!file_util::PathExists(file_path_)) { 316 if (!file_util::PathExists(file_path_)) {
315 set_error_code(base::PLATFORM_FILE_ERROR_NOT_FOUND); 317 set_error_code(base::PLATFORM_FILE_ERROR_NOT_FOUND);
316 return; 318 return;
317 } 319 }
318 if (!file_util::Delete(file_path_, recursive_)) { 320 if (!file_util::Delete(file_path_, recursive_)) {
319 if (!recursive_ && !file_util::IsDirectoryEmpty(file_path_)) { 321 if (!recursive_ && !file_util::IsDirectoryEmpty(file_path_)) {
320 set_error_code(base::PLATFORM_FILE_ERROR_NOT_EMPTY); 322 set_error_code(base::PLATFORM_FILE_ERROR_NOT_EMPTY);
321 return; 323 return;
322 } 324 }
323 set_error_code(base::PLATFORM_FILE_ERROR_FAILED); 325 set_error_code(base::PLATFORM_FILE_ERROR_FAILED);
324 } 326 }
325 } 327 }
326 328
327 private: 329 private:
328 FilePath file_path_; 330 FilePath file_path_;
329 bool recursive_; 331 bool recursive_;
330 }; 332 };
331 333
332 class RelayCopy : public RelayWithStatusCallback { 334 class RelayCopy : public RelayWithStatusCallback {
333 public: 335 public:
334 RelayCopy(const FilePath& src_file_path, 336 RelayCopy(const FilePath& src_file_path,
335 const FilePath& dest_file_path, 337 const FilePath& dest_file_path,
336 base::FileUtilProxy::StatusCallback* callback) 338 base::FileUtilProxyBase::StatusCallback* callback)
337 : RelayWithStatusCallback(callback), 339 : RelayWithStatusCallback(callback),
338 src_file_path_(src_file_path), 340 src_file_path_(src_file_path),
339 dest_file_path_(dest_file_path) { 341 dest_file_path_(dest_file_path) {
340 } 342 }
341 343
342 protected: 344 protected:
343 virtual void RunWork() { 345 virtual void RunWork() {
344 set_error_code(PerformCommonCheckAndPreparationForMoveAndCopy( 346 set_error_code(PerformCommonCheckAndPreparationForMoveAndCopy(
345 src_file_path_, dest_file_path_)); 347 src_file_path_, dest_file_path_));
346 if (error_code() != base::PLATFORM_FILE_OK) 348 if (error_code() != base::PLATFORM_FILE_OK)
347 return; 349 return;
348 if (!file_util::CopyDirectory(src_file_path_, dest_file_path_, 350 if (!file_util::CopyDirectory(src_file_path_, dest_file_path_,
349 true /* recursive */)) 351 true /* recursive */))
350 set_error_code(base::PLATFORM_FILE_ERROR_FAILED); 352 set_error_code(base::PLATFORM_FILE_ERROR_FAILED);
351 } 353 }
352 354
353 private: 355 private:
354 FilePath src_file_path_; 356 FilePath src_file_path_;
355 FilePath dest_file_path_; 357 FilePath dest_file_path_;
356 }; 358 };
357 359
358 class RelayMove : public RelayWithStatusCallback { 360 class RelayMove : public RelayWithStatusCallback {
359 public: 361 public:
360 RelayMove(const FilePath& src_file_path, 362 RelayMove(const FilePath& src_file_path,
361 const FilePath& dest_file_path, 363 const FilePath& dest_file_path,
362 base::FileUtilProxy::StatusCallback* callback) 364 base::FileUtilProxyBase::StatusCallback* callback)
363 : RelayWithStatusCallback(callback), 365 : RelayWithStatusCallback(callback),
364 src_file_path_(src_file_path), 366 src_file_path_(src_file_path),
365 dest_file_path_(dest_file_path) { 367 dest_file_path_(dest_file_path) {
366 } 368 }
367 369
368 protected: 370 protected:
369 virtual void RunWork() { 371 virtual void RunWork() {
370 set_error_code(PerformCommonCheckAndPreparationForMoveAndCopy( 372 set_error_code(PerformCommonCheckAndPreparationForMoveAndCopy(
371 src_file_path_, dest_file_path_)); 373 src_file_path_, dest_file_path_));
372 if (error_code() != base::PLATFORM_FILE_OK) 374 if (error_code() != base::PLATFORM_FILE_OK)
373 return; 375 return;
374 if (!file_util::Move(src_file_path_, dest_file_path_)) 376 if (!file_util::Move(src_file_path_, dest_file_path_))
375 set_error_code(base::PLATFORM_FILE_ERROR_FAILED); 377 set_error_code(base::PLATFORM_FILE_ERROR_FAILED);
376 } 378 }
377 379
378 private: 380 private:
379 FilePath src_file_path_; 381 FilePath src_file_path_;
380 FilePath dest_file_path_; 382 FilePath dest_file_path_;
381 }; 383 };
382 384
383 class RelayCreateDirectory : public RelayWithStatusCallback { 385 class RelayCreateDirectory : public RelayWithStatusCallback {
384 public: 386 public:
385 RelayCreateDirectory( 387 RelayCreateDirectory(
386 const FilePath& file_path, 388 const FilePath& file_path,
387 bool exclusive, 389 bool exclusive,
388 bool recursive, 390 bool recursive,
389 base::FileUtilProxy::StatusCallback* callback) 391 base::FileUtilProxyBase::StatusCallback* callback)
390 : RelayWithStatusCallback(callback), 392 : RelayWithStatusCallback(callback),
391 file_path_(file_path), 393 file_path_(file_path),
392 exclusive_(exclusive), 394 exclusive_(exclusive),
393 recursive_(recursive) { 395 recursive_(recursive) {
394 } 396 }
395 397
396 protected: 398 protected:
397 virtual void RunWork() { 399 virtual void RunWork() {
398 bool path_exists = file_util::PathExists(file_path_); 400 bool path_exists = file_util::PathExists(file_path_);
399 // If parent dir of file doesn't exist. 401 // If parent dir of file doesn't exist.
(...skipping 16 matching lines...) Expand all
416 418
417 private: 419 private:
418 FilePath file_path_; 420 FilePath file_path_;
419 bool exclusive_; 421 bool exclusive_;
420 bool recursive_; 422 bool recursive_;
421 }; 423 };
422 424
423 class RelayReadDirectory : public MessageLoopRelay { 425 class RelayReadDirectory : public MessageLoopRelay {
424 public: 426 public:
425 RelayReadDirectory(const FilePath& file_path, 427 RelayReadDirectory(const FilePath& file_path,
426 base::FileUtilProxy::ReadDirectoryCallback* callback) 428 base::FileUtilProxyBase::ReadDirectoryCallback* callback)
427 : callback_(callback), file_path_(file_path) { 429 : callback_(callback), file_path_(file_path) {
428 DCHECK(callback); 430 DCHECK(callback);
429 } 431 }
430 432
431 protected: 433 protected:
432 virtual void RunWork() { 434 virtual void RunWork() {
433 // TODO(kkanetkar): Implement directory read in multiple chunks. 435 // TODO(kkanetkar): Implement directory read in multiple chunks.
434 if (!file_util::DirectoryExists(file_path_)) { 436 if (!file_util::DirectoryExists(file_path_)) {
435 set_error_code(base::PLATFORM_FILE_ERROR_NOT_FOUND); 437 set_error_code(base::PLATFORM_FILE_ERROR_NOT_FOUND);
436 return; 438 return;
437 } 439 }
438 440
439 file_util::FileEnumerator file_enum( 441 file_util::FileEnumerator file_enum(
440 file_path_, false, static_cast<file_util::FileEnumerator::FILE_TYPE>( 442 file_path_, false, static_cast<file_util::FileEnumerator::FILE_TYPE>(
441 file_util::FileEnumerator::FILES | 443 file_util::FileEnumerator::FILES |
442 file_util::FileEnumerator::DIRECTORIES)); 444 file_util::FileEnumerator::DIRECTORIES));
443 FilePath current; 445 FilePath current;
444 while (!(current = file_enum.Next()).empty()) { 446 while (!(current = file_enum.Next()).empty()) {
445 base::FileUtilProxy::Entry entry; 447 base::FileUtilProxyBase::Entry entry;
446 file_util::FileEnumerator::FindInfo info; 448 file_util::FileEnumerator::FindInfo info;
447 file_enum.GetFindInfo(&info); 449 file_enum.GetFindInfo(&info);
448 entry.is_directory = file_enum.IsDirectory(info); 450 entry.is_directory = file_enum.IsDirectory(info);
449 // This will just give the entry's name instead of entire path 451 // This will just give the entry's name instead of entire path
450 // if we use current.value(). 452 // if we use current.value().
451 entry.name = file_util::FileEnumerator::GetFilename(info).value(); 453 entry.name = file_util::FileEnumerator::GetFilename(info).value();
452 entries_.push_back(entry); 454 entries_.push_back(entry);
453 } 455 }
454 } 456 }
455 457
456 virtual void RunCallback() { 458 virtual void RunCallback() {
457 callback_->Run(error_code(), entries_); 459 callback_->Run(error_code(), entries_);
458 delete callback_; 460 delete callback_;
459 } 461 }
460 462
461 private: 463 private:
462 base::FileUtilProxy::ReadDirectoryCallback* callback_; 464 base::FileUtilProxyBase::ReadDirectoryCallback* callback_;
463 FilePath file_path_; 465 FilePath file_path_;
464 std::vector<base::FileUtilProxy::Entry> entries_; 466 std::vector<base::FileUtilProxyBase::Entry> entries_;
465 }; 467 };
466 468
467 class RelayGetFileInfo : public MessageLoopRelay { 469 class RelayGetFileInfo : public MessageLoopRelay {
468 public: 470 public:
469 RelayGetFileInfo(const FilePath& file_path, 471 RelayGetFileInfo(const FilePath& file_path,
470 base::FileUtilProxy::GetFileInfoCallback* callback) 472 base::FileUtilProxyBase::GetFileInfoCallback* callback)
471 : callback_(callback), 473 : callback_(callback),
472 file_path_(file_path) { 474 file_path_(file_path) {
473 DCHECK(callback); 475 DCHECK(callback);
474 } 476 }
475 477
476 protected: 478 protected:
477 virtual void RunWork() { 479 virtual void RunWork() {
478 if (!file_util::PathExists(file_path_)) { 480 if (!file_util::PathExists(file_path_)) {
479 set_error_code(base::PLATFORM_FILE_ERROR_NOT_FOUND); 481 set_error_code(base::PLATFORM_FILE_ERROR_NOT_FOUND);
480 return; 482 return;
481 } 483 }
482 if (!file_util::GetFileInfo(file_path_, &file_info_)) 484 if (!file_util::GetFileInfo(file_path_, &file_info_))
483 set_error_code(base::PLATFORM_FILE_ERROR_FAILED); 485 set_error_code(base::PLATFORM_FILE_ERROR_FAILED);
484 } 486 }
485 487
486 virtual void RunCallback() { 488 virtual void RunCallback() {
487 callback_->Run(error_code(), file_info_); 489 callback_->Run(error_code(), file_info_);
488 delete callback_; 490 delete callback_;
489 } 491 }
490 492
491 private: 493 private:
492 base::FileUtilProxy::GetFileInfoCallback* callback_; 494 base::FileUtilProxyBase::GetFileInfoCallback* callback_;
493 FilePath file_path_; 495 FilePath file_path_;
494 base::PlatformFileInfo file_info_; 496 base::PlatformFileInfo file_info_;
495 }; 497 };
496 498
497 class RelayGetFileInfoFromPlatformFile : public MessageLoopRelay { 499 class RelayGetFileInfoFromPlatformFile : public MessageLoopRelay {
498 public: 500 public:
499 RelayGetFileInfoFromPlatformFile( 501 RelayGetFileInfoFromPlatformFile(
500 base::PlatformFile file, 502 base::PlatformFile file,
501 base::FileUtilProxy::GetFileInfoCallback* callback) 503 base::FileUtilProxyBase::GetFileInfoCallback* callback)
502 : callback_(callback), 504 : callback_(callback),
503 file_(file) { 505 file_(file) {
504 DCHECK(callback); 506 DCHECK(callback);
505 } 507 }
506 508
507 protected: 509 protected:
508 virtual void RunWork() { 510 virtual void RunWork() {
509 if (!base::GetPlatformFileInfo(file_, &file_info_)) 511 if (!base::GetPlatformFileInfo(file_, &file_info_))
510 set_error_code(base::PLATFORM_FILE_ERROR_FAILED); 512 set_error_code(base::PLATFORM_FILE_ERROR_FAILED);
511 } 513 }
512 514
513 virtual void RunCallback() { 515 virtual void RunCallback() {
514 callback_->Run(error_code(), file_info_); 516 callback_->Run(error_code(), file_info_);
515 delete callback_; 517 delete callback_;
516 } 518 }
517 519
518 private: 520 private:
519 base::FileUtilProxy::GetFileInfoCallback* callback_; 521 base::FileUtilProxyBase::GetFileInfoCallback* callback_;
520 base::PlatformFile file_; 522 base::PlatformFile file_;
521 base::PlatformFileInfo file_info_; 523 base::PlatformFileInfo file_info_;
522 }; 524 };
523 525
524 class RelayRead : public MessageLoopRelay { 526 class RelayRead : public MessageLoopRelay {
525 public: 527 public:
526 RelayRead(base::PlatformFile file, 528 RelayRead(base::PlatformFile file,
527 int64 offset, 529 int64 offset,
528 char* buffer, 530 char* buffer,
529 int bytes_to_read, 531 int bytes_to_read,
530 base::FileUtilProxy::ReadWriteCallback* callback) 532 base::FileUtilProxyBase::ReadWriteCallback* callback)
531 : file_(file), 533 : file_(file),
532 offset_(offset), 534 offset_(offset),
533 buffer_(buffer), 535 buffer_(buffer),
534 bytes_to_read_(bytes_to_read), 536 bytes_to_read_(bytes_to_read),
535 callback_(callback), 537 callback_(callback),
536 bytes_read_(0) { 538 bytes_read_(0) {
537 } 539 }
538 540
539 protected: 541 protected:
540 virtual void RunWork() { 542 virtual void RunWork() {
541 bytes_read_ = base::ReadPlatformFile(file_, offset_, buffer_, 543 bytes_read_ = base::ReadPlatformFile(file_, offset_, buffer_,
542 bytes_to_read_); 544 bytes_to_read_);
543 if (bytes_read_ < 0) 545 if (bytes_read_ < 0)
544 set_error_code(base::PLATFORM_FILE_ERROR_FAILED); 546 set_error_code(base::PLATFORM_FILE_ERROR_FAILED);
545 } 547 }
546 548
547 virtual void RunCallback() { 549 virtual void RunCallback() {
548 if (callback_) { 550 if (callback_) {
549 callback_->Run(error_code(), bytes_read_); 551 callback_->Run(error_code(), bytes_read_);
550 delete callback_; 552 delete callback_;
551 } 553 }
552 } 554 }
553 555
554 private: 556 private:
555 base::PlatformFile file_; 557 base::PlatformFile file_;
556 int64 offset_; 558 int64 offset_;
557 char* buffer_; 559 char* buffer_;
558 int bytes_to_read_; 560 int bytes_to_read_;
559 base::FileUtilProxy::ReadWriteCallback* callback_; 561 base::FileUtilProxyBase::ReadWriteCallback* callback_;
560 int bytes_read_; 562 int bytes_read_;
561 }; 563 };
562 564
563 class RelayWrite : public MessageLoopRelay { 565 class RelayWrite : public MessageLoopRelay {
564 public: 566 public:
565 RelayWrite(base::PlatformFile file, 567 RelayWrite(base::PlatformFile file,
566 int64 offset, 568 int64 offset,
567 const char* buffer, 569 const char* buffer,
568 int bytes_to_write, 570 int bytes_to_write,
569 base::FileUtilProxy::ReadWriteCallback* callback) 571 base::FileUtilProxyBase::ReadWriteCallback* callback)
570 : file_(file), 572 : file_(file),
571 offset_(offset), 573 offset_(offset),
572 buffer_(buffer), 574 buffer_(buffer),
573 bytes_to_write_(bytes_to_write), 575 bytes_to_write_(bytes_to_write),
574 callback_(callback) { 576 callback_(callback) {
575 } 577 }
576 578
577 protected: 579 protected:
578 virtual void RunWork() { 580 virtual void RunWork() {
579 bytes_written_ = base::WritePlatformFile(file_, offset_, buffer_, 581 bytes_written_ = base::WritePlatformFile(file_, offset_, buffer_,
580 bytes_to_write_); 582 bytes_to_write_);
581 if (bytes_written_ < 0) 583 if (bytes_written_ < 0)
582 set_error_code(base::PLATFORM_FILE_ERROR_FAILED); 584 set_error_code(base::PLATFORM_FILE_ERROR_FAILED);
583 } 585 }
584 586
585 virtual void RunCallback() { 587 virtual void RunCallback() {
586 if (callback_) { 588 if (callback_) {
587 callback_->Run(error_code(), bytes_written_); 589 callback_->Run(error_code(), bytes_written_);
588 delete callback_; 590 delete callback_;
589 } 591 }
590 } 592 }
591 593
592 private: 594 private:
593 base::PlatformFile file_; 595 base::PlatformFile file_;
594 int64 offset_; 596 int64 offset_;
595 const char* buffer_; 597 const char* buffer_;
596 int bytes_to_write_; 598 int bytes_to_write_;
597 base::FileUtilProxy::ReadWriteCallback* callback_; 599 base::FileUtilProxyBase::ReadWriteCallback* callback_;
598 int bytes_written_; 600 int bytes_written_;
599 }; 601 };
600 602
601 class RelayTouch : public RelayWithStatusCallback { 603 class RelayTouch : public RelayWithStatusCallback {
602 public: 604 public:
603 RelayTouch(base::PlatformFile file, 605 RelayTouch(base::PlatformFile file,
604 const base::Time& last_access_time, 606 const base::Time& last_access_time,
605 const base::Time& last_modified_time, 607 const base::Time& last_modified_time,
606 base::FileUtilProxy::StatusCallback* callback) 608 base::FileUtilProxyBase::StatusCallback* callback)
607 : RelayWithStatusCallback(callback), 609 : RelayWithStatusCallback(callback),
608 file_(file), 610 file_(file),
609 last_access_time_(last_access_time), 611 last_access_time_(last_access_time),
610 last_modified_time_(last_modified_time) { 612 last_modified_time_(last_modified_time) {
611 } 613 }
612 614
613 protected: 615 protected:
614 virtual void RunWork() { 616 virtual void RunWork() {
615 if (!base::TouchPlatformFile(file_, last_access_time_, last_modified_time_)) 617 if (!base::TouchPlatformFile(file_, last_access_time_, last_modified_time_))
616 set_error_code(base::PLATFORM_FILE_ERROR_FAILED); 618 set_error_code(base::PLATFORM_FILE_ERROR_FAILED);
617 } 619 }
618 620
619 private: 621 private:
620 base::PlatformFile file_; 622 base::PlatformFile file_;
621 base::Time last_access_time_; 623 base::Time last_access_time_;
622 base::Time last_modified_time_; 624 base::Time last_modified_time_;
623 }; 625 };
624 626
625 class RelayTouchFilePath : public RelayWithStatusCallback { 627 class RelayTouchFilePath : public RelayWithStatusCallback {
626 public: 628 public:
627 RelayTouchFilePath(const FilePath& file_path, 629 RelayTouchFilePath(const FilePath& file_path,
628 const base::Time& last_access_time, 630 const base::Time& last_access_time,
629 const base::Time& last_modified_time, 631 const base::Time& last_modified_time,
630 base::FileUtilProxy::StatusCallback* callback) 632 base::FileUtilProxyBase::StatusCallback* callback)
631 : RelayWithStatusCallback(callback), 633 : RelayWithStatusCallback(callback),
632 file_path_(file_path), 634 file_path_(file_path),
633 last_access_time_(last_access_time), 635 last_access_time_(last_access_time),
634 last_modified_time_(last_modified_time) { 636 last_modified_time_(last_modified_time) {
635 } 637 }
636 638
637 protected: 639 protected:
638 virtual void RunWork() { 640 virtual void RunWork() {
639 if (!file_util::TouchFile( 641 if (!file_util::TouchFile(
640 file_path_, last_access_time_, last_modified_time_)) 642 file_path_, last_access_time_, last_modified_time_))
641 set_error_code(base::PLATFORM_FILE_ERROR_FAILED); 643 set_error_code(base::PLATFORM_FILE_ERROR_FAILED);
642 } 644 }
643 645
644 private: 646 private:
645 FilePath file_path_; 647 FilePath file_path_;
646 base::Time last_access_time_; 648 base::Time last_access_time_;
647 base::Time last_modified_time_; 649 base::Time last_modified_time_;
648 }; 650 };
649 651
650 class RelayTruncatePlatformFile : public RelayWithStatusCallback { 652 class RelayTruncatePlatformFile : public RelayWithStatusCallback {
651 public: 653 public:
652 RelayTruncatePlatformFile(base::PlatformFile file, 654 RelayTruncatePlatformFile(base::PlatformFile file,
653 int64 length, 655 int64 length,
654 base::FileUtilProxy::StatusCallback* callback) 656 base::FileUtilProxyBase::StatusCallback* callback)
655 : RelayWithStatusCallback(callback), 657 : RelayWithStatusCallback(callback),
656 file_(file), 658 file_(file),
657 length_(length) { 659 length_(length) {
658 } 660 }
659 661
660 protected: 662 protected:
661 virtual void RunWork() { 663 virtual void RunWork() {
662 if (!base::TruncatePlatformFile(file_, length_)) 664 if (!base::TruncatePlatformFile(file_, length_))
663 set_error_code(base::PLATFORM_FILE_ERROR_FAILED); 665 set_error_code(base::PLATFORM_FILE_ERROR_FAILED);
664 } 666 }
665 667
666 private: 668 private:
667 base::PlatformFile file_; 669 base::PlatformFile file_;
668 int64 length_; 670 int64 length_;
669 }; 671 };
670 672
671 class RelayTruncate : public RelayWithStatusCallback { 673 class RelayTruncate : public RelayWithStatusCallback {
672 public: 674 public:
673 RelayTruncate(const FilePath& path, 675 RelayTruncate(const FilePath& path,
674 int64 length, 676 int64 length,
675 base::FileUtilProxy::StatusCallback* callback) 677 base::FileUtilProxyBase::StatusCallback* callback)
676 : RelayWithStatusCallback(callback), 678 : RelayWithStatusCallback(callback),
677 path_(path), 679 path_(path),
678 length_(length) { 680 length_(length) {
679 } 681 }
680 682
681 protected: 683 protected:
682 virtual void RunWork() { 684 virtual void RunWork() {
683 base::PlatformFileError error_code(base::PLATFORM_FILE_ERROR_FAILED); 685 base::PlatformFileError error_code(base::PLATFORM_FILE_ERROR_FAILED);
684 base::PlatformFile file = 686 base::PlatformFile file =
685 base::CreatePlatformFile( 687 base::CreatePlatformFile(
(...skipping 11 matching lines...) Expand all
697 } 699 }
698 700
699 private: 701 private:
700 FilePath path_; 702 FilePath path_;
701 int64 length_; 703 int64 length_;
702 }; 704 };
703 705
704 class RelayFlush : public RelayWithStatusCallback { 706 class RelayFlush : public RelayWithStatusCallback {
705 public: 707 public:
706 RelayFlush(base::PlatformFile file, 708 RelayFlush(base::PlatformFile file,
707 base::FileUtilProxy::StatusCallback* callback) 709 base::FileUtilProxyBase::StatusCallback* callback)
708 : RelayWithStatusCallback(callback), 710 : RelayWithStatusCallback(callback),
709 file_(file) { 711 file_(file) {
710 } 712 }
711 713
712 protected: 714 protected:
713 virtual void RunWork() { 715 virtual void RunWork() {
714 if (!base::FlushPlatformFile(file_)) 716 if (!base::FlushPlatformFile(file_))
715 set_error_code(base::PLATFORM_FILE_ERROR_FAILED); 717 set_error_code(base::PLATFORM_FILE_ERROR_FAILED);
716 } 718 }
717 719
718 private: 720 private:
719 base::PlatformFile file_; 721 base::PlatformFile file_;
720 }; 722 };
721 723
722 bool Start(const tracked_objects::Location& from_here, 724 bool Start(const tracked_objects::Location& from_here,
723 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, 725 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
724 scoped_refptr<MessageLoopRelay> relay) { 726 scoped_refptr<MessageLoopRelay> relay) {
725 return relay->Start(message_loop_proxy, from_here); 727 return relay->Start(message_loop_proxy, from_here);
726 } 728 }
727 729
728 } // namespace 730 } // namespace
729 731
730 namespace base { 732 namespace base {
731 733
732 // static 734 FileUtilProxy* FileUtilProxy::GetInstance() {
735 return Singleton<FileUtilProxy>::get();
736 }
737
733 bool FileUtilProxy::CreateOrOpen( 738 bool FileUtilProxy::CreateOrOpen(
734 scoped_refptr<MessageLoopProxy> message_loop_proxy, 739 scoped_refptr<MessageLoopProxy> message_loop_proxy,
735 const FilePath& file_path, int file_flags, 740 const FilePath& file_path, int file_flags,
736 CreateOrOpenCallback* callback) { 741 CreateOrOpenCallback* callback) {
737 return Start(FROM_HERE, message_loop_proxy, new RelayCreateOrOpen( 742 return Start(FROM_HERE, message_loop_proxy, new RelayCreateOrOpen(
738 message_loop_proxy, file_path, file_flags, callback)); 743 message_loop_proxy, file_path, file_flags, callback));
739 } 744 }
740 745
741 // static
742 bool FileUtilProxy::CreateTemporary( 746 bool FileUtilProxy::CreateTemporary(
743 scoped_refptr<MessageLoopProxy> message_loop_proxy, 747 scoped_refptr<MessageLoopProxy> message_loop_proxy,
744 CreateTemporaryCallback* callback) { 748 CreateTemporaryCallback* callback) {
745 return Start(FROM_HERE, message_loop_proxy, 749 return Start(FROM_HERE, message_loop_proxy,
746 new RelayCreateTemporary(message_loop_proxy, callback)); 750 new RelayCreateTemporary(message_loop_proxy, callback));
747 } 751 }
748 752
749 // static
750 bool FileUtilProxy::Close(scoped_refptr<MessageLoopProxy> message_loop_proxy, 753 bool FileUtilProxy::Close(scoped_refptr<MessageLoopProxy> message_loop_proxy,
751 base::PlatformFile file_handle, 754 base::PlatformFile file_handle,
752 StatusCallback* callback) { 755 StatusCallback* callback) {
753 return Start(FROM_HERE, message_loop_proxy, 756 return Start(FROM_HERE, message_loop_proxy,
754 new RelayClose(file_handle, callback)); 757 new RelayClose(file_handle, callback));
755 } 758 }
756 759
757 // static
758 bool FileUtilProxy::EnsureFileExists( 760 bool FileUtilProxy::EnsureFileExists(
759 scoped_refptr<MessageLoopProxy> message_loop_proxy, 761 scoped_refptr<MessageLoopProxy> message_loop_proxy,
760 const FilePath& file_path, 762 const FilePath& file_path,
761 EnsureFileExistsCallback* callback) { 763 EnsureFileExistsCallback* callback) {
762 return Start(FROM_HERE, message_loop_proxy, new RelayEnsureFileExists( 764 return Start(FROM_HERE, message_loop_proxy, new RelayEnsureFileExists(
763 message_loop_proxy, file_path, callback)); 765 message_loop_proxy, file_path, callback));
764 } 766 }
765 767
766 // Retrieves the information about a file. It is invalid to pass NULL for the 768 // Retrieves the information about a file. It is invalid to pass NULL for the
767 // callback. 769 // callback.
768 bool FileUtilProxy::GetFileInfo( 770 bool FileUtilProxy::GetFileInfo(
769 scoped_refptr<MessageLoopProxy> message_loop_proxy, 771 scoped_refptr<MessageLoopProxy> message_loop_proxy,
770 const FilePath& file_path, 772 const FilePath& file_path,
771 GetFileInfoCallback* callback) { 773 GetFileInfoCallback* callback) {
772 return Start(FROM_HERE, message_loop_proxy, new RelayGetFileInfo( 774 return Start(FROM_HERE, message_loop_proxy, new RelayGetFileInfo(
773 file_path, callback)); 775 file_path, callback));
774 } 776 }
775 777
776 // static
777 bool FileUtilProxy::GetFileInfoFromPlatformFile( 778 bool FileUtilProxy::GetFileInfoFromPlatformFile(
778 scoped_refptr<MessageLoopProxy> message_loop_proxy, 779 scoped_refptr<MessageLoopProxy> message_loop_proxy,
779 PlatformFile file, 780 PlatformFile file,
780 GetFileInfoCallback* callback) { 781 GetFileInfoCallback* callback) {
781 return Start(FROM_HERE, message_loop_proxy, 782 return Start(FROM_HERE, message_loop_proxy,
782 new RelayGetFileInfoFromPlatformFile(file, callback)); 783 new RelayGetFileInfoFromPlatformFile(file, callback));
783 } 784 }
784 785
785 // static
786 bool FileUtilProxy::ReadDirectory( 786 bool FileUtilProxy::ReadDirectory(
787 scoped_refptr<MessageLoopProxy> message_loop_proxy, 787 scoped_refptr<MessageLoopProxy> message_loop_proxy,
788 const FilePath& file_path, 788 const FilePath& file_path,
789 ReadDirectoryCallback* callback) { 789 ReadDirectoryCallback* callback) {
790 return Start(FROM_HERE, message_loop_proxy, new RelayReadDirectory( 790 return Start(FROM_HERE, message_loop_proxy, new RelayReadDirectory(
791 file_path, callback)); 791 file_path, callback));
792 } 792 }
793 793
794 // static
795 bool FileUtilProxy::CreateDirectory( 794 bool FileUtilProxy::CreateDirectory(
796 scoped_refptr<MessageLoopProxy> message_loop_proxy, 795 scoped_refptr<MessageLoopProxy> message_loop_proxy,
797 const FilePath& file_path, 796 const FilePath& file_path,
798 bool exclusive, 797 bool exclusive,
799 bool recursive, 798 bool recursive,
800 StatusCallback* callback) { 799 StatusCallback* callback) {
801 return Start(FROM_HERE, message_loop_proxy, new RelayCreateDirectory( 800 return Start(FROM_HERE, message_loop_proxy, new RelayCreateDirectory(
802 file_path, exclusive, recursive, callback)); 801 file_path, exclusive, recursive, callback));
803 } 802 }
804 803
805 // static
806 bool FileUtilProxy::Copy(scoped_refptr<MessageLoopProxy> message_loop_proxy, 804 bool FileUtilProxy::Copy(scoped_refptr<MessageLoopProxy> message_loop_proxy,
807 const FilePath& src_file_path, 805 const FilePath& src_file_path,
808 const FilePath& dest_file_path, 806 const FilePath& dest_file_path,
809 StatusCallback* callback) { 807 StatusCallback* callback) {
810 return Start(FROM_HERE, message_loop_proxy, 808 return Start(FROM_HERE, message_loop_proxy,
811 new RelayCopy(src_file_path, dest_file_path, callback)); 809 new RelayCopy(src_file_path, dest_file_path, callback));
812 } 810 }
813 811
814 // static
815 bool FileUtilProxy::Move(scoped_refptr<MessageLoopProxy> message_loop_proxy, 812 bool FileUtilProxy::Move(scoped_refptr<MessageLoopProxy> message_loop_proxy,
816 const FilePath& src_file_path, 813 const FilePath& src_file_path,
817 const FilePath& dest_file_path, 814 const FilePath& dest_file_path,
818 StatusCallback* callback) { 815 StatusCallback* callback) {
819 return Start(FROM_HERE, message_loop_proxy, 816 return Start(FROM_HERE, message_loop_proxy,
820 new RelayMove(src_file_path, dest_file_path, callback)); 817 new RelayMove(src_file_path, dest_file_path, callback));
821 } 818 }
822 819
823 // static
824 bool FileUtilProxy::Delete(scoped_refptr<MessageLoopProxy> message_loop_proxy, 820 bool FileUtilProxy::Delete(scoped_refptr<MessageLoopProxy> message_loop_proxy,
825 const FilePath& file_path, 821 const FilePath& file_path,
826 bool recursive, 822 bool recursive,
827 StatusCallback* callback) { 823 StatusCallback* callback) {
828 return Start(FROM_HERE, message_loop_proxy, 824 return Start(FROM_HERE, message_loop_proxy,
829 new RelayDelete(file_path, recursive, callback)); 825 new RelayDelete(file_path, recursive, callback));
830 } 826 }
831 827
832 // static
833 bool FileUtilProxy::RecursiveDelete( 828 bool FileUtilProxy::RecursiveDelete(
834 scoped_refptr<MessageLoopProxy> message_loop_proxy, 829 scoped_refptr<MessageLoopProxy> message_loop_proxy,
835 const FilePath& file_path, 830 const FilePath& file_path,
836 StatusCallback* callback) { 831 StatusCallback* callback) {
837 return Start(FROM_HERE, message_loop_proxy, 832 return Start(FROM_HERE, message_loop_proxy,
838 new RelayDelete(file_path, true, callback)); 833 new RelayDelete(file_path, true, callback));
839 } 834 }
840 835
841 // static
842 bool FileUtilProxy::Read( 836 bool FileUtilProxy::Read(
843 scoped_refptr<MessageLoopProxy> message_loop_proxy, 837 scoped_refptr<MessageLoopProxy> message_loop_proxy,
844 PlatformFile file, 838 PlatformFile file,
845 int64 offset, 839 int64 offset,
846 char* buffer, 840 char* buffer,
847 int bytes_to_read, 841 int bytes_to_read,
848 ReadWriteCallback* callback) { 842 ReadWriteCallback* callback) {
849 return Start(FROM_HERE, message_loop_proxy, 843 return Start(FROM_HERE, message_loop_proxy,
850 new RelayRead(file, offset, buffer, bytes_to_read, callback)); 844 new RelayRead(file, offset, buffer, bytes_to_read, callback));
851 } 845 }
852 846
853 // static
854 bool FileUtilProxy::Write( 847 bool FileUtilProxy::Write(
855 scoped_refptr<MessageLoopProxy> message_loop_proxy, 848 scoped_refptr<MessageLoopProxy> message_loop_proxy,
856 PlatformFile file, 849 PlatformFile file,
857 int64 offset, 850 int64 offset,
858 const char* buffer, 851 const char* buffer,
859 int bytes_to_write, 852 int bytes_to_write,
860 ReadWriteCallback* callback) { 853 ReadWriteCallback* callback) {
861 return Start(FROM_HERE, message_loop_proxy, 854 return Start(FROM_HERE, message_loop_proxy,
862 new RelayWrite(file, offset, buffer, bytes_to_write, callback)); 855 new RelayWrite(file, offset, buffer, bytes_to_write, callback));
863 } 856 }
864 857
865 // static
866 bool FileUtilProxy::Touch( 858 bool FileUtilProxy::Touch(
867 scoped_refptr<MessageLoopProxy> message_loop_proxy, 859 scoped_refptr<MessageLoopProxy> message_loop_proxy,
868 PlatformFile file, 860 PlatformFile file,
869 const base::Time& last_access_time, 861 const base::Time& last_access_time,
870 const base::Time& last_modified_time, 862 const base::Time& last_modified_time,
871 StatusCallback* callback) { 863 StatusCallback* callback) {
872 return Start(FROM_HERE, message_loop_proxy, 864 return Start(FROM_HERE, message_loop_proxy,
873 new RelayTouch(file, last_access_time, last_modified_time, 865 new RelayTouch(file, last_access_time, last_modified_time,
874 callback)); 866 callback));
875 } 867 }
876 868
877 // static
878 bool FileUtilProxy::Touch( 869 bool FileUtilProxy::Touch(
879 scoped_refptr<MessageLoopProxy> message_loop_proxy, 870 scoped_refptr<MessageLoopProxy> message_loop_proxy,
880 const FilePath& file_path, 871 const FilePath& file_path,
881 const base::Time& last_access_time, 872 const base::Time& last_access_time,
882 const base::Time& last_modified_time, 873 const base::Time& last_modified_time,
883 StatusCallback* callback) { 874 StatusCallback* callback) {
884 return Start(FROM_HERE, message_loop_proxy, 875 return Start(FROM_HERE, message_loop_proxy,
885 new RelayTouchFilePath(file_path, last_access_time, 876 new RelayTouchFilePath(file_path, last_access_time,
886 last_modified_time, callback)); 877 last_modified_time, callback));
887 } 878 }
888 879
889 // static
890 bool FileUtilProxy::Truncate( 880 bool FileUtilProxy::Truncate(
891 scoped_refptr<MessageLoopProxy> message_loop_proxy, 881 scoped_refptr<MessageLoopProxy> message_loop_proxy,
892 PlatformFile file, 882 PlatformFile file,
893 int64 length, 883 int64 length,
894 StatusCallback* callback) { 884 StatusCallback* callback) {
895 return Start(FROM_HERE, message_loop_proxy, 885 return Start(FROM_HERE, message_loop_proxy,
896 new RelayTruncatePlatformFile(file, length, callback)); 886 new RelayTruncatePlatformFile(file, length, callback));
897 } 887 }
898 888
899 // static
900 bool FileUtilProxy::Truncate( 889 bool FileUtilProxy::Truncate(
901 scoped_refptr<MessageLoopProxy> message_loop_proxy, 890 scoped_refptr<MessageLoopProxy> message_loop_proxy,
902 const FilePath& path, 891 const FilePath& path,
903 int64 length, 892 int64 length,
904 StatusCallback* callback) { 893 StatusCallback* callback) {
905 return Start(FROM_HERE, message_loop_proxy, 894 return Start(FROM_HERE, message_loop_proxy,
906 new RelayTruncate(path, length, callback)); 895 new RelayTruncate(path, length, callback));
907 } 896 }
908 897
909 // static
910 bool FileUtilProxy::Flush( 898 bool FileUtilProxy::Flush(
911 scoped_refptr<MessageLoopProxy> message_loop_proxy, 899 scoped_refptr<MessageLoopProxy> message_loop_proxy,
912 PlatformFile file, 900 PlatformFile file,
913 StatusCallback* callback) { 901 StatusCallback* callback) {
914 return Start(FROM_HERE, message_loop_proxy, new RelayFlush(file, callback)); 902 return Start(FROM_HERE, message_loop_proxy, new RelayFlush(file, callback));
915 } 903 }
916 904
917 } // namespace base 905 } // namespace base
OLDNEW
« no previous file with comments | « base/file_util_proxy.h ('k') | base/file_util_proxy_base.h » ('j') | base/file_util_proxy_base.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698