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

Side by Side Diff: runtime/bin/file_system_watcher_win.cc

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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
« no previous file with comments | « runtime/bin/file_system_watcher_unsupported.cc ('k') | runtime/bin/file_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if !defined(DART_IO_DISABLED) 5 #if !defined(DART_IO_DISABLED)
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #if defined(HOST_OS_WINDOWS) 8 #if defined(HOST_OS_WINDOWS)
9 9
10 #include "bin/file_system_watcher.h" 10 #include "bin/file_system_watcher.h"
11 11
12 #include <WinIoCtl.h> // NOLINT 12 #include <WinIoCtl.h> // NOLINT
13 13
14 #include "bin/builtin.h" 14 #include "bin/builtin.h"
15 #include "bin/eventhandler.h" 15 #include "bin/eventhandler.h"
16 #include "bin/log.h" 16 #include "bin/log.h"
17 #include "bin/utils.h" 17 #include "bin/utils.h"
18 #include "bin/utils_win.h" 18 #include "bin/utils_win.h"
19 19
20 namespace dart { 20 namespace dart {
21 namespace bin { 21 namespace bin {
22 22
23 bool FileSystemWatcher::IsSupported() { 23 bool FileSystemWatcher::IsSupported() {
24 return true; 24 return true;
25 } 25 }
26 26
27
28 intptr_t FileSystemWatcher::Init() { 27 intptr_t FileSystemWatcher::Init() {
29 return 0; 28 return 0;
30 } 29 }
31 30
32
33 void FileSystemWatcher::Close(intptr_t id) { 31 void FileSystemWatcher::Close(intptr_t id) {
34 USE(id); 32 USE(id);
35 } 33 }
36 34
37
38 intptr_t FileSystemWatcher::WatchPath(intptr_t id, 35 intptr_t FileSystemWatcher::WatchPath(intptr_t id,
39 const char* path, 36 const char* path,
40 int events, 37 int events,
41 bool recursive) { 38 bool recursive) {
42 USE(id); 39 USE(id);
43 Utf8ToWideScope name(path); 40 Utf8ToWideScope name(path);
44 HANDLE dir = CreateFileW( 41 HANDLE dir = CreateFileW(
45 name.wide(), FILE_LIST_DIRECTORY, 42 name.wide(), FILE_LIST_DIRECTORY,
46 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, 43 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL,
47 OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL); 44 OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL);
(...skipping 12 matching lines...) Expand all
60 57
61 DirectoryWatchHandle* handle = 58 DirectoryWatchHandle* handle =
62 new DirectoryWatchHandle(dir, list_events, recursive); 59 new DirectoryWatchHandle(dir, list_events, recursive);
63 // Issue a read directly, to be sure events are tracked from now on. This is 60 // Issue a read directly, to be sure events are tracked from now on. This is
64 // okay, since in Dart, we create the socket and start reading immidiately. 61 // okay, since in Dart, we create the socket and start reading immidiately.
65 handle->EnsureInitialized(EventHandler::delegate()); 62 handle->EnsureInitialized(EventHandler::delegate());
66 handle->IssueRead(); 63 handle->IssueRead();
67 return reinterpret_cast<intptr_t>(handle); 64 return reinterpret_cast<intptr_t>(handle);
68 } 65 }
69 66
70
71 void FileSystemWatcher::UnwatchPath(intptr_t id, intptr_t path_id) { 67 void FileSystemWatcher::UnwatchPath(intptr_t id, intptr_t path_id) {
72 USE(id); 68 USE(id);
73 DirectoryWatchHandle* handle = 69 DirectoryWatchHandle* handle =
74 reinterpret_cast<DirectoryWatchHandle*>(path_id); 70 reinterpret_cast<DirectoryWatchHandle*>(path_id);
75 handle->Stop(); 71 handle->Stop();
76 } 72 }
77 73
78
79 intptr_t FileSystemWatcher::GetSocketId(intptr_t id, intptr_t path_id) { 74 intptr_t FileSystemWatcher::GetSocketId(intptr_t id, intptr_t path_id) {
80 USE(id); 75 USE(id);
81 return path_id; 76 return path_id;
82 } 77 }
83 78
84
85 Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) { 79 Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
86 USE(id); 80 USE(id);
87 const intptr_t kEventSize = sizeof(FILE_NOTIFY_INFORMATION); 81 const intptr_t kEventSize = sizeof(FILE_NOTIFY_INFORMATION);
88 DirectoryWatchHandle* dir = reinterpret_cast<DirectoryWatchHandle*>(path_id); 82 DirectoryWatchHandle* dir = reinterpret_cast<DirectoryWatchHandle*>(path_id);
89 intptr_t available = dir->Available(); 83 intptr_t available = dir->Available();
90 intptr_t max_count = available / kEventSize + 1; 84 intptr_t max_count = available / kEventSize + 1;
91 Dart_Handle events = Dart_NewList(max_count); 85 Dart_Handle events = Dart_NewList(max_count);
92 uint8_t* buffer = Dart_ScopeAllocate(available); 86 uint8_t* buffer = Dart_ScopeAllocate(available);
93 intptr_t bytes = dir->Read(buffer, available); 87 intptr_t bytes = dir->Read(buffer, available);
94 intptr_t offset = 0; 88 intptr_t offset = 0;
(...skipping 15 matching lines...) Expand all
110 } 104 }
111 if (e->Action == FILE_ACTION_RENAMED_OLD_NAME) { 105 if (e->Action == FILE_ACTION_RENAMED_OLD_NAME) {
112 mask |= kMove; 106 mask |= kMove;
113 } 107 }
114 if (e->Action == FILE_ACTION_RENAMED_NEW_NAME) { 108 if (e->Action == FILE_ACTION_RENAMED_NEW_NAME) {
115 mask |= kMove; 109 mask |= kMove;
116 } 110 }
117 Dart_ListSetAt(event, 0, Dart_NewInteger(mask)); 111 Dart_ListSetAt(event, 0, Dart_NewInteger(mask));
118 // Move events come in pairs. Just 'enable' by default. 112 // Move events come in pairs. Just 'enable' by default.
119 Dart_ListSetAt(event, 1, Dart_NewInteger(1)); 113 Dart_ListSetAt(event, 1, Dart_NewInteger(1));
120 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF16( 114 Dart_ListSetAt(
121 reinterpret_cast<uint16_t*>(e->FileName), 115 event, 2,
122 e->FileNameLength / 2)); 116 Dart_NewStringFromUTF16(reinterpret_cast<uint16_t*>(e->FileName),
117 e->FileNameLength / 2));
123 Dart_ListSetAt(event, 3, Dart_NewBoolean(true)); 118 Dart_ListSetAt(event, 3, Dart_NewBoolean(true));
124 Dart_ListSetAt(event, 4, Dart_NewInteger(path_id)); 119 Dart_ListSetAt(event, 4, Dart_NewInteger(path_id));
125 Dart_ListSetAt(events, i, event); 120 Dart_ListSetAt(events, i, event);
126 i++; 121 i++;
127 if (e->NextEntryOffset == 0) { 122 if (e->NextEntryOffset == 0) {
128 break; 123 break;
129 } 124 }
130 offset += e->NextEntryOffset; 125 offset += e->NextEntryOffset;
131 } 126 }
132 return events; 127 return events;
133 } 128 }
134 129
135 } // namespace bin 130 } // namespace bin
136 } // namespace dart 131 } // namespace dart
137 132
138 #endif // defined(HOST_OS_WINDOWS) 133 #endif // defined(HOST_OS_WINDOWS)
139 134
140 #endif // !defined(DART_IO_DISABLED) 135 #endif // !defined(DART_IO_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/file_system_watcher_unsupported.cc ('k') | runtime/bin/file_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698