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

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

Issue 2386173002: reflow comments in Source/bindings/core/v8 (Closed)
Patch Set: Created 4 years, 2 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 DOMWrapperWorld& world) { 81 DOMWrapperWorld& world) {
82 return new WindowProxy(frame, &world, isolate); 82 return new WindowProxy(frame, &world, isolate);
83 } 83 }
84 84
85 WindowProxy::WindowProxy(Frame* frame, 85 WindowProxy::WindowProxy(Frame* frame,
86 PassRefPtr<DOMWrapperWorld> world, 86 PassRefPtr<DOMWrapperWorld> world,
87 v8::Isolate* isolate) 87 v8::Isolate* isolate)
88 : m_frame(frame), m_isolate(isolate), m_world(world) {} 88 : m_frame(frame), m_isolate(isolate), m_world(world) {}
89 89
90 WindowProxy::~WindowProxy() { 90 WindowProxy::~WindowProxy() {
91 // clearForClose() or clearForNavigation() must be invoked before destruction starts. 91 // clearForClose() or clearForNavigation() must be invoked before destruction
92 // starts.
92 ASSERT(!isContextInitialized()); 93 ASSERT(!isContextInitialized());
93 } 94 }
94 95
95 DEFINE_TRACE(WindowProxy) { 96 DEFINE_TRACE(WindowProxy) {
96 visitor->trace(m_frame); 97 visitor->trace(m_frame);
97 } 98 }
98 99
99 void WindowProxy::disposeContext(GlobalDetachmentBehavior behavior) { 100 void WindowProxy::disposeContext(GlobalDetachmentBehavior behavior) {
100 if (!isContextInitialized()) 101 if (!isContextInitialized())
101 return; 102 return;
102 103
103 v8::HandleScope handleScope(m_isolate); 104 v8::HandleScope handleScope(m_isolate);
104 v8::Local<v8::Context> context = m_scriptState->context(); 105 v8::Local<v8::Context> context = m_scriptState->context();
105 if (m_frame->isLocalFrame()) { 106 if (m_frame->isLocalFrame()) {
106 LocalFrame* frame = toLocalFrame(m_frame); 107 LocalFrame* frame = toLocalFrame(m_frame);
107 // The embedder could run arbitrary code in response to the willReleaseScrip tContext callback, so all disposing should happen after it returns. 108 // The embedder could run arbitrary code in response to the
109 // willReleaseScriptContext callback, so all disposing should happen after
110 // it returns.
108 frame->loader().client()->willReleaseScriptContext(context, 111 frame->loader().client()->willReleaseScriptContext(context,
109 m_world->worldId()); 112 m_world->worldId());
110 MainThreadDebugger::instance()->contextWillBeDestroyed(m_scriptState.get()); 113 MainThreadDebugger::instance()->contextWillBeDestroyed(m_scriptState.get());
111 } 114 }
112 115
113 m_document.clear(); 116 m_document.clear();
114 117
115 if (behavior == DetachGlobal) 118 if (behavior == DetachGlobal)
116 m_scriptState->detachGlobalObject(); 119 m_scriptState->detachGlobalObject();
117 120
(...skipping 26 matching lines...) Expand all
144 if (!isContextInitialized()) 147 if (!isContextInitialized())
145 return v8::Local<v8::Object>(); 148 return v8::Local<v8::Object>();
146 ASSERT(m_scriptState->contextIsValid()); 149 ASSERT(m_scriptState->contextIsValid());
147 ASSERT(m_global == m_scriptState->context()->Global()); 150 ASSERT(m_global == m_scriptState->context()->Global());
148 return m_global.newLocal(m_isolate); 151 return m_global.newLocal(m_isolate);
149 } 152 }
150 153
151 v8::Local<v8::Object> WindowProxy::releaseGlobal() { 154 v8::Local<v8::Object> WindowProxy::releaseGlobal() {
152 ASSERT(!isContextInitialized()); 155 ASSERT(!isContextInitialized());
153 // If a ScriptState was created, the context was initialized at some point. 156 // If a ScriptState was created, the context was initialized at some point.
154 // Make sure the global object was detached from the proxy by calling clearFor Navigation(). 157 // Make sure the global object was detached from the proxy by calling
158 // clearForNavigation().
155 if (m_scriptState) 159 if (m_scriptState)
156 ASSERT(m_scriptState->isGlobalObjectDetached()); 160 ASSERT(m_scriptState->isGlobalObjectDetached());
157 v8::Local<v8::Object> global = m_global.newLocal(m_isolate); 161 v8::Local<v8::Object> global = m_global.newLocal(m_isolate);
158 m_global.clear(); 162 m_global.clear();
159 return global; 163 return global;
160 } 164 }
161 165
162 void WindowProxy::setGlobal(v8::Local<v8::Object> global) { 166 void WindowProxy::setGlobal(v8::Local<v8::Object> global) {
163 m_global.set(m_isolate, global); 167 m_global.set(m_isolate, global);
164 168
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 LocalFrame* frame = toLocalFrame(m_frame); 273 LocalFrame* frame = toLocalFrame(m_frame);
270 MainThreadDebugger::instance()->contextCreated(m_scriptState.get(), frame, 274 MainThreadDebugger::instance()->contextCreated(m_scriptState.get(), frame,
271 origin); 275 origin);
272 frame->loader().client()->didCreateScriptContext( 276 frame->loader().client()->didCreateScriptContext(
273 context, m_world->extensionGroup(), m_world->worldId()); 277 context, m_world->extensionGroup(), m_world->worldId());
274 } 278 }
275 return true; 279 return true;
276 } 280 }
277 281
278 void WindowProxy::createContext() { 282 void WindowProxy::createContext() {
279 // FIXME: This should be a null check of m_frame->client(), but there are stil l some edge cases 283 // FIXME: This should be a null check of m_frame->client(), but there are
284 // still some edge cases
280 // that this fails to catch during frame detach. 285 // that this fails to catch during frame detach.
281 if (m_frame->isLocalFrame() && 286 if (m_frame->isLocalFrame() &&
282 !toLocalFrame(m_frame)->loader().documentLoader()) 287 !toLocalFrame(m_frame)->loader().documentLoader())
283 return; 288 return;
284 289
285 // Create a new v8::Context with the window object as the global object 290 // Create a new v8::Context with the window object as the global object
286 // (aka the inner global). Reuse the global proxy object (aka the outer 291 // (aka the inner global). Reuse the global proxy object (aka the outer
287 // global) if it already exists. See the comments in 292 // global) if it already exists. See the comments in
288 // setupWindowPrototypeChain for the structure of the prototype chain of 293 // setupWindowPrototypeChain for the structure of the prototype chain of
289 // the global object. 294 // the global object.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 toV8(frame->document(), context->Global(), context->GetIsolate()); 411 toV8(frame->document(), context->Global(), context->GetIsolate());
407 if (documentWrapper.IsEmpty()) 412 if (documentWrapper.IsEmpty())
408 return; 413 return;
409 ASSERT(documentWrapper == m_document.newLocal(m_isolate) || 414 ASSERT(documentWrapper == m_document.newLocal(m_isolate) ||
410 m_document.isEmpty()); 415 m_document.isEmpty());
411 if (m_document.isEmpty()) 416 if (m_document.isEmpty())
412 updateDocumentWrapper(v8::Local<v8::Object>::Cast(documentWrapper)); 417 updateDocumentWrapper(v8::Local<v8::Object>::Cast(documentWrapper));
413 checkDocumentWrapper(m_document.newLocal(m_isolate), frame->document()); 418 checkDocumentWrapper(m_document.newLocal(m_isolate), frame->document());
414 419
415 ASSERT(documentWrapper->IsObject()); 420 ASSERT(documentWrapper->IsObject());
416 // TODO(jochen): Don't replace the accessor with a data value. We need a way t o tell v8 that the accessor's return value won't change after this point. 421 // TODO(jochen): Don't replace the accessor with a data value. We need a way
422 // to tell v8 that the accessor's return value won't change after this point.
417 if (!v8CallBoolean(context->Global()->ForceSet( 423 if (!v8CallBoolean(context->Global()->ForceSet(
418 context, v8AtomicString(m_isolate, "document"), documentWrapper, 424 context, v8AtomicString(m_isolate, "document"), documentWrapper,
419 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)))) 425 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete))))
420 return; 426 return;
421 } 427 }
422 428
423 void WindowProxy::updateActivityLogger() { 429 void WindowProxy::updateActivityLogger() {
424 m_scriptState->perContextData()->setActivityLogger( 430 m_scriptState->perContextData()->setActivityLogger(
425 V8DOMActivityLogger::activityLogger( 431 V8DOMActivityLogger::activityLogger(
426 m_world->worldId(), 432 m_world->worldId(),
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 v8String(m_isolate, name)); 577 v8String(m_isolate, name));
572 } 578 }
573 579
574 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) { 580 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) {
575 if (!isContextInitialized()) 581 if (!isContextInitialized())
576 return; 582 return;
577 setSecurityToken(origin); 583 setSecurityToken(origin);
578 } 584 }
579 585
580 } // namespace blink 586 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698