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

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
« no previous file with comments | « Source/bindings/v8/V8WindowShell.h ('k') | no next file » | 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, 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "wtf/OwnPtr.h" 59 #include "wtf/OwnPtr.h"
60 #include "wtf/StringExtras.h" 60 #include "wtf/StringExtras.h"
61 #include "wtf/text/CString.h" 61 #include "wtf/text/CString.h"
62 #include <algorithm> 62 #include <algorithm>
63 #include <utility> 63 #include <utility>
64 #include <v8-debug.h> 64 #include <v8-debug.h>
65 #include <v8.h> 65 #include <v8.h>
66 66
67 namespace WebCore { 67 namespace WebCore {
68 68
69 static bool contextBeingInitialized = false;
70
71 static void checkDocumentWrapper(v8::Handle<v8::Object> wrapper, Document* docum ent) 69 static void checkDocumentWrapper(v8::Handle<v8::Object> wrapper, Document* docum ent)
72 { 70 {
73 ASSERT(V8Document::toNative(wrapper) == document); 71 ASSERT(V8Document::toNative(wrapper) == document);
74 ASSERT(!document->isHTMLDocument() || (V8Document::toNative(v8::Handle<v8::O bject>::Cast(wrapper->GetPrototype())) == document)); 72 ASSERT(!document->isHTMLDocument() || (V8Document::toNative(v8::Handle<v8::O bject>::Cast(wrapper->GetPrototype())) == document));
75 } 73 }
76 74
77 static void setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContex t, int debugId) 75 static void setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContex t, int debugId)
78 { 76 {
79 V8PerContextDebugData::setContextDebugData(targetContext, "injected", debugI d); 77 V8PerContextDebugData::setContextDebugData(targetContext, "injected", debugI d);
80 } 78 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // When a frame navigates to a new page, the inner window is cut off 176 // When a frame navigates to a new page, the inner window is cut off
179 // the outer window, and the outer window identify is preserved for 177 // the outer window, and the outer window identify is preserved for
180 // the frame. However, a new inner window is created for the new page. 178 // the frame. However, a new inner window is created for the new page.
181 // If there are JS code holds a closure to the old inner window, 179 // If there are JS code holds a closure to the old inner window,
182 // it won't be able to reach the outer window via its global object. 180 // it won't be able to reach the outer window via its global object.
183 bool V8WindowShell::initializeIfNeeded() 181 bool V8WindowShell::initializeIfNeeded()
184 { 182 {
185 if (m_perContextData) 183 if (m_perContextData)
186 return true; 184 return true;
187 185
188 ASSERT(!contextBeingInitialized); 186 DOMWrapperWorld::setWorldOfInitializingWindow(m_world.get());
189 contextBeingInitialized = true;
190 bool result = initialize(); 187 bool result = initialize();
191 contextBeingInitialized = false; 188 DOMWrapperWorld::setWorldOfInitializingWindow(0);
192 return result; 189 return result;
193 } 190 }
194 191
195 bool V8WindowShell::initialize() 192 bool V8WindowShell::initialize()
196 { 193 {
197 TRACE_EVENT0("v8", "V8WindowShell::initialize"); 194 TRACE_EVENT0("v8", "V8WindowShell::initialize");
198 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "InitializeWindow"); 195 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "InitializeWindow");
199 196
200 v8::HandleScope handleScope(m_isolate); 197 v8::HandleScope handleScope(m_isolate);
201 198
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 491
495 void V8WindowShell::updateSecurityOrigin(SecurityOrigin* origin) 492 void V8WindowShell::updateSecurityOrigin(SecurityOrigin* origin)
496 { 493 {
497 ASSERT(m_world->isMainWorld()); 494 ASSERT(m_world->isMainWorld());
498 if (!m_perContextData) 495 if (!m_perContextData)
499 return; 496 return;
500 v8::HandleScope handleScope(m_isolate); 497 v8::HandleScope handleScope(m_isolate);
501 setSecurityToken(origin); 498 setSecurityToken(origin);
502 } 499 }
503 500
504 bool V8WindowShell::contextHasCorrectPrototype(v8::Handle<v8::Context> context)
505 {
506 if (!isMainThread())
507 return true;
508 // We're initializing the context, so it is not yet in a status where we can
509 // validate the context.
510 if (contextBeingInitialized)
511 return true;
512 return !!toDOMWindow(context);
513 }
514
515 } // WebCore 501 } // WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8WindowShell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698