OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/renderer/extensions/messaging_bindings.h" | 5 #include "chrome/renderer/extensions/messaging_bindings.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 base::Bind(&GCCallback::RunCallback, base::Owned(self))); | 185 base::Bind(&GCCallback::RunCallback, base::Owned(self))); |
186 } | 186 } |
187 | 187 |
188 GCCallback(v8::Handle<v8::Object> object, | 188 GCCallback(v8::Handle<v8::Object> object, |
189 v8::Handle<v8::Function> callback, | 189 v8::Handle<v8::Function> callback, |
190 v8::Isolate* isolate) | 190 v8::Isolate* isolate) |
191 : object_(object), callback_(callback), isolate_(isolate) {} | 191 : object_(object), callback_(callback), isolate_(isolate) {} |
192 | 192 |
193 void RunCallback() { | 193 void RunCallback() { |
194 v8::HandleScope handle_scope(isolate_); | 194 v8::HandleScope handle_scope(isolate_); |
195 v8::Handle<v8::Context> context = callback_->CreationContext(); | 195 v8::Handle<v8::Function> callback = callback_.NewHandle(isolate_); |
| 196 v8::Handle<v8::Context> context = callback->CreationContext(); |
196 if (context.IsEmpty()) | 197 if (context.IsEmpty()) |
197 return; | 198 return; |
198 v8::Context::Scope context_scope(context); | 199 v8::Context::Scope context_scope(context); |
199 WebKit::WebScopedMicrotaskSuppression suppression; | 200 WebKit::WebScopedMicrotaskSuppression suppression; |
200 callback_->Call(context->Global(), 0, NULL); | 201 callback->Call(context->Global(), 0, NULL); |
201 } | 202 } |
202 | 203 |
203 extensions::ScopedPersistent<v8::Object> object_; | 204 extensions::ScopedPersistent<v8::Object> object_; |
204 extensions::ScopedPersistent<v8::Function> callback_; | 205 extensions::ScopedPersistent<v8::Function> callback_; |
205 v8::Isolate* isolate_; | 206 v8::Isolate* isolate_; |
206 | 207 |
207 DISALLOW_COPY_AND_ASSIGN(GCCallback); | 208 DISALLOW_COPY_AND_ASSIGN(GCCallback); |
208 }; | 209 }; |
209 | 210 |
210 // void BindToGC(object, callback) | 211 // void BindToGC(object, callback) |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 } else { | 364 } else { |
364 arguments.push_back(v8::Null()); | 365 arguments.push_back(v8::Null()); |
365 } | 366 } |
366 (*it)->module_system()->CallModuleMethod("messaging", | 367 (*it)->module_system()->CallModuleMethod("messaging", |
367 "dispatchOnDisconnect", | 368 "dispatchOnDisconnect", |
368 &arguments); | 369 &arguments); |
369 } | 370 } |
370 } | 371 } |
371 | 372 |
372 } // namespace extensions | 373 } // namespace extensions |
OLD | NEW |