OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 // completed, the WindowProxy will always be reinitialized, as | 199 // completed, the WindowProxy will always be reinitialized, as |
200 // |DocumentLoader::InstallNewDocument| ends up calling to | 200 // |DocumentLoader::InstallNewDocument| ends up calling to |
201 // |WindowProxy::UpdateDocument|, which reinitializes the WindowProxy. | 201 // |WindowProxy::UpdateDocument|, which reinitializes the WindowProxy. |
202 // | 202 // |
203 // * kFrameIsDetached | 203 // * kFrameIsDetached |
204 // The context was initialized, but its frame has been detached from the DOM. | 204 // The context was initialized, but its frame has been detached from the DOM. |
205 // Note that the context is still alive and author script may have references | 205 // Note that the context is still alive and author script may have references |
206 // to the context and hence author script may run in the context. | 206 // to the context and hence author script may run in the context. |
207 // The spec does not support some of web features such as setTimeout, etc. on | 207 // The spec does not support some of web features such as setTimeout, etc. on |
208 // a detached window. Blink supports less things than the spec. | 208 // a detached window. Blink supports less things than the spec. |
209 // V8PerContextData is cut off from the context. | 209 // V8PerContextData is cut off from the context. |global_proxy_| becomes a |
210 // weak reference so that it's collectable when author script has no | |
211 // reference. | |
210 // - Possible next states: n/a | 212 // - Possible next states: n/a |
211 enum class Lifecycle { | 213 enum class Lifecycle { |
212 // v8::Context is not yet initialized. | 214 // v8::Context is not yet initialized. |
213 kContextIsUninitialized, | 215 kContextIsUninitialized, |
214 // v8::Context is initialized. | 216 // v8::Context is initialized. |
215 kContextIsInitialized, | 217 kContextIsInitialized, |
216 // The global object (inner global) is detached from the global proxy (outer | 218 // The global object (inner global) is detached from the global proxy (outer |
217 // global). | 219 // global). |
218 kGlobalObjectIsDetached, | 220 kGlobalObjectIsDetached, |
219 // The context's frame is detached from the DOM. | 221 // The context's frame is detached from the DOM. |
(...skipping 22 matching lines...) Expand all Loading... | |
242 private: | 244 private: |
243 v8::Isolate* const isolate_; | 245 v8::Isolate* const isolate_; |
244 const Member<Frame> frame_; | 246 const Member<Frame> frame_; |
245 #if DCHECK_IS_ON() | 247 #if DCHECK_IS_ON() |
246 bool is_global_object_attached_ = false; | 248 bool is_global_object_attached_ = false; |
247 #endif | 249 #endif |
248 | 250 |
249 protected: | 251 protected: |
250 // TODO(dcheng): Consider making these private and using getters. | 252 // TODO(dcheng): Consider making these private and using getters. |
251 const RefPtr<DOMWrapperWorld> world_; | 253 const RefPtr<DOMWrapperWorld> world_; |
254 // |global_proxy_| is the root reference from Blink to v8::Context (a strong | |
255 // reference to the global proxy makes the entire context alive). In order to | |
256 // discard the v8::Context, |global_proxy_| needs to be a weak reference or | |
257 // to be destroyed. | |
haraken
2017/04/11 14:32:54
// |global_proxy_| needs to be made a weak referen
| |
252 ScopedPersistent<v8::Object> global_proxy_; | 258 ScopedPersistent<v8::Object> global_proxy_; |
253 Lifecycle lifecycle_; | 259 Lifecycle lifecycle_; |
254 }; | 260 }; |
255 | 261 |
256 } // namespace blink | 262 } // namespace blink |
257 | 263 |
258 #endif // WindowProxy_h | 264 #endif // WindowProxy_h |
OLD | NEW |