| 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 #include "public/platform/WebPassOwnPtr.h" | 10 |
| 11 #include <memory> |
| 11 | 12 |
| 12 namespace blink { | 13 namespace blink { |
| 13 | 14 |
| 14 class WebFrameScheduler; | 15 class WebFrameScheduler; |
| 15 | 16 |
| 16 class BLINK_PLATFORM_EXPORT WebViewScheduler { | 17 class BLINK_PLATFORM_EXPORT WebViewScheduler { |
| 17 public: | 18 public: |
| 18 virtual ~WebViewScheduler() { } | 19 virtual ~WebViewScheduler() { } |
| 19 | 20 |
| 20 // The scheduler may throttle tasks associated with background pages. | 21 // The scheduler may throttle tasks associated with background pages. |
| 21 virtual void setPageVisible(bool) = 0; | 22 virtual void setPageVisible(bool) = 0; |
| 22 | 23 |
| 23 // Creates a new WebFrameScheduler. The caller is responsible for deleting | 24 // Creates a new WebFrameScheduler. The caller is responsible for deleting |
| 24 // it. All tasks executed by the frame scheduler will be attributed to | 25 // it. All tasks executed by the frame scheduler will be attributed to |
| 25 // |BlameContext|. | 26 // |BlameContext|. |
| 26 virtual WebPassOwnPtr<WebFrameScheduler> createFrameScheduler(BlameContext*)
= 0; | 27 virtual std::unique_ptr<WebFrameScheduler> createFrameScheduler(BlameContext
*) = 0; |
| 27 | 28 |
| 28 // Instructs this WebViewScheduler to use virtual time. When virtual time is
enabled | 29 // Instructs this WebViewScheduler to use virtual time. When virtual time is
enabled |
| 29 // the system doesn't actually sleep for the delays between tasks before exe
cuting | 30 // the system doesn't actually sleep for the delays between tasks before exe
cuting |
| 30 // them. E.g: A-E are delayed tasks | 31 // them. E.g: A-E are delayed tasks |
| 31 // | 32 // |
| 32 // | A B C D E (normal) | 33 // | A B C D E (normal) |
| 33 // |-----------------------------> time | 34 // |-----------------------------> time |
| 34 // | 35 // |
| 35 // |ABCDE (virtual time) | 36 // |ABCDE (virtual time) |
| 36 // |-----------------------------> time | 37 // |-----------------------------> time |
| 37 virtual void enableVirtualTime() = 0; | 38 virtual void enableVirtualTime() = 0; |
| 38 | 39 |
| 39 // Controls whether or not virtual time is allowed to advance. If virtual ti
me | 40 // Controls whether or not virtual time is allowed to advance. If virtual ti
me |
| 40 // is not allowed to advance then delayed tasks posted to the WebTaskRunners
owned | 41 // is not allowed to advance then delayed tasks posted to the WebTaskRunners
owned |
| 41 // by any child WebFrameSchedulers will be paused. If virtual time is allowe
d to | 42 // by any child WebFrameSchedulers will be paused. If virtual time is allowe
d to |
| 42 // advance then tasks will be run in time order (as usual) but virtual time
will | 43 // advance then tasks will be run in time order (as usual) but virtual time
will |
| 43 // fast forward so that the system doesn't actually sleep for the delays bet
ween | 44 // fast forward so that the system doesn't actually sleep for the delays bet
ween |
| 44 // tasks before executing them. | 45 // tasks before executing them. |
| 45 virtual void setAllowVirtualTimeToAdvance(bool) = 0; | 46 virtual void setAllowVirtualTimeToAdvance(bool) = 0; |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 } // namespace blink | 49 } // namespace blink |
| 49 | 50 |
| 50 #endif // WebViewScheduler | 51 #endif // WebViewScheduler |
| OLD | NEW |