@@ -44,7 +44,7 @@ bool IsSwitchEnabled(base::CommandLine* command_line,
44
44
return true ;
45
45
}
46
46
47
- // Helper class to forward the WillReleaseScriptContext message to the client.
47
+ // Helper class to forward the messages to the client.
48
48
class AtomRenderFrameObserver : public content ::RenderFrameObserver {
49
49
public:
50
50
AtomRenderFrameObserver (content::RenderFrame* frame,
@@ -53,11 +53,6 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
53
53
renderer_client_ (renderer_client) {}
54
54
55
55
// content::RenderFrameObserver:
56
- void WillReleaseScriptContext (v8::Handle<v8::Context> context,
57
- int world_id) override {
58
- renderer_client_->WillReleaseScriptContext (
59
- render_frame ()->GetWebFrame (), context, world_id);
60
- }
61
56
void DidClearWindowObject () override {
62
57
renderer_client_->DidClearWindowObject ();
63
58
}
@@ -135,9 +130,12 @@ void AtomRendererClient::DidCreateScriptContext(blink::WebFrame* frame,
135
130
v8::Handle<v8::Context> context,
136
131
int extension_group,
137
132
int world_id) {
133
+ // Only attach node bindings in main frame.
134
+ if (main_frame_)
135
+ return ;
136
+
138
137
// The first web frame is the main frame.
139
- if (main_frame_ == nullptr )
140
- main_frame_ = frame;
138
+ main_frame_ = frame;
141
139
142
140
v8::Context::Scope scope (context);
143
141
@@ -155,9 +153,6 @@ void AtomRendererClient::DidCreateScriptContext(blink::WebFrame* frame,
155
153
// Add atom-shell extended APIs.
156
154
atom_bindings_->BindTo (env->isolate (), env->process_object ());
157
155
158
- // Store the created environment.
159
- web_page_envs_.push_back (env);
160
-
161
156
// Make uv loop being wrapped by window context.
162
157
if (node_bindings_->uv_env () == nullptr )
163
158
node_bindings_->set_uv_env (env);
@@ -169,38 +164,6 @@ void AtomRendererClient::DidCreateScriptContext(blink::WebFrame* frame,
169
164
void AtomRendererClient::DidClearWindowObject () {
170
165
}
171
166
172
- void AtomRendererClient::WillReleaseScriptContext (
173
- blink::WebLocalFrame* frame,
174
- v8::Handle<v8::Context> context,
175
- int world_id) {
176
- node::Environment* env = node::Environment::GetCurrent (context);
177
- if (env == nullptr ) {
178
- LOG (ERROR) << " Encounter a non-node context when releasing script context" ;
179
- return ;
180
- }
181
-
182
- // Clear the environment.
183
- web_page_envs_.erase (
184
- std::remove (web_page_envs_.begin (), web_page_envs_.end (), env),
185
- web_page_envs_.end ());
186
-
187
- // Notice that we are not disposing the environment object here, because there
188
- // may still be pending uv operations in the uv loop, and when they got done
189
- // they would be needing the original environment.
190
- // So we are leaking the environment object here, just like Chrome leaking the
191
- // memory :) . Since it's only leaked when refreshing or unloading, so as long
192
- // as we make sure renderer process is restared then the memory would not be
193
- // leaked.
194
- // env->Dispose();
195
-
196
- // Wrap the uv loop with another environment.
197
- if (env == node_bindings_->uv_env ()) {
198
- node::Environment* env = web_page_envs_.size () > 0 ? web_page_envs_[0 ] :
199
- nullptr ;
200
- node_bindings_->set_uv_env (env);
201
- }
202
- }
203
-
204
167
bool AtomRendererClient::ShouldFork (blink::WebFrame* frame,
205
168
const GURL& url,
206
169
const std::string& http_method,
0 commit comments