| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
| 7 | 7 |
| 8 #include "bin/file_system_watcher.h" | 8 #include "bin/file_system_watcher.h" |
| 9 | 9 |
| 10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
| 11 #include <fcntl.h> // NOLINT | 11 #include <fcntl.h> // NOLINT |
| 12 #include <unistd.h> // NOLINT | 12 #include <unistd.h> // NOLINT |
| 13 #include <CoreServices/CoreServices.h> // NOLINT | 13 #include <CoreServices/CoreServices.h> // NOLINT |
| 14 | 14 |
| 15 #include "bin/eventhandler.h" | 15 #include "bin/eventhandler.h" |
| 16 #include "bin/fdutils.h" | 16 #include "bin/fdutils.h" |
| 17 #include "bin/file.h" | 17 #include "bin/file.h" |
| 18 #include "bin/socket.h" | 18 #include "bin/socket.h" |
| 19 #include "bin/thread.h" | 19 #include "bin/thread.h" |
| 20 | 20 |
| 21 #include "platform/signal_blocker.h" |
| 22 |
| 21 | 23 |
| 22 #ifndef MAC_OS_X_VERSION_10_7 | 24 #ifndef MAC_OS_X_VERSION_10_7 |
| 23 enum { | 25 enum { |
| 24 kFSEventStreamCreateFlagFileEvents = 0x00000010 | 26 kFSEventStreamCreateFlagFileEvents = 0x00000010 |
| 25 }; | 27 }; |
| 26 enum { | 28 enum { |
| 27 kFSEventStreamEventFlagItemCreated = 0x00000100, | 29 kFSEventStreamEventFlagItemCreated = 0x00000100, |
| 28 kFSEventStreamEventFlagItemRemoved = 0x00000200, | 30 kFSEventStreamEventFlagItemRemoved = 0x00000200, |
| 29 kFSEventStreamEventFlagItemInodeMetaMod = 0x00000400, | 31 kFSEventStreamEventFlagItemInodeMetaMod = 0x00000400, |
| 30 kFSEventStreamEventFlagItemRenamed = 0x00000800, | 32 kFSEventStreamEventFlagItemRenamed = 0x00000800, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 NULL, base_path, kCFStringEncodingUTF8)), | 66 NULL, base_path, kCFStringEncodingUTF8)), |
| 65 read_fd_(read_fd), | 67 read_fd_(read_fd), |
| 66 write_fd_(write_fd), | 68 write_fd_(write_fd), |
| 67 recursive_(recursive), | 69 recursive_(recursive), |
| 68 ref_(NULL) { | 70 ref_(NULL) { |
| 69 Start(); | 71 Start(); |
| 70 } | 72 } |
| 71 | 73 |
| 72 ~Node() { | 74 ~Node() { |
| 73 Stop(); | 75 Stop(); |
| 74 close(write_fd_); | 76 VOID_TEMP_FAILURE_RETRY(close(write_fd_)); |
| 75 CFRelease(path_ref_); | 77 CFRelease(path_ref_); |
| 76 } | 78 } |
| 77 | 79 |
| 78 void set_ref(FSEventStreamRef ref) { | 80 void set_ref(FSEventStreamRef ref) { |
| 79 ref_ = ref; | 81 ref_ = ref; |
| 80 } | 82 } |
| 81 | 83 |
| 82 void Start() { | 84 void Start() { |
| 83 // Schedule StartCallback to be executed in the RunLoop. | 85 // Schedule StartCallback to be executed in the RunLoop. |
| 84 CFRunLoopTimerContext context; | 86 CFRunLoopTimerContext context; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 Monitor& monitor() { return monitor_; } | 256 Monitor& monitor() { return monitor_; } |
| 255 | 257 |
| 256 bool has_run_loop() const { return run_loop_ != NULL; } | 258 bool has_run_loop() const { return run_loop_ != NULL; } |
| 257 | 259 |
| 258 static void TimerCallback(CFRunLoopTimerRef timer, void* context) { | 260 static void TimerCallback(CFRunLoopTimerRef timer, void* context) { |
| 259 // Dummy callback to keep RunLoop alive. | 261 // Dummy callback to keep RunLoop alive. |
| 260 } | 262 } |
| 261 | 263 |
| 262 Node* AddPath(const char* path, int events, bool recursive) { | 264 Node* AddPath(const char* path, int events, bool recursive) { |
| 263 int fds[2]; | 265 int fds[2]; |
| 264 VOID_TEMP_FAILURE_RETRY(pipe(fds)); | 266 VOID_NO_RETRY_EXPECTED(pipe(fds)); |
| 265 Socket::SetNonBlocking(fds[0]); | 267 Socket::SetNonBlocking(fds[0]); |
| 266 Socket::SetBlocking(fds[1]); | 268 Socket::SetBlocking(fds[1]); |
| 267 | 269 |
| 268 char base_path[PATH_MAX]; | 270 char base_path[PATH_MAX]; |
| 269 realpath(path, base_path); | 271 realpath(path, base_path); |
| 270 | 272 |
| 271 return new Node(this, base_path, fds[0], fds[1], recursive); | 273 return new Node(this, base_path, fds[0], fds[1], recursive); |
| 272 } | 274 } |
| 273 | 275 |
| 274 private: | 276 private: |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 } | 388 } |
| 387 return events; | 389 return events; |
| 388 } | 390 } |
| 389 | 391 |
| 390 } // namespace bin | 392 } // namespace bin |
| 391 } // namespace dart | 393 } // namespace dart |
| 392 | 394 |
| 393 #endif // defined(TARGET_OS_MACOS) | 395 #endif // defined(TARGET_OS_MACOS) |
| 394 | 396 |
| 395 | 397 |
| OLD | NEW |