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

Unified Diff: runtime/bin/directory.h

Issue 1893033002: Fixes memory leak of async directory lister (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add unsupported calls Created 4 years, 8 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 | runtime/bin/directory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory.h
diff --git a/runtime/bin/directory.h b/runtime/bin/directory.h
index 7a1c5d13914e0f8f5daba773f975cb2c49f8d67f..f45571072e45baad1f475b78fb96e44332dd4407 100644
--- a/runtime/bin/directory.h
+++ b/runtime/bin/directory.h
@@ -7,6 +7,7 @@
#include "bin/builtin.h"
#include "bin/dartutils.h"
+#include "bin/reference_counting.h"
#include "bin/thread.h"
#include "platform/globals.h"
@@ -107,9 +108,7 @@ class DirectoryListing {
}
virtual ~DirectoryListing() {
- while (!IsEmpty()) {
- Pop();
- }
+ PopAll();
}
virtual bool HandleDirectory(const char* dir_name) = 0;
@@ -133,6 +132,12 @@ class DirectoryListing {
return top_ == NULL;
}
+ void PopAll() {
+ while (!IsEmpty()) {
+ Pop();
+ }
+ }
+
DirectoryListingEntry* top() const {
return top_;
}
@@ -166,7 +171,8 @@ class DirectoryListing {
};
-class AsyncDirectoryListing : public DirectoryListing {
+class AsyncDirectoryListing : public ReferenceCounted<AsyncDirectoryListing>,
+ public DirectoryListing {
public:
enum Response {
kListFile = 0,
@@ -179,9 +185,12 @@ class AsyncDirectoryListing : public DirectoryListing {
AsyncDirectoryListing(const char* dir_name,
bool recursive,
bool follow_links)
- : DirectoryListing(dir_name, recursive, follow_links) {}
+ : ReferenceCounted(),
+ DirectoryListing(dir_name, recursive, follow_links),
+ array_(NULL),
+ index_(0),
+ length_(0) {}
- virtual ~AsyncDirectoryListing() {}
virtual bool HandleDirectory(const char* dir_name);
virtual bool HandleFile(const char* file_name);
virtual bool HandleLink(const char* file_name);
@@ -200,11 +209,13 @@ class AsyncDirectoryListing : public DirectoryListing {
}
private:
+ virtual ~AsyncDirectoryListing() {}
bool AddFileSystemEntityToResponse(Response response, const char* arg);
CObjectArray* array_;
intptr_t index_;
intptr_t length_;
+ friend class ReferenceCounted<AsyncDirectoryListing>;
DISALLOW_IMPLICIT_CONSTRUCTORS(AsyncDirectoryListing);
};
@@ -238,6 +249,7 @@ class SyncDirectoryListing: public DirectoryListing {
Dart_Handle file_type_;
Dart_Handle link_type_;
+ DISALLOW_ALLOCATION()
DISALLOW_IMPLICIT_CONSTRUCTORS(SyncDirectoryListing);
};
« no previous file with comments | « no previous file | runtime/bin/directory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698