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

Side by Side Diff: runtime/bin/isolate_data.h

Issue 2463923002: Don't use IsolateData for the exit hook as multiple embedders share the dart/bin while using differ… (Closed)
Patch Set: check secondary Created 4 years, 1 month 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 | « no previous file | runtime/bin/main.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) 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 #ifndef RUNTIME_BIN_ISOLATE_DATA_H_ 5 #ifndef RUNTIME_BIN_ISOLATE_DATA_H_
6 #define RUNTIME_BIN_ISOLATE_DATA_H_ 6 #define RUNTIME_BIN_ISOLATE_DATA_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/globals.h" 10 #include "platform/globals.h"
11 11
12 namespace dart { 12 namespace dart {
13 namespace bin { 13 namespace bin {
14 14
15 // Forward declaration. 15 // Forward declaration.
16 class EventHandler; 16 class EventHandler;
17 class Loader; 17 class Loader;
18 18
19 typedef void (*ExitHook)(int64_t exit_code);
20
21 // Data associated with every isolate in the standalone VM 19 // Data associated with every isolate in the standalone VM
22 // embedding. This is used to free external resources for each isolate 20 // embedding. This is used to free external resources for each isolate
23 // when the isolate shuts down. 21 // when the isolate shuts down.
24 class IsolateData { 22 class IsolateData {
25 public: 23 public:
26 IsolateData(const char* url, 24 IsolateData(const char* url,
27 const char* package_root, 25 const char* package_root,
28 const char* packages_file) 26 const char* packages_file)
29 : script_url((url != NULL) ? strdup(url) : NULL), 27 : script_url((url != NULL) ? strdup(url) : NULL),
30 package_root(NULL), 28 package_root(NULL),
31 packages_file(NULL), 29 packages_file(NULL),
32 udp_receive_buffer(NULL), 30 udp_receive_buffer(NULL),
33 builtin_lib_(NULL), 31 builtin_lib_(NULL),
34 loader_(NULL), 32 loader_(NULL) {
35 exit_hook_(NULL) {
36 if (package_root != NULL) { 33 if (package_root != NULL) {
37 ASSERT(packages_file == NULL); 34 ASSERT(packages_file == NULL);
38 this->package_root = strdup(package_root); 35 this->package_root = strdup(package_root);
39 } else if (packages_file != NULL) { 36 } else if (packages_file != NULL) {
40 this->packages_file = strdup(packages_file); 37 this->packages_file = strdup(packages_file);
41 } 38 }
42 } 39 }
43 40
44 ~IsolateData() { 41 ~IsolateData() {
45 free(script_url); 42 free(script_url);
(...skipping 14 matching lines...) Expand all
60 ASSERT(!Dart_IsError(builtin_lib_)); 57 ASSERT(!Dart_IsError(builtin_lib_));
61 return builtin_lib_; 58 return builtin_lib_;
62 } 59 }
63 void set_builtin_lib(Dart_Handle lib) { 60 void set_builtin_lib(Dart_Handle lib) {
64 ASSERT(builtin_lib_ == NULL); 61 ASSERT(builtin_lib_ == NULL);
65 ASSERT(lib != NULL); 62 ASSERT(lib != NULL);
66 ASSERT(!Dart_IsError(lib)); 63 ASSERT(!Dart_IsError(lib));
67 builtin_lib_ = Dart_NewPersistentHandle(lib); 64 builtin_lib_ = Dart_NewPersistentHandle(lib);
68 } 65 }
69 66
70 ExitHook exit_hook() const { return exit_hook_; }
71 void set_exit_hook(ExitHook hook) { exit_hook_ = hook; }
72
73 char* script_url; 67 char* script_url;
74 char* package_root; 68 char* package_root;
75 char* packages_file; 69 char* packages_file;
76 uint8_t* udp_receive_buffer; 70 uint8_t* udp_receive_buffer;
77 71
78 // While loading a loader is associated with the isolate. 72 // While loading a loader is associated with the isolate.
79 bool HasLoader() const { return loader_ != NULL; } 73 bool HasLoader() const { return loader_ != NULL; }
80 Loader* loader() const { 74 Loader* loader() const {
81 ASSERT(loader_ != NULL); 75 ASSERT(loader_ != NULL);
82 return loader_; 76 return loader_;
83 } 77 }
84 void set_loader(Loader* loader) { 78 void set_loader(Loader* loader) {
85 ASSERT((loader_ == NULL) || (loader == NULL)); 79 ASSERT((loader_ == NULL) || (loader == NULL));
86 loader_ = loader; 80 loader_ = loader;
87 } 81 }
88 82
89 private: 83 private:
90 Dart_Handle builtin_lib_; 84 Dart_Handle builtin_lib_;
91 Loader* loader_; 85 Loader* loader_;
92 ExitHook exit_hook_;
93 86
94 DISALLOW_COPY_AND_ASSIGN(IsolateData); 87 DISALLOW_COPY_AND_ASSIGN(IsolateData);
95 }; 88 };
96 89
97 } // namespace bin 90 } // namespace bin
98 } // namespace dart 91 } // namespace dart
99 92
100 #endif // RUNTIME_BIN_ISOLATE_DATA_H_ 93 #endif // RUNTIME_BIN_ISOLATE_DATA_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698