summaryrefslogtreecommitdiffstats
path: root/webkit/support
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-09 14:14:12 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-09 14:14:12 +0000
commit3a7bf22aaf7dd1d9ed4671f4b5859d8b7e86542c (patch)
tree4e2a8e2967b61849ab1d7742bc87dc80734dd29d /webkit/support
parent770d6a89638d340c3bad7970614923dc17e54d8c (diff)
downloadchromium_src-3a7bf22aaf7dd1d9ed4671f4b5859d8b7e86542c.zip
chromium_src-3a7bf22aaf7dd1d9ed4671f4b5859d8b7e86542c.tar.gz
chromium_src-3a7bf22aaf7dd1d9ed4671f4b5859d8b7e86542c.tar.bz2
Replace all CreateFileSystemOperation with FileSystemOperationRunner
FileSystemOperation consumers should no longer worry about Operation memory leak. BUG=176444 TEST=existing tests R=benjhayden@chromium.org, kinaba@chromium.org, thestig@chromium.org, tzik@chromium.org Review URL: https://codereview.chromium.org/16452002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205121 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/support')
-rw-r--r--webkit/support/simple_file_system.cc43
-rw-r--r--webkit/support/simple_file_system.h2
-rw-r--r--webkit/support/simple_file_writer.cc34
3 files changed, 37 insertions, 42 deletions
diff --git a/webkit/support/simple_file_system.cc b/webkit/support/simple_file_system.cc
index 67309f1..b2aa728 100644
--- a/webkit/support/simple_file_system.cc
+++ b/webkit/support/simple_file_system.cc
@@ -23,6 +23,7 @@
#include "webkit/browser/blob/blob_storage_controller.h"
#include "webkit/browser/fileapi/file_permission_policy.h"
#include "webkit/browser/fileapi/file_system_mount_point_provider.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/browser/fileapi/mock_file_system_context.h"
#include "webkit/common/fileapi/directory_entry.h"
@@ -133,8 +134,8 @@ void SimpleFileSystem::move(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(src_url)->Move(src_url, dest_url,
- FinishHandler(callbacks));
+ file_system_context_->operation_runner()->Move(
+ src_url, dest_url, FinishHandler(callbacks));
}
void SimpleFileSystem::copy(
@@ -147,8 +148,8 @@ void SimpleFileSystem::copy(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(src_url)->Copy(src_url, dest_url,
- FinishHandler(callbacks));
+ file_system_context_->operation_runner()->Copy(
+ src_url, dest_url, FinishHandler(callbacks));
}
void SimpleFileSystem::remove(
@@ -158,8 +159,8 @@ void SimpleFileSystem::remove(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->Remove(url, false /* recursive */,
- FinishHandler(callbacks));
+ file_system_context_->operation_runner()->Remove(
+ url, false /* recursive */, FinishHandler(callbacks));
}
void SimpleFileSystem::removeRecursively(
@@ -169,8 +170,8 @@ void SimpleFileSystem::removeRecursively(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->Remove(url, true /* recursive */,
- FinishHandler(callbacks));
+ file_system_context_->operation_runner()->Remove(
+ url, true /* recursive */, FinishHandler(callbacks));
}
void SimpleFileSystem::readMetadata(
@@ -180,7 +181,8 @@ void SimpleFileSystem::readMetadata(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->GetMetadata(url, GetMetadataHandler(callbacks));
+ file_system_context_->operation_runner()->GetMetadata(
+ url, GetMetadataHandler(callbacks));
}
void SimpleFileSystem::createFile(
@@ -190,7 +192,8 @@ void SimpleFileSystem::createFile(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->CreateFile(url, exclusive, FinishHandler(callbacks));
+ file_system_context_->operation_runner()->CreateFile(
+ url, exclusive, FinishHandler(callbacks));
}
void SimpleFileSystem::createDirectory(
@@ -200,8 +203,8 @@ void SimpleFileSystem::createDirectory(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->CreateDirectory(url, exclusive, false,
- FinishHandler(callbacks));
+ file_system_context_->operation_runner()->CreateDirectory(
+ url, exclusive, false, FinishHandler(callbacks));
}
void SimpleFileSystem::fileExists(
@@ -211,7 +214,8 @@ void SimpleFileSystem::fileExists(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->FileExists(url, FinishHandler(callbacks));
+ file_system_context_->operation_runner()->FileExists(
+ url, FinishHandler(callbacks));
}
void SimpleFileSystem::directoryExists(
@@ -221,7 +225,8 @@ void SimpleFileSystem::directoryExists(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->DirectoryExists(url, FinishHandler(callbacks));
+ file_system_context_->operation_runner()->DirectoryExists(
+ url, FinishHandler(callbacks));
}
void SimpleFileSystem::readDirectory(
@@ -231,7 +236,8 @@ void SimpleFileSystem::readDirectory(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->ReadDirectory(url, ReadDirectoryHandler(callbacks));
+ file_system_context_->operation_runner()->ReadDirectory(
+ url, ReadDirectoryHandler(callbacks));
}
WebFileWriter* SimpleFileSystem::createFileWriter(
@@ -247,7 +253,7 @@ void SimpleFileSystem::createSnapshotFileAndReadMetadata(
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
- GetNewOperation(url)->CreateSnapshotFile(
+ file_system_context_->operation_runner()->CreateSnapshotFile(
url, SnapshotFileHandler(callbacks));
}
@@ -277,11 +283,6 @@ bool SimpleFileSystem::HasFilePermission(
!= fileapi::FILE_PERMISSION_ALWAYS_DENY);
}
-FileSystemOperation* SimpleFileSystem::GetNewOperation(
- const fileapi::FileSystemURL& url) {
- return file_system_context_->CreateFileSystemOperation(url, NULL);
-}
-
FileSystemOperation::StatusCallback
SimpleFileSystem::FinishHandler(WebFileSystemCallbacks* callbacks) {
return base::Bind(&SimpleFileSystem::DidFinish,
diff --git a/webkit/support/simple_file_system.h b/webkit/support/simple_file_system.h
index 6430aa0..9d9f315 100644
--- a/webkit/support/simple_file_system.h
+++ b/webkit/support/simple_file_system.h
@@ -99,8 +99,6 @@ class SimpleFileSystem
private:
// Helpers.
bool HasFilePermission(const fileapi::FileSystemURL& url, int permissions);
- fileapi::FileSystemOperation* GetNewOperation(
- const fileapi::FileSystemURL& url);
// Callback Handlers
fileapi::FileSystemOperation::StatusCallback FinishHandler(
diff --git a/webkit/support/simple_file_writer.cc b/webkit/support/simple_file_writer.cc
index b372fd1..98de70b 100644
--- a/webkit/support/simple_file_writer.cc
+++ b/webkit/support/simple_file_writer.cc
@@ -10,7 +10,7 @@
#include "base/message_loop_proxy.h"
#include "net/url_request/url_request_context.h"
#include "webkit/browser/fileapi/file_system_context.h"
-#include "webkit/browser/fileapi/file_system_operation.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/common/fileapi/file_system_types.h"
#include "webkit/glue/webkit_glue.h"
@@ -18,7 +18,7 @@
using fileapi::FileSystemURL;
using fileapi::FileSystemContext;
-using fileapi::FileSystemOperation;
+using fileapi::FileSystemOperationRunner;
using fileapi::WebFileWriterBase;
using WebKit::WebFileWriterClient;
using WebKit::WebString;
@@ -35,7 +35,7 @@ class SimpleFileWriter::IOThreadProxy
IOThreadProxy(const base::WeakPtr<SimpleFileWriter>& simple_writer,
FileSystemContext* file_system_context)
: simple_writer_(simple_writer),
- operation_(NULL),
+ operation_id_(FileSystemOperationRunner::kErrorOperationID),
file_system_context_(file_system_context) {
// The IO thread needs to be running for this class to work.
SimpleResourceLoaderBridge::EnsureIOThread();
@@ -52,10 +52,9 @@ class SimpleFileWriter::IOThreadProxy
}
if (FailIfNotWritable(url))
return;
- DCHECK(!operation_);
- operation_ = GetNewOperation(url);
- operation_->Truncate(url, offset,
- base::Bind(&IOThreadProxy::DidFinish, this));
+ DCHECK_EQ(FileSystemOperationRunner::kErrorOperationID, operation_id_);
+ operation_id_ = file_system_context_->operation_runner()->Truncate(
+ url, offset, base::Bind(&IOThreadProxy::DidFinish, this));
}
void Write(const FileSystemURL& url, const GURL& blob_url, int64 offset) {
@@ -68,10 +67,10 @@ class SimpleFileWriter::IOThreadProxy
if (FailIfNotWritable(url))
return;
DCHECK(request_context_);
- DCHECK(!operation_);
- operation_ = GetNewOperation(url);
- operation_->Write(request_context_, url, blob_url, offset,
- base::Bind(&IOThreadProxy::DidWrite, this));
+ DCHECK_EQ(FileSystemOperationRunner::kErrorOperationID, operation_id_);
+ operation_id_ = file_system_context_->operation_runner()->Write(
+ request_context_, url, blob_url, offset,
+ base::Bind(&IOThreadProxy::DidWrite, this));
}
void Cancel() {
@@ -81,21 +80,18 @@ class SimpleFileWriter::IOThreadProxy
base::Bind(&IOThreadProxy::Cancel, this));
return;
}
- if (!operation_) {
+ if (operation_id_ == FileSystemOperationRunner::kErrorOperationID) {
DidFailOnMainThread(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
return;
}
- operation_->Cancel(base::Bind(&IOThreadProxy::DidFinish, this));
+ file_system_context_->operation_runner()->Cancel(
+ operation_id_, base::Bind(&IOThreadProxy::DidFinish, this));
}
private:
friend class base::RefCountedThreadSafe<IOThreadProxy>;
virtual ~IOThreadProxy() {}
- FileSystemOperation* GetNewOperation( const FileSystemURL& url) {
- return file_system_context_->CreateFileSystemOperation(url, NULL);
- }
-
// Returns true if it is not writable.
bool FailIfNotWritable(const FileSystemURL& url) {
if (url.type() == fileapi::kFileSystemTypeDragged) {
@@ -142,7 +138,7 @@ class SimpleFileWriter::IOThreadProxy
void ClearOperation() {
DCHECK(io_thread_->BelongsToCurrentThread());
- operation_ = NULL;
+ operation_id_ = FileSystemOperationRunner::kErrorOperationID;
}
void DidFinish(base::PlatformFileError result) {
@@ -171,7 +167,7 @@ class SimpleFileWriter::IOThreadProxy
base::WeakPtr<SimpleFileWriter> simple_writer_;
// Only used on the io thread.
- FileSystemOperation* operation_;
+ FileSystemOperationRunner::OperationID operation_id_;
scoped_refptr<FileSystemContext> file_system_context_;
};