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

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

Issue 23636015: Remove unsafe access hacks from ScopedPersistent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: code review (jyasskin)' 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::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
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
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/chrome_v8_context.cc ('k') | chrome/renderer/extensions/object_backed_native_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698