| OLD | NEW |
| 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 "base/file_util_proxy.h" | 5 #include "base/file_util_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/location.h" |
| 11 #include "base/message_loop_proxy.h" |
| 10 #include "base/task_runner.h" | 12 #include "base/task_runner.h" |
| 11 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
| 12 | 14 |
| 13 namespace base { | 15 namespace base { |
| 14 | 16 |
| 15 namespace { | 17 namespace { |
| 16 | 18 |
| 17 void CallWithTranslatedParameter(const FileUtilProxy::StatusCallback& callback, | 19 void CallWithTranslatedParameter(const FileUtilProxy::StatusCallback& callback, |
| 18 bool value) { | 20 bool value) { |
| 19 DCHECK(!callback.is_null()); | 21 DCHECK(!callback.is_null()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 scoped_refptr<TaskRunner> task_runner_; | 54 scoped_refptr<TaskRunner> task_runner_; |
| 53 FileUtilProxy::CloseTask close_task_; | 55 FileUtilProxy::CloseTask close_task_; |
| 54 PlatformFile file_handle_; | 56 PlatformFile file_handle_; |
| 55 bool created_; | 57 bool created_; |
| 56 PlatformFileError error_; | 58 PlatformFileError error_; |
| 57 DISALLOW_COPY_AND_ASSIGN(CreateOrOpenHelper); | 59 DISALLOW_COPY_AND_ASSIGN(CreateOrOpenHelper); |
| 58 }; | 60 }; |
| 59 | 61 |
| 60 class CreateTemporaryHelper { | 62 class CreateTemporaryHelper { |
| 61 public: | 63 public: |
| 62 CreateTemporaryHelper(TaskRunner* task_runner) | 64 explicit CreateTemporaryHelper(TaskRunner* task_runner) |
| 63 : task_runner_(task_runner), | 65 : task_runner_(task_runner), |
| 64 file_handle_(kInvalidPlatformFileValue), | 66 file_handle_(kInvalidPlatformFileValue), |
| 65 error_(PLATFORM_FILE_OK) {} | 67 error_(PLATFORM_FILE_OK) {} |
| 66 | 68 |
| 67 ~CreateTemporaryHelper() { | 69 ~CreateTemporaryHelper() { |
| 68 if (file_handle_ != kInvalidPlatformFileValue) { | 70 if (file_handle_ != kInvalidPlatformFileValue) { |
| 69 FileUtilProxy::Close(task_runner_, file_handle_, | 71 FileUtilProxy::Close(task_runner_, file_handle_, |
| 70 FileUtilProxy::StatusCallback()); | 72 FileUtilProxy::StatusCallback()); |
| 71 } | 73 } |
| 72 } | 74 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 127 } |
| 126 | 128 |
| 127 private: | 129 private: |
| 128 PlatformFileError error_; | 130 PlatformFileError error_; |
| 129 PlatformFileInfo file_info_; | 131 PlatformFileInfo file_info_; |
| 130 DISALLOW_COPY_AND_ASSIGN(GetFileInfoHelper); | 132 DISALLOW_COPY_AND_ASSIGN(GetFileInfoHelper); |
| 131 }; | 133 }; |
| 132 | 134 |
| 133 class ReadHelper { | 135 class ReadHelper { |
| 134 public: | 136 public: |
| 135 ReadHelper(int bytes_to_read) | 137 explicit ReadHelper(int bytes_to_read) |
| 136 : buffer_(new char[bytes_to_read]), | 138 : buffer_(new char[bytes_to_read]), |
| 137 bytes_to_read_(bytes_to_read), | 139 bytes_to_read_(bytes_to_read), |
| 138 bytes_read_(0) {} | 140 bytes_read_(0) {} |
| 139 | 141 |
| 140 void RunWork(PlatformFile file, int64 offset) { | 142 void RunWork(PlatformFile file, int64 offset) { |
| 141 bytes_read_ = ReadPlatformFile(file, offset, buffer_.get(), bytes_to_read_); | 143 bytes_read_ = ReadPlatformFile(file, offset, buffer_.get(), bytes_to_read_); |
| 142 } | 144 } |
| 143 | 145 |
| 144 void Reply(const FileUtilProxy::ReadCallback& callback) { | 146 void Reply(const FileUtilProxy::ReadCallback& callback) { |
| 145 if (!callback.is_null()) { | 147 if (!callback.is_null()) { |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 bool FileUtilProxy::RelayClose( | 427 bool FileUtilProxy::RelayClose( |
| 426 TaskRunner* task_runner, | 428 TaskRunner* task_runner, |
| 427 const CloseTask& close_task, | 429 const CloseTask& close_task, |
| 428 PlatformFile file_handle, | 430 PlatformFile file_handle, |
| 429 const StatusCallback& callback) { | 431 const StatusCallback& callback) { |
| 430 return base::PostTaskAndReplyWithResult( | 432 return base::PostTaskAndReplyWithResult( |
| 431 task_runner, FROM_HERE, Bind(close_task, file_handle), callback); | 433 task_runner, FROM_HERE, Bind(close_task, file_handle), callback); |
| 432 } | 434 } |
| 433 | 435 |
| 434 } // namespace base | 436 } // namespace base |
| OLD | NEW |