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

Side by Side Diff: trunk/src/chrome/renderer/extensions/messaging_bindings.cc

Issue 23724028: Revert 222102 "Remove unsafe access hacks from ScopedPersistent." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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) 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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698