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

Unified Diff: content/child/fileapi/webfilesystem_impl.cc

Issue 102603014: FileAPI: Fix memory leak in WebFileSystemImpl (won't commit) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/fileapi/webfilesystem_impl.cc
diff --git a/content/child/fileapi/webfilesystem_impl.cc b/content/child/fileapi/webfilesystem_impl.cc
index c149afd3ff628eb1ab28634122b38720109e6761..0866c61c7575b089e394af99f07776128f1c816d 100644
--- a/content/child/fileapi/webfilesystem_impl.cc
+++ b/content/child/fileapi/webfilesystem_impl.cc
@@ -42,32 +42,32 @@ base::LazyInstance<base::ThreadLocalPointer<WebFileSystemImpl> >::Leaky
class WaitableCallbackResults {
public:
- static WaitableCallbackResults* MaybeCreate(
+ static scoped_ptr<WaitableCallbackResults> MaybeCreate(
const WebFileSystemCallbacks& callbacks) {
if (callbacks.shouldBlockUntilCompletion())
- return new WaitableCallbackResults;
- return NULL;
+ return make_scoped_ptr(new WaitableCallbackResults);
+ return scoped_ptr<WaitableCallbackResults>();
}
~WaitableCallbackResults() {}
void SetResultsAndSignal(const base::Closure& results_closure) {
results_closure_ = results_closure;
- event_->Signal();
+ event_.Signal();
}
void WaitAndRun() {
{
blink::WebHeap::SafePointScope safe_point;
- event_->Wait();
+ event_.Wait();
}
DCHECK(!results_closure_.is_null());
results_closure_.Run();
}
private:
- WaitableCallbackResults() : event_(new base::WaitableEvent(true, false)) {}
kinuko 2014/03/05 15:23:32 oops.
+ WaitableCallbackResults() : event_(true, false) {}
- base::WaitableEvent* event_;
+ base::WaitableEvent event_;
base::Closure results_closure_;
DISALLOW_COPY_AND_ASSIGN(WaitableCallbackResults);
};
@@ -332,7 +332,7 @@ void WebFileSystemImpl::openFileSystem(
blink::WebFileSystemType type,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
- WaitableCallbackResults* waitable_results =
+ scoped_ptr<WaitableCallbackResults> waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
@@ -341,18 +341,18 @@ void WebFileSystemImpl::openFileSystem(
static_cast<fileapi::FileSystemType>(type),
base::Bind(&OpenFileSystemCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results)),
+ waitable_results.get()),
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results))),
- make_scoped_ptr(waitable_results));
+ waitable_results.get())),
+ waitable_results.Pass());
nhiroki 2014/03/05 15:16:08 Hmm... |waitable_results| can be passed before cal
kinuko 2014/03/05 15:23:32 Was about to comment about it. You could keep a ra
}
void WebFileSystemImpl::resolveURL(
const blink::WebURL& filesystem_url,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
- WaitableCallbackResults* waitable_results =
+ scoped_ptr<WaitableCallbackResults> waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
@@ -360,11 +360,11 @@ void WebFileSystemImpl::resolveURL(
MakeTuple(GURL(filesystem_url),
base::Bind(&ResolveURLCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results)),
+ waitable_results.get()),
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results))),
- make_scoped_ptr(waitable_results));
+ waitable_results.get())),
+ waitable_results.Pass());
}
void WebFileSystemImpl::deleteFileSystem(
@@ -372,7 +372,7 @@ void WebFileSystemImpl::deleteFileSystem(
blink::WebFileSystemType type,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
- WaitableCallbackResults* waitable_results =
+ scoped_ptr<WaitableCallbackResults> waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
@@ -381,8 +381,8 @@ void WebFileSystemImpl::deleteFileSystem(
static_cast<fileapi::FileSystemType>(type),
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results))),
- make_scoped_ptr(waitable_results));
+ waitable_results.get())),
+ waitable_results.Pass());
}
void WebFileSystemImpl::move(
@@ -390,7 +390,7 @@ void WebFileSystemImpl::move(
const blink::WebURL& dest_path,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
- WaitableCallbackResults* waitable_results =
+ scoped_ptr<WaitableCallbackResults> waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
@@ -398,8 +398,8 @@ void WebFileSystemImpl::move(
MakeTuple(GURL(src_path), GURL(dest_path),
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results))),
- make_scoped_ptr(waitable_results));
+ waitable_results.get())),
+ waitable_results.Pass());
}
void WebFileSystemImpl::copy(
@@ -407,7 +407,7 @@ void WebFileSystemImpl::copy(
const blink::WebURL& dest_path,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
- WaitableCallbackResults* waitable_results =
+ scoped_ptr<WaitableCallbackResults> waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
@@ -415,15 +415,15 @@ void WebFileSystemImpl::copy(
MakeTuple(GURL(src_path), GURL(dest_path),
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results))),
- make_scoped_ptr(waitable_results));
+ waitable_results.get())),
+ waitable_results.Pass());
}
void WebFileSystemImpl::remove(
const blink::WebURL& path,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
- WaitableCallbackResults* waitable_results =
+ scoped_ptr<WaitableCallbackResults> waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
@@ -431,15 +431,15 @@ void WebFileSystemImpl::remove(
MakeTuple(GURL(path), false /* recursive */,
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results))),
- make_scoped_ptr(waitable_results));
+ waitable_results.get())),
+ waitable_results.Pass());
}
void WebFileSystemImpl::removeRecursively(
const blink::WebURL& path,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
- WaitableCallbackResults* waitable_results =
+ scoped_ptr<WaitableCallbackResults> waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
@@ -447,15 +447,15 @@ void WebFileSystemImpl::removeRecursively(
MakeTuple(GURL(path), true /* recursive */,
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results))),
- make_scoped_ptr(waitable_results));
+ waitable_results.get())),
+ waitable_results.Pass());
}
void WebFileSystemImpl::readMetadata(
const blink::WebURL& path,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
- WaitableCallbackResults* waitable_results =
+ scoped_ptr<WaitableCallbackResults> waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
@@ -463,11 +463,11 @@ void WebFileSystemImpl::readMetadata(
MakeTuple(GURL(path),
base::Bind(&ReadMetadataCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results)),
+ waitable_results.get()),
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results))),
- make_scoped_ptr(waitable_results));
+ waitable_results.get())),
+ waitable_results.Pass());
}
void WebFileSystemImpl::createFile(
@@ -475,7 +475,7 @@ void WebFileSystemImpl::createFile(
bool exclusive,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
- WaitableCallbackResults* waitable_results =
+ scoped_ptr<WaitableCallbackResults> waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
@@ -483,8 +483,8 @@ void WebFileSystemImpl::createFile(
MakeTuple(GURL(path), exclusive,
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results))),
- make_scoped_ptr(waitable_results));
+ waitable_results.get())),
+ waitable_results.Pass());
}
void WebFileSystemImpl::createDirectory(
@@ -492,7 +492,7 @@ void WebFileSystemImpl::createDirectory(
bool exclusive,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
- WaitableCallbackResults* waitable_results =
+ scoped_ptr<WaitableCallbackResults> waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
@@ -500,15 +500,15 @@ void WebFileSystemImpl::createDirectory(
MakeTuple(GURL(path), exclusive, false /* recursive */,
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results))),
- make_scoped_ptr(waitable_results));
+ waitable_results.get())),
+ waitable_results.Pass());
}
void WebFileSystemImpl::fileExists(
const blink::WebURL& path,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
- WaitableCallbackResults* waitable_results =
+ scoped_ptr<WaitableCallbackResults> waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
@@ -516,15 +516,15 @@ void WebFileSystemImpl::fileExists(
MakeTuple(GURL(path), false /* directory */,
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results))),
- make_scoped_ptr(waitable_results));
+ waitable_results.get())),
+ waitable_results.Pass());
}
void WebFileSystemImpl::directoryExists(
const blink::WebURL& path,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
- WaitableCallbackResults* waitable_results =
+ scoped_ptr<WaitableCallbackResults> waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
@@ -532,15 +532,15 @@ void WebFileSystemImpl::directoryExists(
MakeTuple(GURL(path), true /* directory */,
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results))),
- make_scoped_ptr(waitable_results));
+ waitable_results.get())),
+ waitable_results.Pass());
}
void WebFileSystemImpl::readDirectory(
const blink::WebURL& path,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
- WaitableCallbackResults* waitable_results =
+ scoped_ptr<WaitableCallbackResults> waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
@@ -548,11 +548,11 @@ void WebFileSystemImpl::readDirectory(
MakeTuple(GURL(path),
base::Bind(&ReadDirectoryCallbackAdapater,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results)),
+ waitable_results.get()),
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
-base::Unretained(waitable_results))),
- make_scoped_ptr(waitable_results));
+ waitable_results.get())),
+ waitable_results.Pass());
}
void WebFileSystemImpl::createFileWriter(
@@ -560,7 +560,7 @@ void WebFileSystemImpl::createFileWriter(
blink::WebFileWriterClient* client,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
- WaitableCallbackResults* waitable_results =
+ scoped_ptr<WaitableCallbackResults> waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
@@ -568,19 +568,19 @@ void WebFileSystemImpl::createFileWriter(
MakeTuple(GURL(path),
base::Bind(&CreateFileWriterCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results),
+ waitable_results.get(),
main_thread_loop_, GURL(path), client),
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results))),
- make_scoped_ptr(waitable_results));
+ waitable_results.get())),
+ waitable_results.Pass());
}
void WebFileSystemImpl::createSnapshotFileAndReadMetadata(
const blink::WebURL& path,
WebFileSystemCallbacks callbacks) {
int callbacks_id = RegisterCallbacks(callbacks);
- WaitableCallbackResults* waitable_results =
+ scoped_ptr<WaitableCallbackResults> waitable_results =
WaitableCallbackResults::MaybeCreate(callbacks);
CallDispatcherOnMainThread(
main_thread_loop_.get(),
@@ -588,12 +588,12 @@ void WebFileSystemImpl::createSnapshotFileAndReadMetadata(
MakeTuple(GURL(path),
base::Bind(&CreateSnapshotFileCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results),
+ waitable_results.get(),
main_thread_loop_),
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
- base::Unretained(waitable_results))),
- make_scoped_ptr(waitable_results));
+ waitable_results.get())),
+ waitable_results.Pass());
}
int WebFileSystemImpl::RegisterCallbacks(
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698