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

Side by Side 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: Avoid memory leak of DirectorySyncLister. Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef BIN_DIRECTORY_H_ 5 #ifndef BIN_DIRECTORY_H_
6 #define BIN_DIRECTORY_H_ 6 #define BIN_DIRECTORY_H_
7 7
8 #include "bin/builtin.h" 8 #include "bin/builtin.h"
9 #include "bin/dartutils.h" 9 #include "bin/dartutils.h"
10 #include "platform/globals.h" 10 #include "platform/globals.h"
11 #include "platform/thread.h" 11 #include "platform/thread.h"
12 12
13 class DirectoryListing { 13 class DirectoryListing {
14 public: 14 public:
15 virtual bool HandleDirectory(char* dir_name) = 0;
16 virtual bool HandleFile(char* file_name) = 0;
17 virtual bool HandleError(const char* dir_name) = 0;
18
19 virtual ~DirectoryListing() {}
20 };
21
22
23 class DirectoryAsyncListing : public DirectoryListing {
Mads Ager (google) 2013/01/04 10:00:25 Can we make this AsyncDirectoryListing? I think th
Bill Hesse 2013/01/04 13:49:27 Done.
24 public:
15 enum Response { 25 enum Response {
16 kListDirectory = 0, 26 kListDirectory = 0,
17 kListFile = 1, 27 kListFile = 1,
18 kListError = 2, 28 kListError = 2,
19 kListDone = 3 29 kListDone = 3
20 }; 30 };
21 31
22 explicit DirectoryListing(Dart_Port response_port) 32 explicit DirectoryAsyncListing(Dart_Port response_port)
23 : response_port_(response_port) {} 33 : response_port_(response_port) {}
24 bool HandleDirectory(char* dir_name); 34 virtual bool HandleDirectory(char* dir_name);
25 bool HandleFile(char* file_name); 35 virtual bool HandleFile(char* file_name);
26 bool HandleError(const char* dir_name); 36 virtual bool HandleError(const char* dir_name);
27 37
38 virtual ~DirectoryAsyncListing() {}
Mads Ager (google) 2013/01/04 10:00:25 Destructor above methods, please. http://google-s
Bill Hesse 2013/01/04 13:49:27 Done.
28 private: 39 private:
29 CObjectArray* NewResponse(Response response, char* arg); 40 CObjectArray* NewResponse(Response response, char* arg);
30 Dart_Port response_port_; 41 Dart_Port response_port_;
31 42
32 DISALLOW_IMPLICIT_CONSTRUCTORS(DirectoryListing); 43 DISALLOW_IMPLICIT_CONSTRUCTORS(DirectoryAsyncListing);
33 }; 44 };
34 45
35 46
47 class DirectorySyncListing: public DirectoryListing {
Mads Ager (google) 2013/01/04 10:00:25 SyncDirectoryListing?
Bill Hesse 2013/01/04 13:49:27 Done.
48 public:
49 explicit DirectorySyncListing(Dart_Handle results)
50 : results_(results) {
51 add_ = DartUtils::NewString("add");
Mads Ager (google) 2013/01/04 10:00:25 add_string_?
Bill Hesse 2013/01/04 13:49:27 Done.
52 directory_class_ =
53 DartUtils::GetDartClass(DartUtils::kIOLibURL, "Directory");
54 file_class_ =
55 DartUtils::GetDartClass(DartUtils::kIOLibURL, "File");
56 }
57 virtual bool HandleDirectory(char* dir_name);
58 virtual bool HandleFile(char* file_name);
59 virtual bool HandleError(const char* dir_name);
60
61 virtual ~DirectorySyncListing() {}
Mads Ager (google) 2013/01/04 10:00:25 Destructor before methods, please.
Bill Hesse 2013/01/04 13:49:27 Done.
62 private:
63 Dart_Handle results_;
64 Dart_Handle add_;
65 Dart_Handle directory_class_;
66 Dart_Handle file_class_;
67
68 DISALLOW_IMPLICIT_CONSTRUCTORS(DirectorySyncListing);
69 };
70
71
36 class Directory { 72 class Directory {
37 public: 73 public:
38 enum ExistsResult { 74 enum ExistsResult {
39 UNKNOWN, 75 UNKNOWN,
40 EXISTS, 76 EXISTS,
41 DOES_NOT_EXIST 77 DOES_NOT_EXIST
42 }; 78 };
43 79
44 // This enum must be kept in sync with the request values in 80 // This enum must be kept in sync with the request values in
45 // directory_impl.dart. 81 // directory_impl.dart.
(...skipping 22 matching lines...) Expand all
68 static int service_ports_size_; 104 static int service_ports_size_;
69 static Dart_Port* service_ports_; 105 static Dart_Port* service_ports_;
70 static int service_ports_index_; 106 static int service_ports_index_;
71 107
72 DISALLOW_ALLOCATION(); 108 DISALLOW_ALLOCATION();
73 DISALLOW_IMPLICIT_CONSTRUCTORS(Directory); 109 DISALLOW_IMPLICIT_CONSTRUCTORS(Directory);
74 }; 110 };
75 111
76 112
77 #endif // BIN_DIRECTORY_H_ 113 #endif // BIN_DIRECTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698