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

Side by Side Diff: Source/core/loader/NavigationScheduler.h

Issue 1164883002: Ignore attempts to navigate once a provisional commit has gotten too far along. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 3 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
4 * Copyright (C) 2009 Adam Barth. All rights reserved. 4 * Copyright (C) 2009 Adam Barth. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 29 matching lines...) Expand all
40 #include "wtf/OwnPtr.h" 40 #include "wtf/OwnPtr.h"
41 #include "wtf/PassOwnPtr.h" 41 #include "wtf/PassOwnPtr.h"
42 #include "wtf/PassRefPtr.h" 42 #include "wtf/PassRefPtr.h"
43 #include "wtf/text/WTFString.h" 43 #include "wtf/text/WTFString.h"
44 44
45 namespace blink { 45 namespace blink {
46 46
47 class Document; 47 class Document;
48 class FormSubmission; 48 class FormSubmission;
49 class LocalFrame; 49 class LocalFrame;
50 class NavigationScheduler;
50 class ScheduledNavigation; 51 class ScheduledNavigation;
51 52
52 class NavigationDisablerForBeforeUnload { 53 class NavigationDisabler {
Nate Chapin 2015/06/09 00:15:20 I guess I'd prefer to leave the old name.
michaeln 2015/06/09 01:15:02 Done.
53 WTF_MAKE_NONCOPYABLE(NavigationDisablerForBeforeUnload); 54 WTF_MAKE_NONCOPYABLE(NavigationDisabler);
54
55 public: 55 public:
56 NavigationDisablerForBeforeUnload() 56 NavigationDisabler()
57 { 57 {
58 s_navigationDisableCount++; 58 s_navigationDisableCount++;
59 } 59 }
60 ~NavigationDisablerForBeforeUnload() 60 ~NavigationDisabler()
61 { 61 {
62 ASSERT(s_navigationDisableCount); 62 ASSERT(s_navigationDisableCount);
63 s_navigationDisableCount--; 63 s_navigationDisableCount--;
64 } 64 }
65 static bool isNavigationAllowed() { return !s_navigationDisableCount; } 65 static bool isNavigationAllowed() { return !s_navigationDisableCount; }
66 66
67 private: 67 private:
68 static unsigned s_navigationDisableCount; 68 static unsigned s_navigationDisableCount;
69 }; 69 };
70 70
71 class FrameNavigationDisabler {
72 WTF_MAKE_NONCOPYABLE(FrameNavigationDisabler);
73 public:
74 explicit FrameNavigationDisabler(LocalFrame*);
75 ~FrameNavigationDisabler();
76
77 private:
78 NavigationScheduler& m_navigationScheduler;
79 };
80
71 class CORE_EXPORT NavigationScheduler final { 81 class CORE_EXPORT NavigationScheduler final {
72 WTF_MAKE_NONCOPYABLE(NavigationScheduler); 82 WTF_MAKE_NONCOPYABLE(NavigationScheduler);
73 DISALLOW_ALLOCATION(); 83 DISALLOW_ALLOCATION();
74 public: 84 public:
75 explicit NavigationScheduler(LocalFrame*); 85 explicit NavigationScheduler(LocalFrame*);
76 ~NavigationScheduler(); 86 ~NavigationScheduler();
77 87
78 bool locationChangePending(); 88 bool locationChangePending();
79 89
80 void scheduleRedirect(double delay, const String& url); 90 void scheduleRedirect(double delay, const String& url);
81 void scheduleLocationChange(Document*, const String& url, bool lockBackForwa rdList = true); 91 void scheduleLocationChange(Document*, const String& url, bool lockBackForwa rdList = true);
82 void schedulePageBlock(Document*); 92 void schedulePageBlock(Document*);
83 void scheduleFormSubmission(Document*, PassRefPtrWillBeRawPtr<FormSubmission >); 93 void scheduleFormSubmission(Document*, PassRefPtrWillBeRawPtr<FormSubmission >);
84 void scheduleReload(); 94 void scheduleReload();
85 95
86 void startTimer(); 96 void startTimer();
87 void cancel(); 97 void cancel();
88 98
89 DECLARE_TRACE(); 99 DECLARE_TRACE();
90 100
91 private: 101 private:
102 friend class FrameNavigationDisabler;
103
104 void disableFrameNavigation() { ++m_disabledCount; }
105 void enableFrameNavigation() { --m_disabledCount; }
106 bool isFrameNavigationAllowed() const { return !m_disabledCount; }
107
92 bool shouldScheduleReload() const; 108 bool shouldScheduleReload() const;
93 bool shouldScheduleNavigation(const String& url) const; 109 bool shouldScheduleNavigation(const String& url) const;
94 110
95 void timerFired(Timer<NavigationScheduler>*); 111 void timerFired(Timer<NavigationScheduler>*);
96 void schedule(PassOwnPtrWillBeRawPtr<ScheduledNavigation>); 112 void schedule(PassOwnPtrWillBeRawPtr<ScheduledNavigation>);
97 113
98 static bool mustLockBackForwardList(LocalFrame* targetFrame); 114 static bool mustLockBackForwardList(LocalFrame* targetFrame);
99 115
100 RawPtrWillBeMember<LocalFrame> m_frame; 116 RawPtrWillBeMember<LocalFrame> m_frame;
101 Timer<NavigationScheduler> m_timer; 117 Timer<NavigationScheduler> m_timer;
102 OwnPtrWillBeMember<ScheduledNavigation> m_redirect; 118 OwnPtrWillBeMember<ScheduledNavigation> m_redirect;
119 int m_disabledCount = 0;
Nate Chapin 2015/06/09 00:15:20 I think it's blink standard to use initialziers ab
michaeln 2015/06/09 01:15:02 Done.
103 }; 120 };
104 121
105 } // namespace blink 122 } // namespace blink
106 123
107 #endif // NavigationScheduler_h 124 #endif // NavigationScheduler_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698