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

Side by Side Diff: Source/WebCore/bindings/dart/DartController.cpp

Issue 9837116: DOM wrappers that are not retained from Dart should be collected. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Created 8 years, 9 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 // Copyright (c) 2009, Google Inc. 1 // Copyright (c) 2009, Google Inc.
2 // All rights reserved. 2 // 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 Dart_SetMessageNotifyCallback(&messageNotifyCallback); 90 Dart_SetMessageNotifyCallback(&messageNotifyCallback);
91 initDOMIsolate(); 91 initDOMIsolate();
92 Dart_ExitIsolate(); 92 Dart_ExitIsolate();
93 93
94 DartUtilities::registerDOMIsolate(isolate, applicationLoader, document); 94 DartUtilities::registerDOMIsolate(isolate, applicationLoader, document);
95 RefPtr<DartIsolate> dartIsolate = DartIsolate::create(isolate); 95 RefPtr<DartIsolate> dartIsolate = DartIsolate::create(isolate);
96 DartDebugServer::shared().registerIsolate(dartIsolate.get()); 96 DartDebugServer::shared().registerIsolate(dartIsolate.get());
97 return dartIsolate.release(); 97 return dartIsolate.release();
98 } 98 }
99 99
100 void DartController::shutdownIsolate(DartIsolate* isolate)
101 {
102 Dart_Isolate currentIsolate = Dart_CurrentIsolate();
103 if (currentIsolate)
104 Dart_ExitIsolate();
105 Dart_EnterIsolate(isolate->isolate());
106 Dart_ShutdownIsolate();
107 if (currentIsolate)
108 Dart_EnterIsolate(currentIsolate);
109
110 *DartUtilities::recursionForIsolate(isolate->isolate()) = 0;
111 DartUtilities::unregisterIsolate(isolate->isolate());
112 DartDebugServer::shared().unregisterIsolate(isolate);
113 }
114
115 DartController::DartController(Frame* frame) 100 DartController::DartController(Frame* frame)
116 : m_frame(frame) 101 : m_frame(frame)
117 , m_scriptsLoaded(false) 102 , m_scriptsLoaded(false)
118 , m_isolates() 103 , m_isolates()
119 , m_npObjectMap() 104 , m_npObjectMap()
120 { 105 {
121 // The DartController's constructor must be called in the Frame's 106 // The DartController's constructor must be called in the Frame's
122 // constructor, so it can properly maintain the unit of related 107 // constructor, so it can properly maintain the unit of related
123 // browsing contexts. 108 // browsing contexts.
124 109
125 // The DartController must be created after the frame's loader and 110 // The DartController must be created after the frame's loader and
126 // tree nodes are initialized. 111 // tree nodes are initialized.
127 ASSERT(frame->loader()); 112 ASSERT(frame->loader());
128 ASSERT(frame->tree()); 113 ASSERT(frame->tree());
129 } 114 }
130 115
131 void DartController::clearWindowShell() 116 void DartController::clearWindowShell()
132 { 117 {
133 m_scriptsLoaded = false; 118 m_scriptsLoaded = false;
134
135 for (size_t i = 0; i < m_isolates.size(); ++i) {
136 DartIsolate::Scope scope(m_isolates[i]);
137 // FIXME: clear event listeners.
138 // FIXME: clear console messages.
139 DartDOMMap* domMap = DartUtilities::domMapForCurrentIsolate();
140 for (DartDOMMap::iterator it = domMap->begin(); it != domMap->end(); ++i t)
141 DartDOMWrapper::derefDOMObject(it->second, it->first);
142 }
143
144 m_isolates.clear(); 119 m_isolates.clear();
145 } 120 }
146 121
147 class MessageNotifyTask : public ScriptExecutionContext::Task { 122 class MessageNotifyTask : public ScriptExecutionContext::Task {
148 public: 123 public:
149 explicit MessageNotifyTask(PassRefPtr<DartIsolate> destinationIsolate) 124 explicit MessageNotifyTask(PassRefPtr<DartIsolate> destinationIsolate)
150 : m_destinationIsolate(destinationIsolate) 125 : m_destinationIsolate(destinationIsolate)
151 { } 126 { }
152 127
153 virtual void performTask(ScriptExecutionContext* context) 128 virtual void performTask(ScriptExecutionContext* context)
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 } 482 }
508 483
509 DartController* DartController::retrieve(ScriptExecutionContext* context) 484 DartController* DartController::retrieve(ScriptExecutionContext* context)
510 { 485 {
511 if (!context || !context->isDocument()) 486 if (!context || !context->isDocument())
512 return 0; 487 return 0;
513 return retrieve(static_cast<Document*>(context)->frame()); 488 return retrieve(static_cast<Document*>(context)->frame());
514 } 489 }
515 490
516 } 491 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698