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

Side by Side Diff: components/scheduler/renderer/throttling_helper.h

Issue 1441073006: Move throttling of background timers into the renderer scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed various dchecks Created 5 years 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_
6 #define COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_
7
8 #include <set>
9
10 #include "base/macros.h"
11 #include "components/scheduler/base/time_domain.h"
12 #include "components/scheduler/scheduler_export.h"
13 #include "third_party/WebKit/public/platform/WebViewScheduler.h"
14
15 namespace scheduler {
16
17 class RendererSchedulerImpl;
18 class VirtualTimeDomain;
19 class WebFrameSchedulerImpl;
20
21 class SCHEDULER_EXPORT ThrottlingHelper : public TimeDomain::Observer {
22 public:
23 ThrottlingHelper(RendererSchedulerImpl* renderer_scheduler,
24 const char* tracing_category);
25
26 ~ThrottlingHelper() override;
27
28 // TimeDomain::Observer implementation:
29 void OnRegisterAsUpdatableTaskQueue() override;
30 void OnRequestWakeup() override;
31
32 void ThrottleBackgroundFrame(WebFrameSchedulerImpl* frame_scheduler);
Sami 2015/11/24 12:48:48 What if the unit that the ThrottlingHelper works w
alex clarke (OOO till 29th) 2015/11/25 12:30:12 Done.
Sami 2015/11/25 17:12:25 Thanks, this seems like a nice simplification.
alex clarke (OOO till 29th) 2015/11/26 18:43:27 Acknowledged.
33 void UnthrottleForegroundFrame(WebFrameSchedulerImpl* frame_scheduler);
34 void Unregister(WebFrameSchedulerImpl* frame_scheduler);
35
36 const scoped_refptr<VirtualTimeDomain>& time_domain() const {
37 return time_domain_;
38 }
39
40 static base::TimeDelta DelayToNextRunTimeInSeconds(base::TimeTicks now);
41
42 private:
43 void PumpThrottledTasks();
44 void MaybeSchedulePumpThrottledTasksLocked();
45
46 std::set<WebFrameSchedulerImpl*> background_frame_schedulers_;
47 base::Closure pump_throttled_tasks_closure_;
48 RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED
49 const char* tracing_category_; // NOT OWNED
50 scoped_refptr<VirtualTimeDomain> time_domain_;
51
52 // Protects members from the contigious block below.
Sami 2015/11/24 12:48:48 typo: contiguous
alex clarke (OOO till 29th) 2015/11/25 12:29:36 Acknowledged.
53 base::Lock lock_;
54 bool pending_pump_throttled_tasks_;
55 bool work_to_do_;
56
57 base::WeakPtrFactory<ThrottlingHelper> weak_factory_;
58
59 DISALLOW_COPY_AND_ASSIGN(ThrottlingHelper);
60 };
61
62 } // namespace scheduler
63
64 #endif // COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698