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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/child/idle_helper.h

Issue 2487343004: Make sure scheduler shutdown prevents idle tasks from running (Closed)
Patch Set: Added a test which fails without the patch. Created 4 years, 1 month 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/child/idle_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_CHILD_IDLE_HELPER_H_ 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_CHILD_IDLE_HELPER_H_
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_CHILD_IDLE_HELPER_H_ 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_CHILD_IDLE_HELPER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "platform/scheduler/base/cancelable_closure_holder.h" 10 #include "platform/scheduler/base/cancelable_closure_holder.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // outlive it. 87 // outlive it.
88 IdleHelper( 88 IdleHelper(
89 SchedulerHelper* helper, 89 SchedulerHelper* helper,
90 Delegate* delegate, 90 Delegate* delegate,
91 const char* tracing_category, 91 const char* tracing_category,
92 const char* disabled_by_default_tracing_category, 92 const char* disabled_by_default_tracing_category,
93 const char* idle_period_tracing_name, 93 const char* idle_period_tracing_name,
94 base::TimeDelta required_quiescence_duration_before_long_idle_period); 94 base::TimeDelta required_quiescence_duration_before_long_idle_period);
95 ~IdleHelper() override; 95 ~IdleHelper() override;
96 96
97 // Prevents any further idle tasks from running.
98 void Shutdown();
99
97 // Returns the idle task runner. Tasks posted to this runner may be reordered 100 // Returns the idle task runner. Tasks posted to this runner may be reordered
98 // relative to other task types and may be starved for an arbitrarily long 101 // relative to other task types and may be starved for an arbitrarily long
99 // time if no idle time is available. 102 // time if no idle time is available.
100 scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner(); 103 scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner();
101 104
102 // If |required_quiescence_duration_before_long_idle_period_| is zero then 105 // If |required_quiescence_duration_before_long_idle_period_| is zero then
103 // immediately initiate a long idle period, otherwise check if any tasks have 106 // immediately initiate a long idle period, otherwise check if any tasks have
104 // run recently and if so, check again after a delay of 107 // run recently and if so, check again after a delay of
105 // |required_quiescence_duration_before_long_idle_period_|. 108 // |required_quiescence_duration_before_long_idle_period_|.
106 // Calling this function will end any previous idle period immediately, and 109 // Calling this function will end any previous idle period immediately, and
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 225
223 CancelableClosureHolder enable_next_long_idle_period_closure_; 226 CancelableClosureHolder enable_next_long_idle_period_closure_;
224 CancelableClosureHolder on_idle_task_posted_closure_; 227 CancelableClosureHolder on_idle_task_posted_closure_;
225 228
226 State state_; 229 State state_;
227 230
228 base::TimeDelta required_quiescence_duration_before_long_idle_period_; 231 base::TimeDelta required_quiescence_duration_before_long_idle_period_;
229 232
230 const char* disabled_by_default_tracing_category_; 233 const char* disabled_by_default_tracing_category_;
231 234
235 bool is_shutdown_;
236
232 base::WeakPtr<IdleHelper> weak_idle_helper_ptr_; 237 base::WeakPtr<IdleHelper> weak_idle_helper_ptr_;
233 base::WeakPtrFactory<IdleHelper> weak_factory_; 238 base::WeakPtrFactory<IdleHelper> weak_factory_;
234 239
235 DISALLOW_COPY_AND_ASSIGN(IdleHelper); 240 DISALLOW_COPY_AND_ASSIGN(IdleHelper);
236 }; 241 };
237 242
238 } // namespace scheduler 243 } // namespace scheduler
239 } // namespace blink 244 } // namespace blink
240 245
241 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_CHILD_IDLE_HELPER_H_ 246 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_CHILD_IDLE_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/child/idle_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698