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

Side by Side Diff: Source/bindings/v8/ScriptController.cpp

Issue 23537048: Reduce usage of v8::Isolate::GetCurrent() in NPV8Object (Closed) Base URL: svn://svn.chromium.org/blink/trunk
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
« no previous file with comments | « Source/bindings/v8/NPV8Object.cpp ('k') | Source/bindings/v8/V8NPObject.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2009 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 _NPN_UnregisterObject(it->value); 109 _NPN_UnregisterObject(it->value);
110 _NPN_ReleaseObject(it->value); 110 _NPN_ReleaseObject(it->value);
111 } 111 }
112 m_pluginObjects.clear(); 112 m_pluginObjects.clear();
113 113
114 if (m_windowScriptNPObject) { 114 if (m_windowScriptNPObject) {
115 // Dispose of the underlying V8 object before releasing our reference 115 // Dispose of the underlying V8 object before releasing our reference
116 // to it, so that if a plugin fails to release it properly we will 116 // to it, so that if a plugin fails to release it properly we will
117 // only leak the NPObject wrapper, not the object, its document, or 117 // only leak the NPObject wrapper, not the object, its document, or
118 // anything else they reference. 118 // anything else they reference.
119 disposeUnderlyingV8Object(m_windowScriptNPObject); 119 disposeUnderlyingV8Object(m_windowScriptNPObject, m_isolate);
120 _NPN_ReleaseObject(m_windowScriptNPObject); 120 _NPN_ReleaseObject(m_windowScriptNPObject);
121 m_windowScriptNPObject = 0; 121 m_windowScriptNPObject = 0;
122 } 122 }
123 } 123 }
124 124
125 void ScriptController::clearForOutOfMemory() 125 void ScriptController::clearForOutOfMemory()
126 { 126 {
127 clearForClose(true); 127 clearForClose(true);
128 } 128 }
129 129
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 v8::HandleScope handleScope(isolate); 460 v8::HandleScope handleScope(isolate);
461 v8::Handle<v8::Context> v8Context = ScriptController::mainWorldContext(frame ); 461 v8::Handle<v8::Context> v8Context = ScriptController::mainWorldContext(frame );
462 if (v8Context.IsEmpty()) 462 if (v8Context.IsEmpty())
463 return createNoScriptObject(); 463 return createNoScriptObject();
464 464
465 v8::Context::Scope scope(v8Context); 465 v8::Context::Scope scope(v8Context);
466 DOMWindow* window = frame->domWindow(); 466 DOMWindow* window = frame->domWindow();
467 v8::Handle<v8::Value> global = toV8(window, v8::Handle<v8::Object>(), v8Cont ext->GetIsolate()); 467 v8::Handle<v8::Value> global = toV8(window, v8::Handle<v8::Object>(), v8Cont ext->GetIsolate());
468 ASSERT(global->IsObject()); 468 ASSERT(global->IsObject());
469 469
470 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(global), windo w); 470 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(global), windo w, isolate);
471 } 471 }
472 472
473 NPObject* ScriptController::windowScriptNPObject() 473 NPObject* ScriptController::windowScriptNPObject()
474 { 474 {
475 if (m_windowScriptNPObject) 475 if (m_windowScriptNPObject)
476 return m_windowScriptNPObject; 476 return m_windowScriptNPObject;
477 477
478 if (canExecuteScripts(NotAboutToExecuteScript)) { 478 if (canExecuteScripts(NotAboutToExecuteScript)) {
479 // JavaScript is enabled, so there is a JavaScript window object. 479 // JavaScript is enabled, so there is a JavaScript window object.
480 // Return an NPObject bound to the window object. 480 // Return an NPObject bound to the window object.
(...skipping 18 matching lines...) Expand all
499 v8::Handle<v8::Context> v8Context = ScriptController::mainWorldContext(m_fra me); 499 v8::Handle<v8::Context> v8Context = ScriptController::mainWorldContext(m_fra me);
500 if (v8Context.IsEmpty()) 500 if (v8Context.IsEmpty())
501 return createNoScriptObject(); 501 return createNoScriptObject();
502 v8::Context::Scope scope(v8Context); 502 v8::Context::Scope scope(v8Context);
503 503
504 DOMWindow* window = m_frame->domWindow(); 504 DOMWindow* window = m_frame->domWindow();
505 v8::Handle<v8::Value> v8plugin = toV8(plugin, v8::Handle<v8::Object>(), v8Co ntext->GetIsolate()); 505 v8::Handle<v8::Value> v8plugin = toV8(plugin, v8::Handle<v8::Object>(), v8Co ntext->GetIsolate());
506 if (!v8plugin->IsObject()) 506 if (!v8plugin->IsObject())
507 return createNoScriptObject(); 507 return createNoScriptObject();
508 508
509 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(v8plugin), win dow); 509 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(v8plugin), win dow, v8Context->GetIsolate());
510 } 510 }
511 511
512 void ScriptController::clearWindowShell() 512 void ScriptController::clearWindowShell()
513 { 513 {
514 double start = currentTime(); 514 double start = currentTime();
515 // V8 binding expects ScriptController::clearWindowShell only be called 515 // V8 binding expects ScriptController::clearWindowShell only be called
516 // when a frame is loading a new page. This creates a new context for the ne w page. 516 // when a frame is loading a new page. This creates a new context for the ne w page.
517 m_windowShell->clearForNavigation(); 517 m_windowShell->clearForNavigation();
518 for (IsolatedWorldMap::iterator iter = m_isolatedWorlds.begin(); iter != m_i solatedWorlds.end(); ++iter) 518 for (IsolatedWorldMap::iterator iter = m_isolatedWorlds.begin(); iter != m_i solatedWorlds.end(); ++iter)
519 iter->value->clearForNavigation(); 519 iter->value->clearForNavigation();
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 v8Results = evaluateHandleScope.Close(resultArray); 714 v8Results = evaluateHandleScope.Close(resultArray);
715 } 715 }
716 716
717 if (results && !v8Results.IsEmpty()) { 717 if (results && !v8Results.IsEmpty()) {
718 for (size_t i = 0; i < v8Results->Length(); ++i) 718 for (size_t i = 0; i < v8Results->Length(); ++i)
719 results->append(ScriptValue(v8Results->Get(i))); 719 results->append(ScriptValue(v8Results->Get(i)));
720 } 720 }
721 } 721 }
722 722
723 } // namespace WebCore 723 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/NPV8Object.cpp ('k') | Source/bindings/v8/V8NPObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698