| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 5 * (http://www.torchmobile.com/) | 5 * (http://www.torchmobile.com/) |
| 6 * Copyright (C) 2009 Adam Barth. All rights reserved. | 6 * Copyright (C) 2009 Adam Barth. All rights reserved. |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 ScheduledRedirect, | 71 ScheduledRedirect, |
| 72 ScheduledLocationChange, | 72 ScheduledLocationChange, |
| 73 ScheduledPageBlock, | 73 ScheduledPageBlock, |
| 74 | 74 |
| 75 ScheduledLastEntry | 75 ScheduledLastEntry |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 // If the current frame has a provisional document loader, a scheduled | 78 // If the current frame has a provisional document loader, a scheduled |
| 79 // navigation might abort that load. Log those occurrences until | 79 // navigation might abort that load. Log those occurrences until |
| 80 // crbug.com/557430 is resolved. | 80 // crbug.com/557430 is resolved. |
| 81 void maybeLogScheduledNavigationClobber( | 81 void maybeLogScheduledNavigationClobber(ScheduledNavigationType type, |
| 82 ScheduledNavigationType type, | 82 LocalFrame* frame) { |
| 83 LocalFrame* frame, | |
| 84 const FrameLoadRequest& request, | |
| 85 UserGestureIndicator* gestureIndicator) { | |
| 86 if (!frame->loader().provisionalDocumentLoader()) | 83 if (!frame->loader().provisionalDocumentLoader()) |
| 87 return; | 84 return; |
| 88 // Include enumeration values userGesture variants. | 85 // Include enumeration values userGesture variants. |
| 89 DEFINE_STATIC_LOCAL(EnumerationHistogram, scheduledNavigationClobberHistogram, | 86 DEFINE_STATIC_LOCAL(EnumerationHistogram, scheduledNavigationClobberHistogram, |
| 90 ("Navigation.Scheduled.MaybeCausedAbort", | 87 ("Navigation.Scheduled.MaybeCausedAbort", |
| 91 ScheduledNavigationType::ScheduledLastEntry * 2)); | 88 ScheduledNavigationType::ScheduledLastEntry * 2)); |
| 92 | 89 |
| 93 UserGestureToken* gestureToken = gestureIndicator->currentToken(); | 90 UserGestureToken* gestureToken = UserGestureIndicator::currentToken(); |
| 94 int value = gestureToken->hasGestures() ? type + ScheduledLastEntry : type; | 91 int value = gestureToken && gestureToken->hasGestures() |
| 92 ? type + ScheduledLastEntry |
| 93 : type; |
| 95 scheduledNavigationClobberHistogram.count(value); | 94 scheduledNavigationClobberHistogram.count(value); |
| 96 | 95 |
| 97 DEFINE_STATIC_LOCAL( | 96 DEFINE_STATIC_LOCAL( |
| 98 CustomCountHistogram, scheduledClobberAbortTimeHistogram, | 97 CustomCountHistogram, scheduledClobberAbortTimeHistogram, |
| 99 ("Navigation.Scheduled.MaybeCausedAbort.Time", 1, 10000, 50)); | 98 ("Navigation.Scheduled.MaybeCausedAbort.Time", 1, 10000, 50)); |
| 100 double navigationStart = | 99 double navigationStart = |
| 101 frame->loader().provisionalDocumentLoader()->timing().navigationStart(); | 100 frame->loader().provisionalDocumentLoader()->timing().navigationStart(); |
| 102 if (navigationStart) | 101 if (navigationStart) |
| 103 scheduledClobberAbortTimeHistogram.count(monotonicallyIncreasingTime() - | 102 scheduledClobberAbortTimeHistogram.count(monotonicallyIncreasingTime() - |
| 104 navigationStart); | 103 navigationStart); |
| 105 } | 104 } |
| 106 | 105 |
| 107 } // namespace | 106 } // namespace |
| 108 | 107 |
| 109 unsigned NavigationDisablerForUnload::s_navigationDisableCount = 0; | 108 unsigned NavigationDisablerForUnload::s_navigationDisableCount = 0; |
| 110 | 109 |
| 111 class ScheduledNavigation | 110 class ScheduledNavigation |
| 112 : public GarbageCollectedFinalized<ScheduledNavigation> { | 111 : public GarbageCollectedFinalized<ScheduledNavigation> { |
| 113 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); | 112 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); |
| 114 | 113 |
| 115 public: | 114 public: |
| 116 ScheduledNavigation(double delay, | 115 ScheduledNavigation(double delay, |
| 117 Document* originDocument, | 116 Document* originDocument, |
| 118 bool replacesCurrentItem, | 117 bool replacesCurrentItem, |
| 119 bool isLocationChange) | 118 bool isLocationChange) |
| 120 : m_delay(delay), | 119 : m_delay(delay), |
| 121 m_originDocument(originDocument), | 120 m_originDocument(originDocument), |
| 122 m_replacesCurrentItem(replacesCurrentItem), | 121 m_replacesCurrentItem(replacesCurrentItem), |
| 123 m_isLocationChange(isLocationChange), | 122 m_isLocationChange(isLocationChange) { |
| 124 m_wasUserGesture(UserGestureIndicator::processingUserGesture()) { | 123 if (UserGestureIndicator::processingUserGesture()) |
| 125 if (m_wasUserGesture) | |
| 126 m_userGestureToken = UserGestureIndicator::currentToken(); | 124 m_userGestureToken = UserGestureIndicator::currentToken(); |
| 127 } | 125 } |
| 128 virtual ~ScheduledNavigation() {} | 126 virtual ~ScheduledNavigation() {} |
| 129 | 127 |
| 130 virtual void fire(LocalFrame*) = 0; | 128 virtual void fire(LocalFrame*) = 0; |
| 131 | 129 |
| 132 virtual bool shouldStartTimer(LocalFrame*) { return true; } | 130 virtual bool shouldStartTimer(LocalFrame*) { return true; } |
| 133 | 131 |
| 134 double delay() const { return m_delay; } | 132 double delay() const { return m_delay; } |
| 135 Document* originDocument() const { return m_originDocument.get(); } | 133 Document* originDocument() const { return m_originDocument.get(); } |
| 136 bool replacesCurrentItem() const { return m_replacesCurrentItem; } | 134 bool replacesCurrentItem() const { return m_replacesCurrentItem; } |
| 137 bool isLocationChange() const { return m_isLocationChange; } | 135 bool isLocationChange() const { return m_isLocationChange; } |
| 138 std::unique_ptr<UserGestureIndicator> createUserGestureIndicator() { | 136 std::unique_ptr<UserGestureIndicator> createUserGestureIndicator() { |
| 139 if (m_wasUserGesture && m_userGestureToken) | 137 return wrapUnique(new UserGestureIndicator(m_userGestureToken)); |
| 140 return wrapUnique(new UserGestureIndicator(m_userGestureToken)); | |
| 141 return wrapUnique( | |
| 142 new UserGestureIndicator(DefinitelyNotProcessingUserGesture)); | |
| 143 } | 138 } |
| 144 | 139 |
| 145 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_originDocument); } | 140 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_originDocument); } |
| 146 | 141 |
| 147 protected: | 142 protected: |
| 148 void clearUserGesture() { m_wasUserGesture = false; } | 143 void clearUserGesture() { m_userGestureToken.clear(); } |
| 149 | 144 |
| 150 private: | 145 private: |
| 151 double m_delay; | 146 double m_delay; |
| 152 Member<Document> m_originDocument; | 147 Member<Document> m_originDocument; |
| 153 bool m_replacesCurrentItem; | 148 bool m_replacesCurrentItem; |
| 154 bool m_isLocationChange; | 149 bool m_isLocationChange; |
| 155 bool m_wasUserGesture; | |
| 156 RefPtr<UserGestureToken> m_userGestureToken; | 150 RefPtr<UserGestureToken> m_userGestureToken; |
| 157 }; | 151 }; |
| 158 | 152 |
| 159 class ScheduledURLNavigation : public ScheduledNavigation { | 153 class ScheduledURLNavigation : public ScheduledNavigation { |
| 160 protected: | 154 protected: |
| 161 ScheduledURLNavigation(double delay, | 155 ScheduledURLNavigation(double delay, |
| 162 Document* originDocument, | 156 Document* originDocument, |
| 163 const String& url, | 157 const String& url, |
| 164 bool replacesCurrentItem, | 158 bool replacesCurrentItem, |
| 165 bool isLocationChange) | 159 bool isLocationChange) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 179 std::unique_ptr<UserGestureIndicator> gestureIndicator = | 173 std::unique_ptr<UserGestureIndicator> gestureIndicator = |
| 180 createUserGestureIndicator(); | 174 createUserGestureIndicator(); |
| 181 FrameLoadRequest request(originDocument(), m_url, "_self", | 175 FrameLoadRequest request(originDocument(), m_url, "_self", |
| 182 m_shouldCheckMainWorldContentSecurityPolicy); | 176 m_shouldCheckMainWorldContentSecurityPolicy); |
| 183 request.setReplacesCurrentItem(replacesCurrentItem()); | 177 request.setReplacesCurrentItem(replacesCurrentItem()); |
| 184 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); | 178 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); |
| 185 | 179 |
| 186 ScheduledNavigationType type = | 180 ScheduledNavigationType type = |
| 187 isLocationChange() ? ScheduledNavigationType::ScheduledLocationChange | 181 isLocationChange() ? ScheduledNavigationType::ScheduledLocationChange |
| 188 : ScheduledNavigationType::ScheduledURLNavigation; | 182 : ScheduledNavigationType::ScheduledURLNavigation; |
| 189 maybeLogScheduledNavigationClobber(type, frame, request, | 183 maybeLogScheduledNavigationClobber(type, frame); |
| 190 gestureIndicator.get()); | |
| 191 frame->loader().load(request); | 184 frame->loader().load(request); |
| 192 } | 185 } |
| 193 | 186 |
| 194 String url() const { return m_url; } | 187 String url() const { return m_url; } |
| 195 | 188 |
| 196 private: | 189 private: |
| 197 String m_url; | 190 String m_url; |
| 198 ContentSecurityPolicyDisposition m_shouldCheckMainWorldContentSecurityPolicy; | 191 ContentSecurityPolicyDisposition m_shouldCheckMainWorldContentSecurityPolicy; |
| 199 }; | 192 }; |
| 200 | 193 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 216 std::unique_ptr<UserGestureIndicator> gestureIndicator = | 209 std::unique_ptr<UserGestureIndicator> gestureIndicator = |
| 217 createUserGestureIndicator(); | 210 createUserGestureIndicator(); |
| 218 FrameLoadRequest request(originDocument(), url(), "_self"); | 211 FrameLoadRequest request(originDocument(), url(), "_self"); |
| 219 request.setReplacesCurrentItem(replacesCurrentItem()); | 212 request.setReplacesCurrentItem(replacesCurrentItem()); |
| 220 if (equalIgnoringFragmentIdentifier(frame->document()->url(), | 213 if (equalIgnoringFragmentIdentifier(frame->document()->url(), |
| 221 request.resourceRequest().url())) | 214 request.resourceRequest().url())) |
| 222 request.resourceRequest().setCachePolicy( | 215 request.resourceRequest().setCachePolicy( |
| 223 WebCachePolicy::ValidatingCacheData); | 216 WebCachePolicy::ValidatingCacheData); |
| 224 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); | 217 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); |
| 225 maybeLogScheduledNavigationClobber( | 218 maybeLogScheduledNavigationClobber( |
| 226 ScheduledNavigationType::ScheduledRedirect, frame, request, | 219 ScheduledNavigationType::ScheduledRedirect, frame); |
| 227 gestureIndicator.get()); | |
| 228 frame->loader().load(request); | 220 frame->loader().load(request); |
| 229 } | 221 } |
| 230 | 222 |
| 231 private: | 223 private: |
| 232 ScheduledRedirect(double delay, | 224 ScheduledRedirect(double delay, |
| 233 Document* originDocument, | 225 Document* originDocument, |
| 234 const String& url, | 226 const String& url, |
| 235 bool replacesCurrentItem) | 227 bool replacesCurrentItem) |
| 236 : ScheduledURLNavigation(delay, | 228 : ScheduledURLNavigation(delay, |
| 237 originDocument, | 229 originDocument, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 void fire(LocalFrame* frame) override { | 261 void fire(LocalFrame* frame) override { |
| 270 std::unique_ptr<UserGestureIndicator> gestureIndicator = | 262 std::unique_ptr<UserGestureIndicator> gestureIndicator = |
| 271 createUserGestureIndicator(); | 263 createUserGestureIndicator(); |
| 272 ResourceRequest resourceRequest = frame->loader().resourceRequestForReload( | 264 ResourceRequest resourceRequest = frame->loader().resourceRequestForReload( |
| 273 FrameLoadTypeReload, KURL(), ClientRedirectPolicy::ClientRedirect); | 265 FrameLoadTypeReload, KURL(), ClientRedirectPolicy::ClientRedirect); |
| 274 if (resourceRequest.isNull()) | 266 if (resourceRequest.isNull()) |
| 275 return; | 267 return; |
| 276 FrameLoadRequest request = FrameLoadRequest(nullptr, resourceRequest); | 268 FrameLoadRequest request = FrameLoadRequest(nullptr, resourceRequest); |
| 277 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); | 269 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); |
| 278 maybeLogScheduledNavigationClobber(ScheduledNavigationType::ScheduledReload, | 270 maybeLogScheduledNavigationClobber(ScheduledNavigationType::ScheduledReload, |
| 279 frame, request, gestureIndicator.get()); | 271 frame); |
| 280 frame->loader().load(request, FrameLoadTypeReload); | 272 frame->loader().load(request, FrameLoadTypeReload); |
| 281 } | 273 } |
| 282 | 274 |
| 283 private: | 275 private: |
| 284 ScheduledReload() : ScheduledNavigation(0.0, nullptr, true, true) {} | 276 ScheduledReload() : ScheduledNavigation(0.0, nullptr, true, true) {} |
| 285 }; | 277 }; |
| 286 | 278 |
| 287 class ScheduledPageBlock final : public ScheduledURLNavigation { | 279 class ScheduledPageBlock final : public ScheduledURLNavigation { |
| 288 public: | 280 public: |
| 289 static ScheduledPageBlock* create(Document* originDocument, | 281 static ScheduledPageBlock* create(Document* originDocument, |
| 290 const String& url) { | 282 const String& url) { |
| 291 return new ScheduledPageBlock(originDocument, url); | 283 return new ScheduledPageBlock(originDocument, url); |
| 292 } | 284 } |
| 293 | 285 |
| 294 void fire(LocalFrame* frame) override { | 286 void fire(LocalFrame* frame) override { |
| 295 std::unique_ptr<UserGestureIndicator> gestureIndicator = | 287 std::unique_ptr<UserGestureIndicator> gestureIndicator = |
| 296 createUserGestureIndicator(); | 288 createUserGestureIndicator(); |
| 297 SubstituteData substituteData(SharedBuffer::create(), "text/plain", "UTF-8", | 289 SubstituteData substituteData(SharedBuffer::create(), "text/plain", "UTF-8", |
| 298 KURL(), ForceSynchronousLoad); | 290 KURL(), ForceSynchronousLoad); |
| 299 FrameLoadRequest request(originDocument(), url(), substituteData); | 291 FrameLoadRequest request(originDocument(), url(), substituteData); |
| 300 request.setReplacesCurrentItem(true); | 292 request.setReplacesCurrentItem(true); |
| 301 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); | 293 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); |
| 302 maybeLogScheduledNavigationClobber( | 294 maybeLogScheduledNavigationClobber( |
| 303 ScheduledNavigationType::ScheduledPageBlock, frame, request, | 295 ScheduledNavigationType::ScheduledPageBlock, frame); |
| 304 gestureIndicator.get()); | |
| 305 frame->loader().load(request); | 296 frame->loader().load(request); |
| 306 } | 297 } |
| 307 | 298 |
| 308 private: | 299 private: |
| 309 ScheduledPageBlock(Document* originDocument, const String& url) | 300 ScheduledPageBlock(Document* originDocument, const String& url) |
| 310 : ScheduledURLNavigation(0.0, originDocument, url, true, true) {} | 301 : ScheduledURLNavigation(0.0, originDocument, url, true, true) {} |
| 311 }; | 302 }; |
| 312 | 303 |
| 313 class ScheduledFormSubmission final : public ScheduledNavigation { | 304 class ScheduledFormSubmission final : public ScheduledNavigation { |
| 314 public: | 305 public: |
| 315 static ScheduledFormSubmission* create(Document* document, | 306 static ScheduledFormSubmission* create(Document* document, |
| 316 FormSubmission* submission, | 307 FormSubmission* submission, |
| 317 bool replacesCurrentItem) { | 308 bool replacesCurrentItem) { |
| 318 return new ScheduledFormSubmission(document, submission, | 309 return new ScheduledFormSubmission(document, submission, |
| 319 replacesCurrentItem); | 310 replacesCurrentItem); |
| 320 } | 311 } |
| 321 | 312 |
| 322 void fire(LocalFrame* frame) override { | 313 void fire(LocalFrame* frame) override { |
| 323 std::unique_ptr<UserGestureIndicator> gestureIndicator = | 314 std::unique_ptr<UserGestureIndicator> gestureIndicator = |
| 324 createUserGestureIndicator(); | 315 createUserGestureIndicator(); |
| 325 FrameLoadRequest frameRequest = | 316 FrameLoadRequest frameRequest = |
| 326 m_submission->createFrameLoadRequest(originDocument()); | 317 m_submission->createFrameLoadRequest(originDocument()); |
| 327 frameRequest.setReplacesCurrentItem(replacesCurrentItem()); | 318 frameRequest.setReplacesCurrentItem(replacesCurrentItem()); |
| 328 maybeLogScheduledNavigationClobber( | 319 maybeLogScheduledNavigationClobber( |
| 329 ScheduledNavigationType::ScheduledFormSubmission, frame, frameRequest, | 320 ScheduledNavigationType::ScheduledFormSubmission, frame); |
| 330 gestureIndicator.get()); | |
| 331 frame->loader().load(frameRequest); | 321 frame->loader().load(frameRequest); |
| 332 } | 322 } |
| 333 | 323 |
| 334 DEFINE_INLINE_VIRTUAL_TRACE() { | 324 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 335 visitor->trace(m_submission); | 325 visitor->trace(m_submission); |
| 336 ScheduledNavigation::trace(visitor); | 326 ScheduledNavigation::trace(visitor); |
| 337 } | 327 } |
| 338 | 328 |
| 339 private: | 329 private: |
| 340 ScheduledFormSubmission(Document* document, | 330 ScheduledFormSubmission(Document* document, |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 m_navigateTaskFactory->cancel(); | 544 m_navigateTaskFactory->cancel(); |
| 555 m_redirect.clear(); | 545 m_redirect.clear(); |
| 556 } | 546 } |
| 557 | 547 |
| 558 DEFINE_TRACE(NavigationScheduler) { | 548 DEFINE_TRACE(NavigationScheduler) { |
| 559 visitor->trace(m_frame); | 549 visitor->trace(m_frame); |
| 560 visitor->trace(m_redirect); | 550 visitor->trace(m_redirect); |
| 561 } | 551 } |
| 562 | 552 |
| 563 } // namespace blink | 553 } // namespace blink |
| OLD | NEW |