OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/files/file_proxy.h" | 5 #include "base/files/file_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/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 FROM_HERE, | 258 FROM_HERE, |
259 Bind(&CreateTemporaryHelper::RunWork, Unretained(helper), | 259 Bind(&CreateTemporaryHelper::RunWork, Unretained(helper), |
260 additional_file_flags), | 260 additional_file_flags), |
261 Bind(&CreateTemporaryHelper::Reply, Owned(helper), callback)); | 261 Bind(&CreateTemporaryHelper::Reply, Owned(helper), callback)); |
262 } | 262 } |
263 | 263 |
264 bool FileProxy::IsValid() const { | 264 bool FileProxy::IsValid() const { |
265 return file_.IsValid(); | 265 return file_.IsValid(); |
266 } | 266 } |
267 | 267 |
| 268 void FileProxy::SetFile(File file) { |
| 269 DCHECK(!file_.IsValid()); |
| 270 file_ = file.Pass(); |
| 271 } |
| 272 |
268 File FileProxy::TakeFile() { | 273 File FileProxy::TakeFile() { |
269 return file_.Pass(); | 274 return file_.Pass(); |
270 } | 275 } |
271 | 276 |
| 277 PlatformFile FileProxy::GetPlatformFile() const { |
| 278 return file_.GetPlatformFile(); |
| 279 } |
| 280 |
272 bool FileProxy::Close(const StatusCallback& callback) { | 281 bool FileProxy::Close(const StatusCallback& callback) { |
273 DCHECK(file_.IsValid()); | 282 DCHECK(file_.IsValid()); |
274 GenericFileHelper* helper = new GenericFileHelper(this, file_.Pass()); | 283 GenericFileHelper* helper = new GenericFileHelper(this, file_.Pass()); |
275 return task_runner_->PostTaskAndReply( | 284 return task_runner_->PostTaskAndReply( |
276 FROM_HERE, | 285 FROM_HERE, |
277 Bind(&GenericFileHelper::Close, Unretained(helper)), | 286 Bind(&GenericFileHelper::Close, Unretained(helper)), |
278 Bind(&GenericFileHelper::Reply, Owned(helper), callback)); | 287 Bind(&GenericFileHelper::Reply, Owned(helper), callback)); |
279 } | 288 } |
280 | 289 |
281 bool FileProxy::GetInfo(const GetFileInfoCallback& callback) { | 290 bool FileProxy::GetInfo(const GetFileInfoCallback& callback) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 349 |
341 bool FileProxy::Flush(const StatusCallback& callback) { | 350 bool FileProxy::Flush(const StatusCallback& callback) { |
342 DCHECK(file_.IsValid()); | 351 DCHECK(file_.IsValid()); |
343 GenericFileHelper* helper = new GenericFileHelper(this, file_.Pass()); | 352 GenericFileHelper* helper = new GenericFileHelper(this, file_.Pass()); |
344 return task_runner_->PostTaskAndReply( | 353 return task_runner_->PostTaskAndReply( |
345 FROM_HERE, | 354 FROM_HERE, |
346 Bind(&GenericFileHelper::Flush, Unretained(helper)), | 355 Bind(&GenericFileHelper::Flush, Unretained(helper)), |
347 Bind(&GenericFileHelper::Reply, Owned(helper), callback)); | 356 Bind(&GenericFileHelper::Reply, Owned(helper), callback)); |
348 } | 357 } |
349 | 358 |
350 void FileProxy::SetFile(File file) { | |
351 DCHECK(!file_.IsValid()); | |
352 file_ = file.Pass(); | |
353 } | |
354 | |
355 } // namespace base | 359 } // namespace base |
OLD | NEW |