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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp

Issue 2131273002: Additional context creation tracing Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more tracing Created 4 years, 5 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
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 ScriptState::Scope scope(m_scriptState.get()); 239 ScriptState::Scope scope(m_scriptState.get());
240 v8::Local<v8::Context> context = m_scriptState->context(); 240 v8::Local<v8::Context> context = m_scriptState->context();
241 if (m_global.isEmpty()) { 241 if (m_global.isEmpty()) {
242 m_global.set(m_isolate, context->Global()); 242 m_global.set(m_isolate, context->Global());
243 if (m_global.isEmpty()) { 243 if (m_global.isEmpty()) {
244 disposeContext(DoNotDetachGlobal); 244 disposeContext(DoNotDetachGlobal);
245 return false; 245 return false;
246 } 246 }
247 } 247 }
248 248
249 if (!setupWindowPrototypeChain()) { 249 {
250 disposeContext(DoNotDetachGlobal); 250 TRACE_EVENT0("v8", "WindowProxy::initialize (prototype chain)");
251 return false; 251 if (!setupWindowPrototypeChain()) {
252 disposeContext(DoNotDetachGlobal);
253 return false;
254 }
252 } 255 }
253 256
254 SecurityOrigin* origin = 0; 257 {
255 if (m_world->isMainWorld()) { 258 TRACE_EVENT0("v8", "WindowProxy::initialize (misc init)");
256 // ActivityLogger for main world is updated within updateDocument(). 259 SecurityOrigin* origin = 0;
257 updateDocument(); 260 if (m_world->isMainWorld()) {
258 origin = m_frame->securityContext()->getSecurityOrigin(); 261 // ActivityLogger for main world is updated within updateDocument().
259 // FIXME: Can this be removed when CSP moves to browser? 262 updateDocument();
260 ContentSecurityPolicy* csp = m_frame->securityContext()->contentSecurity Policy(); 263 origin = m_frame->securityContext()->getSecurityOrigin();
261 context->AllowCodeGenerationFromStrings(csp->allowEval(0, ContentSecurit yPolicy::SuppressReport)); 264 // FIXME: Can this be removed when CSP moves to browser?
262 context->SetErrorMessageForCodeGenerationFromStrings(v8String(m_isolate, csp->evalDisabledErrorMessage())); 265 ContentSecurityPolicy* csp = m_frame->securityContext()->contentSecu rityPolicy();
263 } else { 266 context->AllowCodeGenerationFromStrings(csp->allowEval(0, ContentSec urityPolicy::SuppressReport));
264 updateActivityLogger(); 267 context->SetErrorMessageForCodeGenerationFromStrings(v8String(m_isol ate, csp->evalDisabledErrorMessage()));
265 origin = m_world->isolatedWorldSecurityOrigin(); 268 } else {
266 setSecurityToken(origin); 269 updateActivityLogger();
267 } 270 origin = m_world->isolatedWorldSecurityOrigin();
268 if (m_frame->isLocalFrame()) { 271 setSecurityToken(origin);
269 LocalFrame* frame = toLocalFrame(m_frame); 272 }
270 MainThreadDebugger::instance()->contextCreated(m_scriptState.get(), fram e, origin); 273 if (m_frame->isLocalFrame()) {
271 frame->loader().client()->didCreateScriptContext(context, m_world->exten sionGroup(), m_world->worldId()); 274 LocalFrame* frame = toLocalFrame(m_frame);
275 MainThreadDebugger::instance()->contextCreated(m_scriptState.get(), frame, origin);
276 TRACE_EVENT0("v8", "WindowProxy::initialize (did create script conte xt)");
277 frame->loader().client()->didCreateScriptContext(context, m_world->e xtensionGroup(), m_world->worldId());
278 }
272 } 279 }
273 // If Origin Trials have been registered before the V8 context was ready, 280 // If Origin Trials have been registered before the V8 context was ready,
274 // then inject them into the context now 281 // then inject them into the context now
275 if (m_world->isMainWorld()) { 282 if (m_world->isMainWorld()) {
276 ExecutionContext* executionContext = m_scriptState->getExecutionContext( ); 283 ExecutionContext* executionContext = m_scriptState->getExecutionContext( );
277 if (executionContext) { 284 if (executionContext) {
285 TRACE_EVENT0("v8", "WindowProxy::initialize (origin trial init)");
278 OriginTrialContext* originTrialContext = OriginTrialContext::from(ex ecutionContext); 286 OriginTrialContext* originTrialContext = OriginTrialContext::from(ex ecutionContext);
279 if (originTrialContext) 287 if (originTrialContext)
280 originTrialContext->initializePendingFeatures(); 288 originTrialContext->initializePendingFeatures();
281 } 289 }
282 } 290 }
283 return true; 291 return true;
284 } 292 }
285 293
286 void WindowProxy::createContext() 294 void WindowProxy::createContext()
287 { 295 {
(...skipping 26 matching lines...) Expand all
314 if (!frame->loader().client()->allowScriptExtension(extension->name( ), extensionGroup, worldId)) 322 if (!frame->loader().client()->allowScriptExtension(extension->name( ), extensionGroup, worldId))
315 continue; 323 continue;
316 324
317 extensionNames.append(extension->name()); 325 extensionNames.append(extension->name());
318 } 326 }
319 } 327 }
320 v8::ExtensionConfiguration extensionConfiguration(extensionNames.size(), ext ensionNames.data()); 328 v8::ExtensionConfiguration extensionConfiguration(extensionNames.size(), ext ensionNames.data());
321 329
322 v8::Local<v8::Context> context; 330 v8::Local<v8::Context> context;
323 { 331 {
332 TRACE_EVENT0("v8", "WindowProxy::createContext");
324 V8PerIsolateData::UseCounterDisabledScope useCounterDisabled(V8PerIsolat eData::from(m_isolate)); 333 V8PerIsolateData::UseCounterDisabledScope useCounterDisabled(V8PerIsolat eData::from(m_isolate));
325 context = v8::Context::New(m_isolate, &extensionConfiguration, globalTem plate, m_global.newLocal(m_isolate)); 334 context = v8::Context::New(m_isolate, &extensionConfiguration, globalTem plate, m_global.newLocal(m_isolate));
326 } 335 }
327 if (context.IsEmpty()) 336 if (context.IsEmpty())
328 return; 337 return;
329 m_scriptState = ScriptState::create(context, m_world); 338 m_scriptState = ScriptState::create(context, m_world);
330 } 339 }
331 340
332 bool WindowProxy::setupWindowPrototypeChain() 341 bool WindowProxy::setupWindowPrototypeChain()
333 { 342 {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 393 }
385 394
386 void WindowProxy::updateDocumentWrapper(v8::Local<v8::Object> wrapper) 395 void WindowProxy::updateDocumentWrapper(v8::Local<v8::Object> wrapper)
387 { 396 {
388 ASSERT(m_world->isMainWorld()); 397 ASSERT(m_world->isMainWorld());
389 m_document.set(m_isolate, wrapper); 398 m_document.set(m_isolate, wrapper);
390 } 399 }
391 400
392 void WindowProxy::updateDocumentProperty() 401 void WindowProxy::updateDocumentProperty()
393 { 402 {
403 TRACE_EVENT0("v8", "WindowProxy::updateDocumentProperty");
394 if (!m_world->isMainWorld()) 404 if (!m_world->isMainWorld())
395 return; 405 return;
396 406
397 if (m_frame->isRemoteFrame()) { 407 if (m_frame->isRemoteFrame()) {
398 return; 408 return;
399 } 409 }
400 410
401 ScriptState::Scope scope(m_scriptState.get()); 411 ScriptState::Scope scope(m_scriptState.get());
402 v8::Local<v8::Context> context = m_scriptState->context(); 412 v8::Local<v8::Context> context = m_scriptState->context();
403 LocalFrame* frame = toLocalFrame(m_frame); 413 LocalFrame* frame = toLocalFrame(m_frame);
404 v8::Local<v8::Value> documentWrapper = toV8(frame->document(), context->Glob al(), context->GetIsolate()); 414 v8::Local<v8::Value> documentWrapper = toV8(frame->document(), context->Glob al(), context->GetIsolate());
405 if (documentWrapper.IsEmpty()) 415 if (documentWrapper.IsEmpty())
406 return; 416 return;
407 ASSERT(documentWrapper == m_document.newLocal(m_isolate) || m_document.isEmp ty()); 417 ASSERT(documentWrapper == m_document.newLocal(m_isolate) || m_document.isEmp ty());
408 if (m_document.isEmpty()) 418 if (m_document.isEmpty())
409 updateDocumentWrapper(v8::Local<v8::Object>::Cast(documentWrapper)); 419 updateDocumentWrapper(v8::Local<v8::Object>::Cast(documentWrapper));
410 checkDocumentWrapper(m_document.newLocal(m_isolate), frame->document()); 420 checkDocumentWrapper(m_document.newLocal(m_isolate), frame->document());
411 421
412 ASSERT(documentWrapper->IsObject()); 422 ASSERT(documentWrapper->IsObject());
413 // TODO(jochen): Don't replace the accessor with a data value. We need a way to tell v8 that the accessor's return value won't change after this point. 423 // TODO(jochen): Don't replace the accessor with a data value. We need a way to tell v8 that the accessor's return value won't change after this point.
414 if (!v8CallBoolean(context->Global()->ForceSet(context, v8AtomicString(m_iso late, "document"), documentWrapper, static_cast<v8::PropertyAttribute>(v8::ReadO nly | v8::DontDelete)))) 424 if (!v8CallBoolean(context->Global()->ForceSet(context, v8AtomicString(m_iso late, "document"), documentWrapper, static_cast<v8::PropertyAttribute>(v8::ReadO nly | v8::DontDelete))))
415 return; 425 return;
416 } 426 }
417 427
418 void WindowProxy::updateActivityLogger() 428 void WindowProxy::updateActivityLogger()
419 { 429 {
430 TRACE_EVENT0("v8", "WindowProxy::updateActivityLogger");
420 m_scriptState->perContextData()->setActivityLogger(V8DOMActivityLogger::acti vityLogger( 431 m_scriptState->perContextData()->setActivityLogger(V8DOMActivityLogger::acti vityLogger(
421 m_world->worldId(), m_frame->isLocalFrame() && toLocalFrame(m_frame)->do cument() ? toLocalFrame(m_frame)->document()->baseURI() : KURL())); 432 m_world->worldId(), m_frame->isLocalFrame() && toLocalFrame(m_frame)->do cument() ? toLocalFrame(m_frame)->document()->baseURI() : KURL()));
422 } 433 }
423 434
424 void WindowProxy::setSecurityToken(SecurityOrigin* origin) 435 void WindowProxy::setSecurityToken(SecurityOrigin* origin)
425 { 436 {
426 // If two tokens are equal, then the SecurityOrigins canAccess each other. 437 // If two tokens are equal, then the SecurityOrigins canAccess each other.
427 // If two tokens are not equal, then we have to call canAccess. 438 // If two tokens are not equal, then we have to call canAccess.
428 // Note: we can't use the HTTPOrigin if it was set from the DOM. 439 // Note: we can't use the HTTPOrigin if it was set from the DOM.
429 String token; 440 String token;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 } 478 }
468 479
469 CString utf8Token = token.utf8(); 480 CString utf8Token = token.utf8();
470 // NOTE: V8 does identity comparison in fast path, must use a symbol 481 // NOTE: V8 does identity comparison in fast path, must use a symbol
471 // as the security token. 482 // as the security token.
472 context->SetSecurityToken(v8AtomicString(m_isolate, utf8Token.data(), utf8To ken.length())); 483 context->SetSecurityToken(v8AtomicString(m_isolate, utf8Token.data(), utf8To ken.length()));
473 } 484 }
474 485
475 void WindowProxy::updateDocument() 486 void WindowProxy::updateDocument()
476 { 487 {
488 TRACE_EVENT0("v8", "WindowProxy::updateDocument");
477 ASSERT(m_world->isMainWorld()); 489 ASSERT(m_world->isMainWorld());
478 if (!isGlobalInitialized()) 490 if (!isGlobalInitialized())
479 return; 491 return;
480 if (!isContextInitialized()) 492 if (!isContextInitialized())
481 return; 493 return;
482 updateActivityLogger(); 494 updateActivityLogger();
483 updateDocumentProperty(); 495 updateDocumentProperty();
484 updateSecurityOrigin(m_frame->securityContext()->getSecurityOrigin()); 496 updateSecurityOrigin(m_frame->securityContext()->getSecurityOrigin());
485 } 497 }
486 498
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 561
550 ScriptState::Scope scope(m_scriptState.get()); 562 ScriptState::Scope scope(m_scriptState.get());
551 ASSERT(!m_document.isEmpty()); 563 ASSERT(!m_document.isEmpty());
552 v8::Local<v8::Object> documentHandle = m_document.newLocal(m_isolate); 564 v8::Local<v8::Object> documentHandle = m_document.newLocal(m_isolate);
553 checkDocumentWrapper(documentHandle, document); 565 checkDocumentWrapper(documentHandle, document);
554 documentHandle->Delete(m_isolate->GetCurrentContext(), v8String(m_isolate, n ame)); 566 documentHandle->Delete(m_isolate->GetCurrentContext(), v8String(m_isolate, n ame));
555 } 567 }
556 568
557 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) 569 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin)
558 { 570 {
571 TRACE_EVENT0("v8", "WindowProxy::updateSecurityOrigin");
559 if (!isContextInitialized()) 572 if (!isContextInitialized())
560 return; 573 return;
561 setSecurityToken(origin); 574 setSecurityToken(origin);
562 } 575 }
563 576
564 } // namespace blink 577 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScriptState.cpp ('k') | third_party/WebKit/Source/web/WebLocalFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698