Index: base/files/file_proxy.cc |
diff --git a/base/files/file_proxy.cc b/base/files/file_proxy.cc |
index b517761cf0cc4c0f7baae959e454ae5745f10a4c..c84fa2c13fe96550f3fec1da9841cd37dac175b2 100644 |
--- a/base/files/file_proxy.cc |
+++ b/base/files/file_proxy.cc |
@@ -13,12 +13,20 @@ |
#include "base/task_runner.h" |
#include "base/task_runner_util.h" |
+namespace { |
+ |
+void FileDeleter(base::File file) { |
+} |
+ |
+} // namespace |
+ |
namespace base { |
class FileHelper { |
public: |
FileHelper(FileProxy* proxy, File file) |
: file_(file.Pass()), |
+ task_runner_(proxy->task_runner()), |
proxy_(AsWeakPtr(proxy)), |
error_(File::FILE_ERROR_FAILED) { |
} |
@@ -26,10 +34,13 @@ class FileHelper { |
void PassFile() { |
if (proxy_) |
proxy_->SetFile(file_.Pass()); |
+ else if (file_.IsValid()) |
+ task_runner_->PostTask(FROM_HERE, Bind(&FileDeleter, Passed(&file_))); |
} |
protected: |
File file_; |
+ scoped_refptr<TaskRunner> task_runner_; |
willchan no longer on Chromium
2014/04/10 20:27:47
Can this be private? Does it need to be protected?
rvargas (doing something else)
2014/04/10 22:03:51
yes. I made it private (along with proxy_)
|
WeakPtr<FileProxy> proxy_; |
File::Error error_; |
@@ -219,13 +230,12 @@ class WriteHelper : public FileHelper { |
} // namespace |
-FileProxy::FileProxy() : task_runner_(NULL) { |
-} |
- |
FileProxy::FileProxy(TaskRunner* task_runner) : task_runner_(task_runner) { |
} |
FileProxy::~FileProxy() { |
+ if (file_.IsValid()) |
+ task_runner_->PostTask(FROM_HERE, Bind(&FileDeleter, Passed(&file_))); |
} |
bool FileProxy::CreateOrOpen(const FilePath& file_path, |