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