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

Side by Side Diff: WebCore/bindings/v8/V8ObjectEventListener.cpp

Issue 174381: Merge Webkit 47001 - 20090810 Vitaly Repeshko <vitalyr@quad.spb.corp.google... (Closed) Base URL: svn://chrome-svn/chrome/branches/WebKit/195/
Patch Set: Created 11 years, 4 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
« no previous file with comments | « WebCore/bindings/v8/V8ObjectEventListener.h ('k') | WebCore/bindings/v8/V8Utilities.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 if (proxy) 47 if (proxy)
48 proxy->objectListeners()->remove(listener); 48 proxy->objectListeners()->remove(listener);
49 49
50 // Because the listener is no longer in the list, it must be disconnecte d from the frame to avoid dangling frame pointer 50 // Because the listener is no longer in the list, it must be disconnecte d from the frame to avoid dangling frame pointer
51 // in the destructor. 51 // in the destructor.
52 listener->disconnectFrame(); 52 listener->disconnectFrame();
53 } 53 }
54 listener->disposeListenerObject(); 54 listener->disposeListenerObject();
55 } 55 }
56 56
57 // Object event listeners (such as XmlHttpRequest and MessagePort) are 57 // An object event listener wrapper only holds a weak reference to the
58 // different from listeners on DOM nodes. An object event listener wrapper 58 // JS function. A strong reference can create a cycle.
59 // only holds a weak reference to the JS function. A strong reference can
60 // create a cycle.
61 // 59 //
62 // The lifetime of these objects is bounded by the life time of its JS 60 // The lifetime of these objects is bounded by the life time of the JS
63 // wrapper. So we can create a hidden reference from the JS wrapper to 61 // wrapper of XHR or Node. So we can create a hidden reference from
64 // to its JS function. 62 // the JS wrapper to to its JS function.
65 // 63 //
66 // (map) 64 // (map)
67 // XHR <---------- JS_wrapper 65 // XHR or Node <---------- JS_wrapper
68 // | (hidden) : ^ 66 // | (hidden) : ^
69 // V V : (may reachable by closure) 67 // V V : (may be reachable by closure)
70 // V8_listener --------> JS_function 68 // V8_listener --------> JS_function
71 // (weak) <-- may create a cycle if it is strong 69 // (weak) <-- may create a cycle if it is strong
72 // 70 //
73 // The persistent reference is made weak in the constructor 71 // The persistent reference is made weak in the constructor of
74 // of V8ObjectEventListener. 72 // V8ObjectEventListener.
75 73
76 V8ObjectEventListener::V8ObjectEventListener(Frame* frame, v8::Local<v8::Object> listener, bool isInline) 74 V8ObjectEventListener::V8ObjectEventListener(Frame* frame, v8::Local<v8::Object> listener, bool isInline)
77 : V8EventListener(frame, listener, isInline) 75 : V8EventListener(frame, listener, isInline)
78 { 76 {
79 m_listener.MakeWeak(this, weakObjectEventListenerCallback); 77 m_listener.MakeWeak(this, weakObjectEventListenerCallback);
80 } 78 }
81 79
82 V8ObjectEventListener::~V8ObjectEventListener() 80 V8ObjectEventListener::~V8ObjectEventListener()
83 { 81 {
84 if (m_frame) { 82 if (m_frame) {
85 ASSERT(!m_listener.IsEmpty()); 83 ASSERT(!m_listener.IsEmpty());
86 V8Proxy* proxy = V8Proxy::retrieve(m_frame); 84 V8Proxy* proxy = V8Proxy::retrieve(m_frame);
87 if (proxy) 85 if (proxy)
88 proxy->objectListeners()->remove(this); 86 proxy->objectListeners()->remove(this);
89 } 87 }
90 88
91 disposeListenerObject(); 89 disposeListenerObject();
92 } 90 }
93 91
94 } // namespace WebCore 92 } // namespace WebCore
OLDNEW
« no previous file with comments | « WebCore/bindings/v8/V8ObjectEventListener.h ('k') | WebCore/bindings/v8/V8Utilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698