Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WebViewScheduler_h | 5 #ifndef WebViewScheduler_h |
| 6 #define WebViewScheduler_h | 6 #define WebViewScheduler_h |
| 7 | 7 |
| 8 #include "WebCommon.h" | 8 #include "WebCommon.h" |
| 9 #include "public/platform/BlameContext.h" | 9 #include "public/platform/BlameContext.h" |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 class WebFrameScheduler; | 15 class WebFrameScheduler; |
| 16 | 16 |
| 17 class BLINK_PLATFORM_EXPORT WebViewScheduler { | 17 class BLINK_PLATFORM_EXPORT WebViewScheduler { |
| 18 public: | 18 public: |
| 19 virtual ~WebViewScheduler() { } | 19 WebViewScheduler(); |
| 20 virtual ~WebViewScheduler(); | |
| 20 | 21 |
| 21 // The scheduler may throttle tasks associated with background pages. | 22 // The scheduler may throttle tasks associated with background pages. |
| 22 virtual void setPageVisible(bool) = 0; | 23 virtual void setPageVisible(bool) = 0; |
| 23 | 24 |
| 24 // Creates a new WebFrameScheduler. The caller is responsible for deleting | 25 // Creates a new WebFrameScheduler. The caller is responsible for deleting |
| 25 // it. All tasks executed by the frame scheduler will be attributed to | 26 // it. All tasks executed by the frame scheduler will be attributed to |
| 26 // |BlameContext|. | 27 // |BlameContext|. |
| 27 virtual std::unique_ptr<WebFrameScheduler> createFrameScheduler(BlameContext *) = 0; | 28 virtual std::unique_ptr<WebFrameScheduler> createFrameScheduler(BlameContext *) = 0; |
| 28 | 29 |
| 29 // Instructs this WebViewScheduler to use virtual time. When virtual time is enabled | 30 // Instructs this WebViewScheduler to use virtual time. When virtual time is enabled |
| 30 // the system doesn't actually sleep for the delays between tasks before exe cuting | 31 // the system doesn't actually sleep for the delays between tasks before exe cuting |
| 31 // them. E.g: A-E are delayed tasks | 32 // them. E.g: A-E are delayed tasks |
| 32 // | 33 // |
| 33 // | A B C D E (normal) | 34 // | A B C D E (normal) |
| 34 // |-----------------------------> time | 35 // |-----------------------------> time |
| 35 // | 36 // |
| 36 // |ABCDE (virtual time) | 37 // |ABCDE (virtual time) |
| 37 // |-----------------------------> time | 38 // |-----------------------------> time |
| 38 virtual void enableVirtualTime() = 0; | 39 virtual void enableVirtualTime() = 0; |
| 39 | 40 |
| 40 // Controls whether or not virtual time is allowed to advance. If virtual ti me | 41 // Controls whether or not virtual time is allowed to advance. If virtual ti me |
| 41 // is not allowed to advance then delayed tasks posted to the WebTaskRunners owned | 42 // is not allowed to advance then delayed tasks posted to the WebTaskRunners owned |
| 42 // by any child WebFrameSchedulers will be paused. If virtual time is allowe d to | 43 // by any child WebFrameSchedulers will be paused. If virtual time is allowe d to |
| 43 // advance then tasks will be run in time order (as usual) but virtual time will | 44 // advance then tasks will be run in time order (as usual) but virtual time will |
| 44 // fast forward so that the system doesn't actually sleep for the delays bet ween | 45 // fast forward so that the system doesn't actually sleep for the delays bet ween |
| 45 // tasks before executing them. | 46 // tasks before executing them. |
| 46 virtual void setAllowVirtualTimeToAdvance(bool) = 0; | 47 virtual void setAllowVirtualTimeToAdvance(bool) = 0; |
| 48 | |
| 49 // Returns true if virtual time is allowed to advance. | |
| 50 virtual bool virtualTimeAllowedToAdvance() const = 0; | |
| 51 | |
| 52 void incrementPendingResourceLoadCount(); | |
|
Sami
2016/07/01 14:46:30
Could you add these on the WebFrameScheduler inste
alex clarke (OOO till 29th)
2016/07/01 15:53:23
Done.
| |
| 53 void decrementPendingResourceLoadCount(); | |
| 54 | |
| 55 enum class VirtualTimePolicy { | |
| 56 ADVANCE, | |
| 57 PAUSE, | |
| 58 PAUSE_IF_NETWORK_FETCHES_PENDING | |
| 59 }; | |
| 60 | |
| 61 void setVirtualTimePolicy(VirtualTimePolicy); | |
| 62 | |
| 63 private: | |
| 64 int m_pendingResourceLoadCount; | |
| 65 VirtualTimePolicy m_virtualTimePolicy; | |
| 47 }; | 66 }; |
| 48 | 67 |
| 49 } // namespace blink | 68 } // namespace blink |
| 50 | 69 |
| 51 #endif // WebViewScheduler | 70 #endif // WebViewScheduler |
| OLD | NEW |