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::Function> callback = callback_.NewHandle(isolate_); | 195 v8::Handle<v8::Context> context = callback_->CreationContext(); |
196 v8::Handle<v8::Context> context = callback->CreationContext(); | |
197 if (context.IsEmpty()) | 196 if (context.IsEmpty()) |
198 return; | 197 return; |
199 v8::Context::Scope context_scope(context); | 198 v8::Context::Scope context_scope(context); |
200 WebKit::WebScopedMicrotaskSuppression suppression; | 199 WebKit::WebScopedMicrotaskSuppression suppression; |
201 callback->Call(context->Global(), 0, NULL); | 200 callback_->Call(context->Global(), 0, NULL); |
202 } | 201 } |
203 | 202 |
204 extensions::ScopedPersistent<v8::Object> object_; | 203 extensions::ScopedPersistent<v8::Object> object_; |
205 extensions::ScopedPersistent<v8::Function> callback_; | 204 extensions::ScopedPersistent<v8::Function> callback_; |
206 v8::Isolate* isolate_; | 205 v8::Isolate* isolate_; |
207 | 206 |
208 DISALLOW_COPY_AND_ASSIGN(GCCallback); | 207 DISALLOW_COPY_AND_ASSIGN(GCCallback); |
209 }; | 208 }; |
210 | 209 |
211 // void BindToGC(object, callback) | 210 // void BindToGC(object, callback) |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } else { | 363 } else { |
365 arguments.push_back(v8::Null()); | 364 arguments.push_back(v8::Null()); |
366 } | 365 } |
367 (*it)->module_system()->CallModuleMethod("messaging", | 366 (*it)->module_system()->CallModuleMethod("messaging", |
368 "dispatchOnDisconnect", | 367 "dispatchOnDisconnect", |
369 &arguments); | 368 &arguments); |
370 } | 369 } |
371 } | 370 } |
372 | 371 |
373 } // namespace extensions | 372 } // namespace extensions |
OLD | NEW |