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

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

Issue 2694103004: Cleanup app snapshots on isolate/vm exit. (Closed)
Patch Set: . Created 3 years, 10 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
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 "bin/extensions.h" 8 #include "bin/extensions.h"
9 #include "bin/utils.h" 9 #include "bin/utils.h"
10 #include "bin/utils_win.h" 10 #include "bin/utils_win.h"
11 #include "platform/assert.h"
11 12
12 namespace dart { 13 namespace dart {
13 namespace bin { 14 namespace bin {
14 15
15 const char* kVmSnapshotDataSymbolName = "_kDartVmSnapshotData"; 16 const char* kVmSnapshotDataSymbolName = "_kDartVmSnapshotData";
16 const char* kVmSnapshotInstructionsSymbolName = "_kDartVmSnapshotInstructions"; 17 const char* kVmSnapshotInstructionsSymbolName = "_kDartVmSnapshotInstructions";
17 const char* kIsolateSnapshotDataSymbolName = "_kDartIsolateSnapshotData"; 18 const char* kIsolateSnapshotDataSymbolName = "_kDartIsolateSnapshotData";
18 const char* kIsolateSnapshotInstructionsSymbolName = 19 const char* kIsolateSnapshotInstructionsSymbolName =
19 "_kDartIsolateSnapshotInstructions"; 20 "_kDartIsolateSnapshotInstructions";
20 21
21 void* Extensions::LoadExtensionLibrary(const char* library_file) { 22 void* Extensions::LoadLibrary(const char* library_file) {
22 SetLastError(0); 23 SetLastError(0);
23 24
24 // Convert to wchar_t string. 25 // Convert to wchar_t string.
25 int name_len = MultiByteToWideChar(CP_UTF8, 0, library_file, -1, NULL, 0); 26 int name_len = MultiByteToWideChar(CP_UTF8, 0, library_file, -1, NULL, 0);
26 wchar_t* name; 27 wchar_t* name;
27 name = new wchar_t[name_len]; 28 name = new wchar_t[name_len];
28 MultiByteToWideChar(CP_UTF8, 0, library_file, -1, name, name_len); 29 MultiByteToWideChar(CP_UTF8, 0, library_file, -1, name, name_len);
29 30
30 void* ext = LoadLibraryW(name); 31 void* ext = LoadLibraryW(name);
31 delete[] name; 32 delete[] name;
32 return ext; 33 return ext;
33 } 34 }
34 35
35 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { 36 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) {
36 SetLastError(0); 37 SetLastError(0);
37 return GetProcAddress(reinterpret_cast<HMODULE>(lib_handle), symbol); 38 return GetProcAddress(reinterpret_cast<HMODULE>(lib_handle), symbol);
38 } 39 }
39 40
41 void Extensions::UnloadLibrary(void* lib_handle) {
42 BOOL result = FreeLibrary(reinterpret_cast<HMODULE>(lib_handle));
43 ASSERT(result);
44 }
45
40 Dart_Handle Extensions::GetError() { 46 Dart_Handle Extensions::GetError() {
41 int last_error = GetLastError(); 47 int last_error = GetLastError();
42 if (last_error != 0) { 48 if (last_error != 0) {
43 OSError err; 49 OSError err;
44 return Dart_NewApiError(err.message()); 50 return Dart_NewApiError(err.message());
45 } 51 }
46 return Dart_Null(); 52 return Dart_Null();
47 } 53 }
48 54
49 } // namespace bin 55 } // namespace bin
50 } // namespace dart 56 } // namespace dart
51 57
52 #endif // defined(TARGET_OS_WINDOWS) 58 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698