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

Unified Diff: runtime/bin/directory.h

Issue 11748017: Add synchronous directory listing to dart:io Directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments, move tests that fail on Windows due to VM bug 7157 to a separate test file. Created 7 years, 12 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 | « runtime/bin/builtin_natives.cc ('k') | 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 9455bbbc7c2f65fd4a04c1eb1c6939ea3f0132be..b038ad1b28feda0b5a6a91d5abcf9ed5dc0f3993 100644
--- a/runtime/bin/directory.h
+++ b/runtime/bin/directory.h
@@ -12,6 +12,15 @@
class DirectoryListing {
public:
+ virtual ~DirectoryListing() {}
+ virtual bool HandleDirectory(char* dir_name) = 0;
+ virtual bool HandleFile(char* file_name) = 0;
+ virtual bool HandleError(const char* dir_name) = 0;
+};
+
+
+class AsyncDirectoryListing : public DirectoryListing {
+ public:
enum Response {
kListDirectory = 0,
kListFile = 1,
@@ -19,17 +28,43 @@ class DirectoryListing {
kListDone = 3
};
- explicit DirectoryListing(Dart_Port response_port)
+ explicit AsyncDirectoryListing(Dart_Port response_port)
: response_port_(response_port) {}
- bool HandleDirectory(char* dir_name);
- bool HandleFile(char* file_name);
- bool HandleError(const char* dir_name);
+ virtual ~AsyncDirectoryListing() {}
+ virtual bool HandleDirectory(char* dir_name);
+ virtual bool HandleFile(char* file_name);
+ virtual bool HandleError(const char* dir_name);
private:
CObjectArray* NewResponse(Response response, char* arg);
Dart_Port response_port_;
- DISALLOW_IMPLICIT_CONSTRUCTORS(DirectoryListing);
+ DISALLOW_IMPLICIT_CONSTRUCTORS(AsyncDirectoryListing);
+};
+
+
+class SyncDirectoryListing: public DirectoryListing {
+ public:
+ explicit SyncDirectoryListing(Dart_Handle results)
+ : results_(results) {
+ add_string_ = DartUtils::NewString("add");
+ directory_class_ =
+ DartUtils::GetDartClass(DartUtils::kIOLibURL, "Directory");
+ file_class_ =
+ DartUtils::GetDartClass(DartUtils::kIOLibURL, "File");
+ }
+ virtual ~SyncDirectoryListing() {}
+ virtual bool HandleDirectory(char* dir_name);
+ virtual bool HandleFile(char* file_name);
+ virtual bool HandleError(const char* dir_name);
+
+ private:
+ Dart_Handle results_;
+ Dart_Handle add_string_;
+ Dart_Handle directory_class_;
+ Dart_Handle file_class_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(SyncDirectoryListing);
};
« no previous file with comments | « runtime/bin/builtin_natives.cc ('k') | runtime/bin/directory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698