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

Side by Side Diff: third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp

Issue 1601283003: DevTools: deoilpanize inspector/v8 and related classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed. Created 4 years, 11 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) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
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 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 void LocalDOMWindow::WindowFrameObserver::contextDestroyed() 105 void LocalDOMWindow::WindowFrameObserver::contextDestroyed()
106 { 106 {
107 m_window->frameDestroyed(); 107 m_window->frameDestroyed();
108 LocalFrameLifecycleObserver::contextDestroyed(); 108 LocalFrameLifecycleObserver::contextDestroyed();
109 } 109 }
110 110
111 class PostMessageTimer final : public NoBaseWillBeGarbageCollectedFinalized<Post MessageTimer>, public SuspendableTimer { 111 class PostMessageTimer final : public NoBaseWillBeGarbageCollectedFinalized<Post MessageTimer>, public SuspendableTimer {
112 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PostMessageTimer); 112 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PostMessageTimer);
113 public: 113 public:
114 PostMessageTimer(LocalDOMWindow& window, PassRefPtrWillBeRawPtr<MessageEvent > event, PassRefPtrWillBeRawPtr<LocalDOMWindow> source, SecurityOrigin* targetOr igin, PassRefPtrWillBeRawPtr<ScriptCallStack> stackTrace, UserGestureToken* user GestureToken) 114 PostMessageTimer(LocalDOMWindow& window, PassRefPtrWillBeRawPtr<MessageEvent > event, PassRefPtrWillBeRawPtr<LocalDOMWindow> source, SecurityOrigin* targetOr igin, PassRefPtr<ScriptCallStack> stackTrace, UserGestureToken* userGestureToken )
115 : SuspendableTimer(window.document()) 115 : SuspendableTimer(window.document())
116 , m_event(event) 116 , m_event(event)
117 , m_window(&window) 117 , m_window(&window)
118 , m_targetOrigin(targetOrigin) 118 , m_targetOrigin(targetOrigin)
119 , m_stackTrace(stackTrace) 119 , m_stackTrace(stackTrace)
120 , m_userGestureToken(userGestureToken) 120 , m_userGestureToken(userGestureToken)
121 , m_preventDestruction(false) 121 , m_preventDestruction(false)
122 { 122 {
123 m_asyncOperationId = InspectorInstrumentation::traceAsyncOperationStarti ng(executionContext(), "postMessage"); 123 m_asyncOperationId = InspectorInstrumentation::traceAsyncOperationStarti ng(executionContext(), "postMessage");
124 } 124 }
(...skipping 12 matching lines...) Expand all
137 } 137 }
138 } 138 }
139 139
140 // Eager finalization is needed to promptly stop this timer object. 140 // Eager finalization is needed to promptly stop this timer object.
141 // (see DOMTimer comment for more.) 141 // (see DOMTimer comment for more.)
142 EAGERLY_FINALIZE(); 142 EAGERLY_FINALIZE();
143 DEFINE_INLINE_VIRTUAL_TRACE() 143 DEFINE_INLINE_VIRTUAL_TRACE()
144 { 144 {
145 visitor->trace(m_event); 145 visitor->trace(m_event);
146 visitor->trace(m_window); 146 visitor->trace(m_window);
147 visitor->trace(m_stackTrace);
148 SuspendableTimer::trace(visitor); 147 SuspendableTimer::trace(visitor);
149 } 148 }
150 149
151 // TODO(alexclarke): Override timerTaskRunner() to pass in a document specif ic default task runner. 150 // TODO(alexclarke): Override timerTaskRunner() to pass in a document specif ic default task runner.
152 151
153 private: 152 private:
154 void fired() override 153 void fired() override
155 { 154 {
156 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceA syncOperationCompletedCallbackStarting(executionContext(), m_asyncOperationId); 155 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceA syncOperationCompletedCallbackStarting(executionContext(), m_asyncOperationId);
157 // Prevent calls to stop triggered from the event handler to 156 // Prevent calls to stop triggered from the event handler to
158 // kill this object. 157 // kill this object.
159 m_preventDestruction = true; 158 m_preventDestruction = true;
160 m_window->postMessageTimerFired(this); 159 m_window->postMessageTimerFired(this);
161 // Will destroy this object 160 // Will destroy this object
162 m_window->removePostMessageTimer(this); 161 m_window->removePostMessageTimer(this);
163 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); 162 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie);
164 } 163 }
165 164
166 RefPtrWillBeMember<MessageEvent> m_event; 165 RefPtrWillBeMember<MessageEvent> m_event;
167 RawPtrWillBeMember<LocalDOMWindow> m_window; 166 RawPtrWillBeMember<LocalDOMWindow> m_window;
168 RefPtr<SecurityOrigin> m_targetOrigin; 167 RefPtr<SecurityOrigin> m_targetOrigin;
169 RefPtrWillBeMember<ScriptCallStack> m_stackTrace; 168 RefPtr<ScriptCallStack> m_stackTrace;
170 RefPtr<UserGestureToken> m_userGestureToken; 169 RefPtr<UserGestureToken> m_userGestureToken;
171 int m_asyncOperationId; 170 int m_asyncOperationId;
172 bool m_preventDestruction; 171 bool m_preventDestruction;
173 }; 172 };
174 173
175 static void updateSuddenTerminationStatus(LocalDOMWindow* domWindow, bool addedL istener, FrameLoaderClient::SuddenTerminationDisablerType disablerType) 174 static void updateSuddenTerminationStatus(LocalDOMWindow* domWindow, bool addedL istener, FrameLoaderClient::SuddenTerminationDisablerType disablerType)
176 { 175 {
177 Platform::current()->suddenTerminationChanged(!addedListener); 176 Platform::current()->suddenTerminationChanged(!addedListener);
178 if (domWindow->frame() && domWindow->frame()->loader().client()) 177 if (domWindow->frame() && domWindow->frame()->loader().client())
179 domWindow->frame()->loader().client()->suddenTerminationDisablerChanged( addedListener, disablerType); 178 domWindow->frame()->loader().client()->suddenTerminationDisablerChanged( addedListener, disablerType);
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 return m_applicationCache.get(); 658 return m_applicationCache.get();
660 } 659 }
661 660
662 Navigator* LocalDOMWindow::navigator() const 661 Navigator* LocalDOMWindow::navigator() const
663 { 662 {
664 if (!m_navigator) 663 if (!m_navigator)
665 m_navigator = Navigator::create(frame()); 664 m_navigator = Navigator::create(frame());
666 return m_navigator.get(); 665 return m_navigator.get();
667 } 666 }
668 667
669 void LocalDOMWindow::schedulePostMessage(PassRefPtrWillBeRawPtr<MessageEvent> ev ent, LocalDOMWindow* source, SecurityOrigin* target, PassRefPtrWillBeRawPtr<Scri ptCallStack> stackTrace) 668 void LocalDOMWindow::schedulePostMessage(PassRefPtrWillBeRawPtr<MessageEvent> ev ent, LocalDOMWindow* source, SecurityOrigin* target, PassRefPtr<ScriptCallStack> stackTrace)
670 { 669 {
671 // Schedule the message. 670 // Schedule the message.
672 OwnPtrWillBeRawPtr<PostMessageTimer> timer = adoptPtrWillBeNoop(new PostMess ageTimer(*this, event, source, target, stackTrace, UserGestureIndicator::current Token())); 671 OwnPtrWillBeRawPtr<PostMessageTimer> timer = adoptPtrWillBeNoop(new PostMess ageTimer(*this, event, source, target, stackTrace, UserGestureIndicator::current Token()));
673 timer->startOneShot(0, BLINK_FROM_HERE); 672 timer->startOneShot(0, BLINK_FROM_HERE);
674 timer->suspendIfNeeded(); 673 timer->suspendIfNeeded();
675 m_postMessageTimers.add(timer.release()); 674 m_postMessageTimers.add(timer.release());
676 } 675 }
677 676
678 void LocalDOMWindow::postMessageTimerFired(PostMessageTimer* timer) 677 void LocalDOMWindow::postMessageTimerFired(PostMessageTimer* timer)
679 { 678 {
680 if (!isCurrentlyDisplayedInFrame()) { 679 if (!isCurrentlyDisplayedInFrame()) {
681 return; 680 return;
682 } 681 }
683 682
684 RefPtrWillBeRawPtr<MessageEvent> event = timer->event(); 683 RefPtrWillBeRawPtr<MessageEvent> event = timer->event();
685 684
686 UserGestureIndicator gestureIndicator(timer->userGestureToken()); 685 UserGestureIndicator gestureIndicator(timer->userGestureToken());
687 686
688 event->entangleMessagePorts(document()); 687 event->entangleMessagePorts(document());
689 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta ckTrace()); 688 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta ckTrace());
690 } 689 }
691 690
692 void LocalDOMWindow::removePostMessageTimer(PostMessageTimer* timer) 691 void LocalDOMWindow::removePostMessageTimer(PostMessageTimer* timer)
693 { 692 {
694 m_postMessageTimers.remove(timer); 693 m_postMessageTimers.remove(timer);
695 } 694 }
696 695
697 void LocalDOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intende dTargetOrigin, PassRefPtrWillBeRawPtr<Event> event, PassRefPtrWillBeRawPtr<Scrip tCallStack> stackTrace) 696 void LocalDOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intende dTargetOrigin, PassRefPtrWillBeRawPtr<Event> event, PassRefPtr<ScriptCallStack> stackTrace)
698 { 697 {
699 if (intendedTargetOrigin) { 698 if (intendedTargetOrigin) {
700 // Check target origin now since the target document may have changed si nce the timer was scheduled. 699 // Check target origin now since the target document may have changed si nce the timer was scheduled.
701 if (!intendedTargetOrigin->isSameSchemeHostPortAndSuborigin(document()-> securityOrigin())) { 700 if (!intendedTargetOrigin->isSameSchemeHostPortAndSuborigin(document()-> securityOrigin())) {
702 String message = ExceptionMessages::failedToExecute("postMessage", " DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() + "') does not match the recipient window's origin ('" + document()->securityOrig in()->toString() + "')."); 701 String message = ExceptionMessages::failedToExecute("postMessage", " DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() + "') does not match the recipient window's origin ('" + document()->securityOrig in()->toString() + "').");
703 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage:: create(SecurityMessageSource, ErrorMessageLevel, message); 702 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage:: create(SecurityMessageSource, ErrorMessageLevel, message);
704 consoleMessage->setCallStack(stackTrace); 703 consoleMessage->setCallStack(stackTrace);
705 frameConsole()->addMessage(consoleMessage.release()); 704 frameConsole()->addMessage(consoleMessage.release());
706 return; 705 return;
707 } 706 }
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 { 1500 {
1502 // If the LocalDOMWindow still has a frame reference, that frame must point 1501 // If the LocalDOMWindow still has a frame reference, that frame must point
1503 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation 1502 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation
1504 // where script execution leaks between different LocalDOMWindows. 1503 // where script execution leaks between different LocalDOMWindows.
1505 if (m_frameObserver->frame()) 1504 if (m_frameObserver->frame())
1506 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() = = this); 1505 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() = = this);
1507 return m_frameObserver->frame(); 1506 return m_frameObserver->frame();
1508 } 1507 }
1509 1508
1510 } // namespace blink 1509 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698