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

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

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 #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 class AppSnapshot;
zra 2017/02/15 04:41:40 Alphabetize.
rmacnak 2017/02/16 03:05:30 Done.
18 19
19 // Data associated with every isolate in the standalone VM 20 // Data associated with every isolate in the standalone VM
20 // embedding. This is used to free external resources for each isolate 21 // embedding. This is used to free external resources for each isolate
21 // when the isolate shuts down. 22 // when the isolate shuts down.
22 class IsolateData { 23 class IsolateData {
23 public: 24 public:
24 IsolateData(const char* url, 25 IsolateData(const char* url,
25 const char* package_root, 26 const char* package_root,
26 const char* packages_file) 27 const char* packages_file,
27 : script_url((url != NULL) ? strdup(url) : NULL), 28 AppSnapshot* app_snapshot);
28 package_root(NULL), 29 ~IsolateData();
29 packages_file(NULL),
30 udp_receive_buffer(NULL),
31 builtin_lib_(NULL),
32 loader_(NULL) {
33 if (package_root != NULL) {
34 ASSERT(packages_file == NULL);
35 this->package_root = strdup(package_root);
36 } else if (packages_file != NULL) {
37 this->packages_file = strdup(packages_file);
38 }
39 }
40
41 ~IsolateData() {
42 free(script_url);
43 script_url = NULL;
44 free(package_root);
45 package_root = NULL;
46 free(packages_file);
47 packages_file = NULL;
48 free(udp_receive_buffer);
49 udp_receive_buffer = NULL;
50 if (builtin_lib_ != NULL) {
51 Dart_DeletePersistentHandle(builtin_lib_);
52 }
53 }
54 30
55 Dart_Handle builtin_lib() const { 31 Dart_Handle builtin_lib() const {
56 ASSERT(builtin_lib_ != NULL); 32 ASSERT(builtin_lib_ != NULL);
57 ASSERT(!Dart_IsError(builtin_lib_)); 33 ASSERT(!Dart_IsError(builtin_lib_));
58 return builtin_lib_; 34 return builtin_lib_;
59 } 35 }
60 void set_builtin_lib(Dart_Handle lib) { 36 void set_builtin_lib(Dart_Handle lib) {
61 ASSERT(builtin_lib_ == NULL); 37 ASSERT(builtin_lib_ == NULL);
62 ASSERT(lib != NULL); 38 ASSERT(lib != NULL);
63 ASSERT(!Dart_IsError(lib)); 39 ASSERT(!Dart_IsError(lib));
(...skipping 12 matching lines...) Expand all
76 return loader_; 52 return loader_;
77 } 53 }
78 void set_loader(Loader* loader) { 54 void set_loader(Loader* loader) {
79 ASSERT((loader_ == NULL) || (loader == NULL)); 55 ASSERT((loader_ == NULL) || (loader == NULL));
80 loader_ = loader; 56 loader_ = loader;
81 } 57 }
82 58
83 private: 59 private:
84 Dart_Handle builtin_lib_; 60 Dart_Handle builtin_lib_;
85 Loader* loader_; 61 Loader* loader_;
62 AppSnapshot* app_snapshot_;
86 63
87 DISALLOW_COPY_AND_ASSIGN(IsolateData); 64 DISALLOW_COPY_AND_ASSIGN(IsolateData);
88 }; 65 };
89 66
90 } // namespace bin 67 } // namespace bin
91 } // namespace dart 68 } // namespace dart
92 69
93 #endif // RUNTIME_BIN_ISOLATE_DATA_H_ 70 #endif // RUNTIME_BIN_ISOLATE_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698