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

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

Issue 182903003: Make DOMWrapperWorld::current() callable from workers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 /* 1 /*
2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include "wtf/OwnPtr.h" 58 #include "wtf/OwnPtr.h"
59 #include "wtf/StringExtras.h" 59 #include "wtf/StringExtras.h"
60 #include "wtf/text/CString.h" 60 #include "wtf/text/CString.h"
61 #include <algorithm> 61 #include <algorithm>
62 #include <utility> 62 #include <utility>
63 #include <v8-debug.h> 63 #include <v8-debug.h>
64 #include <v8.h> 64 #include <v8.h>
65 65
66 namespace WebCore { 66 namespace WebCore {
67 67
68 static bool contextBeingInitialized = false;
69
70 static void checkDocumentWrapper(v8::Handle<v8::Object> wrapper, Document* docum ent) 68 static void checkDocumentWrapper(v8::Handle<v8::Object> wrapper, Document* docum ent)
71 { 69 {
72 ASSERT(V8Document::toNative(wrapper) == document); 70 ASSERT(V8Document::toNative(wrapper) == document);
73 ASSERT(!document->isHTMLDocument() || (V8Document::toNative(v8::Handle<v8::O bject>::Cast(wrapper->GetPrototype())) == document)); 71 ASSERT(!document->isHTMLDocument() || (V8Document::toNative(v8::Handle<v8::O bject>::Cast(wrapper->GetPrototype())) == document));
74 } 72 }
75 73
76 static void setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContex t, int debugId) 74 static void setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContex t, int debugId)
77 { 75 {
78 V8PerContextDebugData::setContextDebugData(targetContext, "injected", debugI d); 76 V8PerContextDebugData::setContextDebugData(targetContext, "injected", debugI d);
79 } 77 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // When a frame navigates to a new page, the inner window is cut off 175 // When a frame navigates to a new page, the inner window is cut off
178 // the outer window, and the outer window identify is preserved for 176 // the outer window, and the outer window identify is preserved for
179 // the frame. However, a new inner window is created for the new page. 177 // the frame. However, a new inner window is created for the new page.
180 // If there are JS code holds a closure to the old inner window, 178 // If there are JS code holds a closure to the old inner window,
181 // it won't be able to reach the outer window via its global object. 179 // it won't be able to reach the outer window via its global object.
182 bool V8WindowShell::initializeIfNeeded() 180 bool V8WindowShell::initializeIfNeeded()
183 { 181 {
184 if (m_perContextData) 182 if (m_perContextData)
185 return true; 183 return true;
186 184
187 ASSERT(!contextBeingInitialized); 185 DOMWrapperWorld::setWorldOfInitializingWindow(m_world.get());
188 contextBeingInitialized = true;
189 bool result = initialize(); 186 bool result = initialize();
190 contextBeingInitialized = false; 187 DOMWrapperWorld::setWorldOfInitializingWindow(0);
191 return result; 188 return result;
192 } 189 }
193 190
194 bool V8WindowShell::initialize() 191 bool V8WindowShell::initialize()
195 { 192 {
196 TRACE_EVENT0("v8", "V8WindowShell::initialize"); 193 TRACE_EVENT0("v8", "V8WindowShell::initialize");
197 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "InitializeWindow"); 194 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "InitializeWindow");
198 195
199 v8::HandleScope handleScope(m_isolate); 196 v8::HandleScope handleScope(m_isolate);
200 197
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 490
494 void V8WindowShell::updateSecurityOrigin(SecurityOrigin* origin) 491 void V8WindowShell::updateSecurityOrigin(SecurityOrigin* origin)
495 { 492 {
496 ASSERT(m_world->isMainWorld()); 493 ASSERT(m_world->isMainWorld());
497 if (!m_perContextData) 494 if (!m_perContextData)
498 return; 495 return;
499 v8::HandleScope handleScope(m_isolate); 496 v8::HandleScope handleScope(m_isolate);
500 setSecurityToken(origin); 497 setSecurityToken(origin);
501 } 498 }
502 499
503 bool V8WindowShell::contextHasCorrectPrototype(v8::Handle<v8::Context> context)
504 {
505 if (!isMainThread())
506 return true;
507 // We're initializing the context, so it is not yet in a status where we can
508 // validate the context.
509 if (contextBeingInitialized)
510 return true;
511 return !!toDOMWindow(context);
512 }
513
514 } // WebCore 500 } // WebCore
OLDNEW
« Source/bindings/v8/DOMWrapperWorld.h ('K') | « Source/bindings/v8/V8WindowShell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698