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

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

Issue 1330653003: Oilpan: tidy up NavigationScheduler. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove redundant constructor hiding Created 5 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/loader/FrameLoader.cpp ('k') | Source/core/loader/NavigationScheduler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 14 matching lines...) Expand all
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef NavigationScheduler_h 31 #ifndef NavigationScheduler_h
32 #define NavigationScheduler_h 32 #define NavigationScheduler_h
33 33
34 #include "core/CoreExport.h" 34 #include "core/CoreExport.h"
35 #include "platform/Timer.h"
36 #include "platform/heap/Handle.h" 35 #include "platform/heap/Handle.h"
37 #include "platform/scheduler/CancellableTaskFactory.h"
38 #include "wtf/Forward.h" 36 #include "wtf/Forward.h"
39 #include "wtf/HashMap.h" 37 #include "wtf/HashMap.h"
40 #include "wtf/Noncopyable.h" 38 #include "wtf/Noncopyable.h"
41 #include "wtf/OwnPtr.h" 39 #include "wtf/OwnPtr.h"
42 #include "wtf/PassOwnPtr.h" 40 #include "wtf/PassOwnPtr.h"
43 #include "wtf/PassRefPtr.h" 41 #include "wtf/PassRefPtr.h"
44 #include "wtf/text/WTFString.h" 42 #include "wtf/text/WTFString.h"
45 43
46 namespace blink { 44 namespace blink {
47 45
46 class CancellableTaskFactory;
48 class Document; 47 class Document;
49 class FormSubmission; 48 class FormSubmission;
50 class LocalFrame; 49 class LocalFrame;
51 class NavigationScheduler;
52 class ScheduledNavigation; 50 class ScheduledNavigation;
53 51
54 class NavigationDisablerForBeforeUnload { 52 class CORE_EXPORT NavigationScheduler final : public NoBaseWillBeGarbageCollecte dFinalized<NavigationScheduler> {
55 WTF_MAKE_NONCOPYABLE(NavigationDisablerForBeforeUnload); 53 WTF_MAKE_NONCOPYABLE(NavigationScheduler);
56 STACK_ALLOCATED(); 54 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(NavigationScheduler);
57 public: 55 public:
58 NavigationDisablerForBeforeUnload() 56 static PassOwnPtrWillBeRawPtr<NavigationScheduler> create(LocalFrame* frame)
59 { 57 {
60 s_navigationDisableCount++; 58 return adoptPtrWillBeNoop(new NavigationScheduler(frame));
61 } 59 }
62 ~NavigationDisablerForBeforeUnload()
63 {
64 ASSERT(s_navigationDisableCount);
65 s_navigationDisableCount--;
66 }
67 static bool isNavigationAllowed() { return !s_navigationDisableCount; }
68 60
69 private:
70 static unsigned s_navigationDisableCount;
71 };
72
73 class FrameNavigationDisabler {
74 WTF_MAKE_NONCOPYABLE(FrameNavigationDisabler);
75 STACK_ALLOCATED();
76 public:
77 explicit FrameNavigationDisabler(LocalFrame*);
78 ~FrameNavigationDisabler();
79
80 private:
81 FrameNavigationDisabler() = delete;
82
83 NavigationScheduler& m_navigationScheduler;
84 };
85
86 class CORE_EXPORT NavigationScheduler final {
87 WTF_MAKE_NONCOPYABLE(NavigationScheduler);
88 DISALLOW_ALLOCATION();
89 public:
90 explicit NavigationScheduler(LocalFrame*);
91 ~NavigationScheduler(); 61 ~NavigationScheduler();
92 62
93 bool locationChangePending(); 63 bool locationChangePending();
94 bool isNavigationScheduled() const; 64 bool isNavigationScheduled() const;
95 65
96 void scheduleRedirect(double delay, const String& url); 66 void scheduleRedirect(double delay, const String& url);
97 void scheduleLocationChange(Document*, const String& url, bool replacesCurre ntItem = true); 67 void scheduleLocationChange(Document*, const String& url, bool replacesCurre ntItem = true);
98 void schedulePageBlock(Document*); 68 void schedulePageBlock(Document*);
99 void scheduleFormSubmission(Document*, PassRefPtrWillBeRawPtr<FormSubmission >); 69 void scheduleFormSubmission(Document*, PassRefPtrWillBeRawPtr<FormSubmission >);
100 void scheduleReload(); 70 void scheduleReload();
101 71
102 void startTimer(); 72 void startTimer();
103 void cancel(); 73 void cancel();
104 74
105 DECLARE_TRACE(); 75 DECLARE_TRACE();
106 76
107 private: 77 private:
108 friend class FrameNavigationDisabler; 78 friend class FrameNavigationDisabler;
79 explicit NavigationScheduler(LocalFrame*);
109 80
110 void disableFrameNavigation() { ++m_navigationDisableCount; } 81 void disableFrameNavigation() { ++m_navigationDisableCount; }
111 void enableFrameNavigation() { --m_navigationDisableCount; } 82 void enableFrameNavigation() { --m_navigationDisableCount; }
112 bool isFrameNavigationAllowed() const { return !m_navigationDisableCount; } 83 bool isFrameNavigationAllowed() const { return !m_navigationDisableCount; }
113 84
114 bool shouldScheduleReload() const; 85 bool shouldScheduleReload() const;
115 bool shouldScheduleNavigation(const String& url) const; 86 bool shouldScheduleNavigation(const String& url) const;
116 87
117 void navigateTask(); 88 void navigateTask();
118 void schedule(PassOwnPtrWillBeRawPtr<ScheduledNavigation>); 89 void schedule(PassOwnPtrWillBeRawPtr<ScheduledNavigation>);
119 90
120 static bool mustReplaceCurrentItem(LocalFrame* targetFrame); 91 static bool mustReplaceCurrentItem(LocalFrame* targetFrame);
121 92
122 RawPtrWillBeMember<LocalFrame> m_frame; 93 RawPtrWillBeMember<LocalFrame> m_frame;
123 CancellableTaskFactory m_navigateTaskFactory; 94 OwnPtr<CancellableTaskFactory> m_navigateTaskFactory;
124 OwnPtrWillBeMember<ScheduledNavigation> m_redirect; 95 OwnPtrWillBeMember<ScheduledNavigation> m_redirect;
125 int m_navigationDisableCount; 96 int m_navigationDisableCount;
126 }; 97 };
127 98
99 class NavigationDisablerForBeforeUnload {
100 WTF_MAKE_NONCOPYABLE(NavigationDisablerForBeforeUnload);
101 STACK_ALLOCATED();
102 public:
103 NavigationDisablerForBeforeUnload()
104 {
105 s_navigationDisableCount++;
106 }
107 ~NavigationDisablerForBeforeUnload()
108 {
109 ASSERT(s_navigationDisableCount);
110 s_navigationDisableCount--;
111 }
112 static bool isNavigationAllowed() { return !s_navigationDisableCount; }
113
114 private:
115 static unsigned s_navigationDisableCount;
116 };
117
118 class FrameNavigationDisabler {
119 WTF_MAKE_NONCOPYABLE(FrameNavigationDisabler);
120 STACK_ALLOCATED();
121 public:
122 explicit FrameNavigationDisabler(LocalFrame*);
123 ~FrameNavigationDisabler();
124
125 private:
126 RawPtrWillBeMember<NavigationScheduler> m_navigationScheduler;
127 };
128
128 } // namespace blink 129 } // namespace blink
129 130
130 #endif // NavigationScheduler_h 131 #endif // NavigationScheduler_h
OLDNEW
« no previous file with comments | « Source/core/loader/FrameLoader.cpp ('k') | Source/core/loader/NavigationScheduler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698