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

Unified Diff: runtime/bin/file_system_watcher.cc

Issue 98773002: Rewrite file-system-watcher to better handle the different system APIs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Android impl and doc fix. Created 7 years 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/file_system_watcher.h ('k') | runtime/bin/file_system_watcher_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file_system_watcher.cc
diff --git a/runtime/bin/file_system_watcher.cc b/runtime/bin/file_system_watcher.cc
index 7893ffb4d8b2c51ffc2526de3212d2ed9c3aab87..0260be7b5904ab76c22c1e32ad3b9d0585f804c3 100644
--- a/runtime/bin/file_system_watcher.cc
+++ b/runtime/bin/file_system_watcher.cc
@@ -12,54 +12,57 @@
namespace dart {
namespace bin {
-static const int kWatcherNativeField = 0;
+void FUNCTION_NAME(FileSystemWatcher_IsSupported)(Dart_NativeArguments args) {
+ Dart_SetReturnValue(args, Dart_NewBoolean(FileSystemWatcher::IsSupported()));
+}
-void SetWatcherIdNativeField(Dart_Handle watcher, intptr_t id) {
- ThrowIfError(Dart_SetNativeInstanceField(watcher, kWatcherNativeField, id));
+void FUNCTION_NAME(FileSystemWatcher_InitWatcher)(Dart_NativeArguments args) {
+ Dart_SetReturnValue(args, Dart_NewInteger(FileSystemWatcher::Init()));
}
-void GetWatcherIdNativeField(Dart_Handle watcher, intptr_t* id) {
- ThrowIfError(Dart_GetNativeInstanceField(watcher, kWatcherNativeField, id));
+void FUNCTION_NAME(FileSystemWatcher_CloseWatcher)(Dart_NativeArguments args) {
+ intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0));
+ FileSystemWatcher::Close(id);
}
-void FUNCTION_NAME(FileSystemWatcher_IsSupported)(Dart_NativeArguments args) {
- Dart_SetReturnValue(args, Dart_NewBoolean(FileSystemWatcher::IsSupported()));
-}
void FUNCTION_NAME(FileSystemWatcher_WatchPath)(Dart_NativeArguments args) {
- Dart_Handle watcher = Dart_GetNativeArgument(args, 0);
+ intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0));
const char* path = DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1));
int events = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2));
bool recursive = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3));
- intptr_t id = FileSystemWatcher::WatchPath(path, events, recursive);
- if (id == -1) {
+ intptr_t path_id = FileSystemWatcher::WatchPath(id, path, events, recursive);
+ if (path_id == -1) {
Dart_ThrowException(DartUtils::NewDartOSError());
- } else {
- SetWatcherIdNativeField(watcher, id);
}
- intptr_t socket_id = FileSystemWatcher::GetSocketId(id);
- Dart_SetReturnValue(args, Dart_NewInteger(socket_id));
+ Dart_SetReturnValue(args, Dart_NewInteger(path_id));
}
void FUNCTION_NAME(FileSystemWatcher_UnwatchPath)(Dart_NativeArguments args) {
- Dart_Handle watcher = Dart_GetNativeArgument(args, 0);
- intptr_t id;
- GetWatcherIdNativeField(watcher, &id);
- FileSystemWatcher::UnwatchPath(id);
+ intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0));
+ intptr_t path_id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
+ FileSystemWatcher::UnwatchPath(id, path_id);
}
void FUNCTION_NAME(FileSystemWatcher_ReadEvents)(Dart_NativeArguments args) {
- Dart_Handle watcher = Dart_GetNativeArgument(args, 0);
- intptr_t id;
- GetWatcherIdNativeField(watcher, &id);
- Dart_Handle handle = FileSystemWatcher::ReadEvents(id);
+ intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0));
+ intptr_t path_id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
+ Dart_Handle handle = FileSystemWatcher::ReadEvents(id, path_id);
ThrowIfError(handle);
Dart_SetReturnValue(args, handle);
}
+
+void FUNCTION_NAME(FileSystemWatcher_GetSocketId)(Dart_NativeArguments args) {
+ intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0));
+ intptr_t path_id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
+ int socket_id = FileSystemWatcher::GetSocketId(id, path_id);
+ Dart_SetReturnValue(args, Dart_NewInteger(socket_id));
+}
+
} // namespace bin
} // namespace dart
« no previous file with comments | « runtime/bin/file_system_watcher.h ('k') | runtime/bin/file_system_watcher_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698