| 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 COMPONENTS_SCHEDULER_RENDERER_WEB_VIEW_SCHEDULER_IMPL_H_ | 5 #ifndef COMPONENTS_SCHEDULER_RENDERER_WEB_VIEW_SCHEDULER_IMPL_H_ |
| 6 #define COMPONENTS_SCHEDULER_RENDERER_WEB_VIEW_SCHEDULER_IMPL_H_ | 6 #define COMPONENTS_SCHEDULER_RENDERER_WEB_VIEW_SCHEDULER_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "components/scheduler/base/task_queue.h" | 13 #include "components/scheduler/base/task_queue.h" |
| 14 #include "components/scheduler/scheduler_export.h" | 14 #include "components/scheduler/scheduler_export.h" |
| 15 #include "third_party/WebKit/public/platform/WebViewScheduler.h" | 15 #include "third_party/WebKit/public/platform/WebViewScheduler.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 namespace trace_event { | 18 namespace trace_event { |
| 19 class BlameContext; | 19 class BlameContext; |
| 20 } // namespace trace_event | 20 } // namespace trace_event |
| 21 class SingleThreadTaskRunner; | 21 class SingleThreadTaskRunner; |
| 22 } // namespace base | 22 } // namespace base |
| 23 | 23 |
| 24 namespace blink { | 24 namespace blink { |
| 25 class WebView; | 25 class WebView; |
| 26 } // namespace blink | 26 } // namespace blink |
| 27 | 27 |
| 28 namespace scheduler { | 28 namespace scheduler { |
| 29 | 29 |
| 30 class AutoAdvancingVirtualTimeDomain; |
| 30 class RendererSchedulerImpl; | 31 class RendererSchedulerImpl; |
| 31 class WebFrameSchedulerImpl; | 32 class WebFrameSchedulerImpl; |
| 32 | 33 |
| 33 class SCHEDULER_EXPORT WebViewSchedulerImpl : public blink::WebViewScheduler { | 34 class SCHEDULER_EXPORT WebViewSchedulerImpl : public blink::WebViewScheduler { |
| 34 public: | 35 public: |
| 35 WebViewSchedulerImpl(blink::WebView* web_view, | 36 WebViewSchedulerImpl(blink::WebView* web_view, |
| 36 RendererSchedulerImpl* renderer_scheduler, | 37 RendererSchedulerImpl* renderer_scheduler, |
| 37 bool disable_background_timer_throttling); | 38 bool disable_background_timer_throttling); |
| 38 | 39 |
| 39 ~WebViewSchedulerImpl() override; | 40 ~WebViewSchedulerImpl() override; |
| 40 | 41 |
| 41 // blink::WebViewScheduler implementation: | 42 // blink::WebViewScheduler implementation: |
| 42 void setPageVisible(bool page_visible) override; | 43 void setPageVisible(bool page_visible) override; |
| 43 std::unique_ptr<blink::WebFrameScheduler> createFrameScheduler( | 44 std::unique_ptr<blink::WebFrameScheduler> createFrameScheduler( |
| 44 blink::BlameContext* blame_context) override; | 45 blink::BlameContext* blame_context) override; |
| 45 void enableVirtualTime() override; | 46 void enableVirtualTime() override; |
| 46 bool virtualTimeAllowedToAdvance() const override; | 47 bool virtualTimeAllowedToAdvance() const override; |
| 47 void setVirtualTimePolicy(VirtualTimePolicy virtual_time_policy) override; | 48 void setVirtualTimePolicy(VirtualTimePolicy virtual_time_policy) override; |
| 48 | 49 |
| 49 // Virtual for testing. | 50 // Virtual for testing. |
| 50 virtual void AddConsoleWarning(const std::string& message); | 51 virtual void AddConsoleWarning(const std::string& message); |
| 51 | 52 |
| 52 std::unique_ptr<WebFrameSchedulerImpl> createWebFrameSchedulerImpl( | 53 std::unique_ptr<WebFrameSchedulerImpl> createWebFrameSchedulerImpl( |
| 53 base::trace_event::BlameContext* blame_context); | 54 base::trace_event::BlameContext* blame_context); |
| 54 | 55 |
| 55 void DidStartLoading(unsigned long identifier); | 56 void DidStartLoading(unsigned long identifier); |
| 56 void DidStopLoading(unsigned long identifier); | 57 void DidStopLoading(unsigned long identifier); |
| 57 void IncrementBackgroundParserCount(); | 58 void IncrementBackgroundParserCount(); |
| 58 void DecrementBackgroundParserCount(); | 59 void DecrementBackgroundParserCount(); |
| 60 |
| 61 private: |
| 62 friend class WebFrameSchedulerImpl; |
| 63 |
| 59 void Unregister(WebFrameSchedulerImpl* frame_scheduler); | 64 void Unregister(WebFrameSchedulerImpl* frame_scheduler); |
| 60 | 65 |
| 61 private: | 66 AutoAdvancingVirtualTimeDomain* virtual_time_domain() const { |
| 67 return virtual_time_domain_.get(); |
| 68 } |
| 69 |
| 62 void setAllowVirtualTimeToAdvance(bool allow_virtual_time_to_advance); | 70 void setAllowVirtualTimeToAdvance(bool allow_virtual_time_to_advance); |
| 63 void ApplyVirtualTimePolicy(); | 71 void ApplyVirtualTimePolicy(); |
| 64 | 72 |
| 65 std::set<WebFrameSchedulerImpl*> frame_schedulers_; | 73 std::set<WebFrameSchedulerImpl*> frame_schedulers_; |
| 66 std::set<unsigned long> pending_loads_; | 74 std::set<unsigned long> pending_loads_; |
| 75 std::unique_ptr<AutoAdvancingVirtualTimeDomain> virtual_time_domain_; |
| 76 TaskQueue::PumpPolicy virtual_time_pump_policy_; |
| 67 blink::WebView* web_view_; | 77 blink::WebView* web_view_; |
| 68 RendererSchedulerImpl* renderer_scheduler_; | 78 RendererSchedulerImpl* renderer_scheduler_; |
| 69 VirtualTimePolicy virtual_time_policy_; | 79 VirtualTimePolicy virtual_time_policy_; |
| 70 int background_parser_count_; | 80 int background_parser_count_; |
| 71 bool page_visible_; | 81 bool page_visible_; |
| 72 bool disable_background_timer_throttling_; | 82 bool disable_background_timer_throttling_; |
| 73 bool allow_virtual_time_to_advance_; | 83 bool allow_virtual_time_to_advance_; |
| 74 bool have_seen_loading_task_; | |
| 75 bool virtual_time_; | |
| 76 | 84 |
| 77 DISALLOW_COPY_AND_ASSIGN(WebViewSchedulerImpl); | 85 DISALLOW_COPY_AND_ASSIGN(WebViewSchedulerImpl); |
| 78 }; | 86 }; |
| 79 | 87 |
| 80 } // namespace scheduler | 88 } // namespace scheduler |
| 81 | 89 |
| 82 #endif // COMPONENTS_SCHEDULER_RENDERER_WEB_VIEW_SCHEDULER_IMPL_H_ | 90 #endif // COMPONENTS_SCHEDULER_RENDERER_WEB_VIEW_SCHEDULER_IMPL_H_ |
| OLD | NEW |