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/miscellaneous_bindings.h" | 5 #include "chrome/renderer/extensions/miscellaneous_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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 : object(object), callback(callback) {} | 157 : object(object), callback(callback) {} |
158 | 158 |
159 extensions::ScopedPersistent<v8::Object> object; | 159 extensions::ScopedPersistent<v8::Object> object; |
160 extensions::ScopedPersistent<v8::Function> callback; | 160 extensions::ScopedPersistent<v8::Function> callback; |
161 | 161 |
162 private: | 162 private: |
163 DISALLOW_COPY_AND_ASSIGN(GCCallbackArgs); | 163 DISALLOW_COPY_AND_ASSIGN(GCCallbackArgs); |
164 }; | 164 }; |
165 | 165 |
166 static void GCCallback(v8::Isolate* isolate, | 166 static void GCCallback(v8::Isolate* isolate, |
167 v8::Persistent<v8::Value> object, | 167 v8::Persistent<v8::Object>* object, |
168 void* parameter) { | 168 GCCallbackArgs* args) { |
169 v8::HandleScope handle_scope; | 169 v8::HandleScope handle_scope; |
170 GCCallbackArgs* args = static_cast<GCCallbackArgs*>(parameter); | |
171 v8::Handle<v8::Context> context = args->callback->CreationContext(); | 170 v8::Handle<v8::Context> context = args->callback->CreationContext(); |
172 v8::Context::Scope context_scope(context); | 171 v8::Context::Scope context_scope(context); |
173 WebKit::WebScopedMicrotaskSuppression suppression; | 172 WebKit::WebScopedMicrotaskSuppression suppression; |
174 // Wrap in try/catch here so that we don't call into any message/exception | 173 // Wrap in try/catch here so that we don't call into any message/exception |
175 // handlers during GC. That is a recipe for pain. | 174 // handlers during GC. That is a recipe for pain. |
176 v8::TryCatch trycatch; | 175 v8::TryCatch trycatch; |
177 args->callback->Call(context->Global(), 0, NULL); | 176 args->callback->Call(context->Global(), 0, NULL); |
178 delete args; | 177 delete args; |
179 } | 178 } |
180 | 179 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 } else { | 333 } else { |
335 arguments.push_back(v8::Null()); | 334 arguments.push_back(v8::Null()); |
336 } | 335 } |
337 (*it)->CallChromeHiddenMethod("Port.dispatchOnDisconnect", | 336 (*it)->CallChromeHiddenMethod("Port.dispatchOnDisconnect", |
338 arguments.size(), &arguments[0], | 337 arguments.size(), &arguments[0], |
339 NULL); | 338 NULL); |
340 } | 339 } |
341 } | 340 } |
342 | 341 |
343 } // namespace extensions | 342 } // namespace extensions |
OLD | NEW |