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

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

Issue 23463044: Remove duplicated code on Windows (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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
« no previous file with comments | « runtime/bin/builtin_impl_sources.gypi ('k') | runtime/bin/utils_win.h » ('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) 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 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include <process.h> // NOLINT 8 #include <process.h> // NOLINT
9 9
10 #include "bin/builtin.h" 10 #include "bin/builtin.h"
11 #include "bin/process.h" 11 #include "bin/process.h"
12 #include "bin/eventhandler.h" 12 #include "bin/eventhandler.h"
13 #include "bin/log.h" 13 #include "bin/log.h"
14 #include "bin/thread.h" 14 #include "bin/thread.h"
15 #include "bin/utils.h" 15 #include "bin/utils.h"
16 #include "bin/utils_win.h"
16 17
17 18
18 namespace dart { 19 namespace dart {
19 namespace bin { 20 namespace bin {
20 21
21 static const int kReadHandle = 0; 22 static const int kReadHandle = 0;
22 static const int kWriteHandle = 1; 23 static const int kWriteHandle = 1;
23 24
24 25
25 // ProcessInfo is used to map a process id to the process handle, 26 // ProcessInfo is used to map a process id to the process handle,
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 CloseProcessPipe(handles2); 299 CloseProcessPipe(handles2);
299 CloseProcessPipe(handles3); 300 CloseProcessPipe(handles3);
300 CloseProcessPipe(handles4); 301 CloseProcessPipe(handles4);
301 } 302 }
302 303
303 304
304 static int SetOsErrorMessage(char** os_error_message) { 305 static int SetOsErrorMessage(char** os_error_message) {
305 int error_code = GetLastError(); 306 int error_code = GetLastError();
306 static const int kMaxMessageLength = 256; 307 static const int kMaxMessageLength = 256;
307 wchar_t message[kMaxMessageLength]; 308 wchar_t message[kMaxMessageLength];
308 DWORD message_size = 309 FormatMessageIntoBuffer(error_code, message, kMaxMessageLength);
309 FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
310 NULL,
311 error_code,
312 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
313 message,
314 kMaxMessageLength,
315 NULL);
316 if (message_size == 0) {
317 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
318 Log::PrintErr("FormatMessage failed %d\n", GetLastError());
319 }
320 _snwprintf(message, kMaxMessageLength, L"OS Error %d", error_code);
321 }
322 message[kMaxMessageLength - 1] = '\0';
323 *os_error_message = StringUtils::WideToUtf8(message); 310 *os_error_message = StringUtils::WideToUtf8(message);
324 return error_code; 311 return error_code;
325 } 312 }
326 313
327 314
328 typedef BOOL (WINAPI *InitProcThreadAttrListFn)( 315 typedef BOOL (WINAPI *InitProcThreadAttrListFn)(
329 LPPROC_THREAD_ATTRIBUTE_LIST, DWORD, DWORD, PSIZE_T); 316 LPPROC_THREAD_ATTRIBUTE_LIST, DWORD, DWORD, PSIZE_T);
330 317
331 typedef BOOL (WINAPI *UpdateProcThreadAttrFn)( 318 typedef BOOL (WINAPI *UpdateProcThreadAttrFn)(
332 LPPROC_THREAD_ATTRIBUTE_LIST, DWORD, DWORD_PTR, 319 LPPROC_THREAD_ATTRIBUTE_LIST, DWORD, DWORD_PTR,
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 846
860 847
861 intptr_t Process::CurrentProcessId() { 848 intptr_t Process::CurrentProcessId() {
862 return static_cast<intptr_t>(GetCurrentProcessId()); 849 return static_cast<intptr_t>(GetCurrentProcessId());
863 } 850 }
864 851
865 } // namespace bin 852 } // namespace bin
866 } // namespace dart 853 } // namespace dart
867 854
868 #endif // defined(TARGET_OS_WINDOWS) 855 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/bin/builtin_impl_sources.gypi ('k') | runtime/bin/utils_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698