Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2011 Google, Inc. All Rights Reserved. |
| 3 * Copyright (C) 2012 Apple Inc. All Rights Reserved. | 3 * Copyright (C) 2012 Apple Inc. All Rights Reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/frame/DOMWindowProperty.h" | 28 #include "core/frame/DOMWindowProperty.h" |
| 29 | 29 |
| 30 #include "core/frame/LocalDOMWindow.h" | 30 #include "core/frame/LocalDOMWindow.h" |
| 31 #include "core/frame/LocalFrame.h" | 31 #include "core/frame/LocalFrame.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 DOMWindowProperty::DOMWindowProperty(LocalFrame* frame) | 35 DOMWindowProperty::DOMWindowProperty(LocalFrame* frame) |
| 36 : m_frame(frame) | 36 : m_frame(frame) |
| 37 , m_associatedDOMWindow(0) | 37 , m_associatedDOMWindow(nullptr) |
| 38 { | 38 { |
| 39 // FIXME: For now it *is* acceptable for a DOMWindowProperty to be created w ith a null frame. | 39 // FIXME: For now it *is* acceptable for a DOMWindowProperty to be created w ith a null frame. |
| 40 // See fast/dom/navigator-detached-no-crash.html for the recipe. | 40 // See fast/dom/navigator-detached-no-crash.html for the recipe. |
| 41 // We should fix that. <rdar://problem/11567132> | 41 // We should fix that. <rdar://problem/11567132> |
| 42 if (m_frame) { | 42 if (this->frame()) { |
|
haraken
2014/09/08 07:25:57
What is this change for?
sof
2014/09/08 21:17:45
Reverted back (a leftover from an experiment to se
| |
| 43 m_associatedDOMWindow = m_frame->domWindow(); | 43 m_associatedDOMWindow = m_frame->domWindow(); |
| 44 m_associatedDOMWindow->registerProperty(this); | 44 m_associatedDOMWindow->registerProperty(this); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 #if !ENABLE(OILPAN) | |
| 48 DOMWindowProperty::~DOMWindowProperty() | 49 DOMWindowProperty::~DOMWindowProperty() |
|
haraken
2014/09/08 07:25:57
Is it guaranteed that willDestroyGlobalObjectInFra
sof
2014/09/08 21:17:45
LocalDOMWindow::reset() calls willDestroyGlobalObj
| |
| 49 { | 50 { |
| 50 if (m_associatedDOMWindow) | 51 if (m_associatedDOMWindow) |
| 51 m_associatedDOMWindow->unregisterProperty(this); | 52 m_associatedDOMWindow->unregisterProperty(this); |
| 52 | 53 |
| 53 m_associatedDOMWindow = 0; | 54 m_associatedDOMWindow = nullptr; |
| 54 m_frame = 0; | 55 m_frame = nullptr; |
| 55 } | 56 } |
| 57 #endif | |
| 56 | 58 |
| 57 void DOMWindowProperty::willDestroyGlobalObjectInFrame() | 59 void DOMWindowProperty::willDestroyGlobalObjectInFrame() |
| 58 { | 60 { |
| 59 // If the property is getting this callback it must have been created with a LocalFrame/LocalDOMWindow and it should still have them. | 61 // If the property is getting this callback it must have been created with a LocalFrame/LocalDOMWindow and it should still have them. |
| 60 ASSERT(m_frame); | 62 ASSERT(m_frame); |
| 61 ASSERT(m_associatedDOMWindow); | 63 ASSERT(m_associatedDOMWindow); |
| 62 | 64 |
| 63 // DOMWindowProperty lifetime isn't tied directly to the LocalDOMWindow itse lf so it is important that it unregister | 65 // DOMWindowProperty lifetime isn't tied directly to the LocalDOMWindow itse lf so it is important that it unregister |
| 64 // itself from any LocalDOMWindow it is associated with if that LocalDOMWind ow is going away. | 66 // itself from any LocalDOMWindow it is associated with if that LocalDOMWind ow is going away. |
| 65 if (m_associatedDOMWindow) | 67 if (m_associatedDOMWindow) |
| 66 m_associatedDOMWindow->unregisterProperty(this); | 68 m_associatedDOMWindow->unregisterProperty(this); |
| 67 m_associatedDOMWindow = 0; | 69 m_associatedDOMWindow = nullptr; |
| 68 m_frame = 0; | 70 m_frame = nullptr; |
| 69 } | 71 } |
| 70 | 72 |
| 71 void DOMWindowProperty::willDetachGlobalObjectFromFrame() | 73 void DOMWindowProperty::willDetachGlobalObjectFromFrame() |
| 72 { | 74 { |
| 73 // If the property is getting this callback it must have been created with a LocalFrame/LocalDOMWindow and it should still have them. | 75 // If the property is getting this callback it must have been created with a LocalFrame/LocalDOMWindow and it should still have them. |
| 74 ASSERT(m_frame); | 76 ASSERT(m_frame); |
| 75 ASSERT(m_associatedDOMWindow); | 77 ASSERT(m_associatedDOMWindow); |
| 76 } | 78 } |
| 77 | 79 |
| 80 void DOMWindowProperty::trace(Visitor* visitor) | |
| 81 { | |
| 82 visitor->trace(m_frame); | |
| 83 visitor->trace(m_associatedDOMWindow); | |
| 78 } | 84 } |
| 85 | |
| 86 } | |
| OLD | NEW |