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

Side by Side Diff: Source/core/frame/DOMWindowProperty.cpp

Issue 569643002: Simplify and weaken DOMWindowProperty unregistration (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add test Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 #if !ENABLE(OILPAN)
49 DOMWindowProperty::~DOMWindowProperty() 49 DOMWindowProperty::~DOMWindowProperty()
50 { 50 {
51 if (m_associatedDOMWindow) 51 if (m_associatedDOMWindow)
52 m_associatedDOMWindow->unregisterProperty(this); 52 m_associatedDOMWindow->unregisterProperty(this);
53
54 m_associatedDOMWindow = nullptr;
55 m_frame = nullptr;
56 } 53 }
57 #endif 54 #endif
58 55
59 void DOMWindowProperty::willDestroyGlobalObjectInFrame() 56 void DOMWindowProperty::willDestroyGlobalObjectInFrame()
60 { 57 {
61 // If the property is getting this callback it must have been created with a LocalFrame/LocalDOMWindow and it should still have them. 58 // If the property is getting this callback it must have been created with a LocalFrame/LocalDOMWindow and it should still have them.
62 ASSERT(m_frame); 59 ASSERT(m_frame);
63 ASSERT(m_associatedDOMWindow); 60 ASSERT(m_associatedDOMWindow);
64 61
65 // DOMWindowProperty lifetime isn't tied directly to the LocalDOMWindow itse lf so it is important that it unregister 62 // LocalDOMWindow will along with notifying DOMWindowProperty objects of
66 // itself from any LocalDOMWindow it is associated with if that LocalDOMWind ow is going away. 63 // impending destruction, unilaterally clear out its registered set.
67 if (m_associatedDOMWindow) 64 // Consequently, no explicit unregisteration required by DOMWindowProperty;
68 m_associatedDOMWindow->unregisterProperty(this); 65 // here or when finalized.
69 m_associatedDOMWindow = nullptr; 66 m_associatedDOMWindow = nullptr;
70 m_frame = nullptr; 67 m_frame = nullptr;
71 } 68 }
72 69
73 void DOMWindowProperty::willDetachGlobalObjectFromFrame() 70 void DOMWindowProperty::willDetachGlobalObjectFromFrame()
74 { 71 {
75 // If the property is getting this callback it must have been created with a LocalFrame/LocalDOMWindow and it should still have them. 72 // If the property is getting this callback it must have been created with a LocalFrame/LocalDOMWindow and it should still have them.
76 ASSERT(m_frame); 73 ASSERT(m_frame);
77 ASSERT(m_associatedDOMWindow); 74 ASSERT(m_associatedDOMWindow);
78 } 75 }
79 76
80 void DOMWindowProperty::trace(Visitor* visitor) 77 void DOMWindowProperty::trace(Visitor* visitor)
81 { 78 {
82 visitor->trace(m_associatedDOMWindow); 79 visitor->trace(m_associatedDOMWindow);
83 } 80 }
84 81
85 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698