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

Side by Side Diff: base/task_scheduler/task_tracker.h

Issue 2857103005: Exempt the Service Thread from BLOCK_SHUTDOWN DCHECKs (Closed)
Patch Set: CR Feedback + Additional DCHECK_IS_ON due to the way DCHECKs are implemented Created 3 years, 7 months 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 BASE_TASK_SCHEDULER_TASK_TRACKER_H_ 5 #ifndef BASE_TASK_SCHEDULER_TASK_TRACKER_H_
6 #define BASE_TASK_SCHEDULER_TASK_TRACKER_H_ 6 #define BASE_TASK_SCHEDULER_TASK_TRACKER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
11 #include "base/base_export.h" 11 #include "base/base_export.h"
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/logging.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/metrics/histogram_base.h" 15 #include "base/metrics/histogram_base.h"
15 #include "base/synchronization/waitable_event.h" 16 #include "base/synchronization/waitable_event.h"
16 #include "base/task_scheduler/scheduler_lock.h" 17 #include "base/task_scheduler/scheduler_lock.h"
17 #include "base/task_scheduler/sequence.h" 18 #include "base/task_scheduler/sequence.h"
18 #include "base/task_scheduler/task.h" 19 #include "base/task_scheduler/task.h"
19 #include "base/task_scheduler/task_traits.h" 20 #include "base/task_scheduler/task_traits.h"
20 21
21 namespace base { 22 namespace base {
22 23
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // Causes HasShutdownStarted() to return true. Unlike when Shutdown() returns, 74 // Causes HasShutdownStarted() to return true. Unlike when Shutdown() returns,
74 // IsShutdownComplete() won't return true after this returns. Shutdown() 75 // IsShutdownComplete() won't return true after this returns. Shutdown()
75 // cannot be called after this. 76 // cannot be called after this.
76 void SetHasShutdownStartedForTesting(); 77 void SetHasShutdownStartedForTesting();
77 78
78 protected: 79 protected:
79 // Runs |task|. An override is expected to call its parent's implementation 80 // Runs |task|. An override is expected to call its parent's implementation
80 // but is free to perform extra work before and after doing so. 81 // but is free to perform extra work before and after doing so.
81 virtual void PerformRunTask(std::unique_ptr<Task> task); 82 virtual void PerformRunTask(std::unique_ptr<Task> task);
82 83
84 #if DCHECK_IS_ON()
85 // Returns true if this context should be exempt from blocking shutdown
86 // DCHECKs.
87 // TODO(robliao): Remove when http://crbug.com/698140 is fixed.
88 virtual bool IsExemptFromBlockingShutdownChecks();
89 #endif
90
83 private: 91 private:
84 class State; 92 class State;
85 93
86 void PerformShutdown(); 94 void PerformShutdown();
87 95
88 // Called before WillPostTask() informs the tracing system that a task has 96 // Called before WillPostTask() informs the tracing system that a task has
89 // been posted. Updates |num_tasks_blocking_shutdown_| if necessary and 97 // been posted. Updates |num_tasks_blocking_shutdown_| if necessary and
90 // returns true if the current shutdown state allows the task to be posted. 98 // returns true if the current shutdown state allows the task to be posted.
91 bool BeforePostTask(TaskShutdownBehavior shutdown_behavior); 99 bool BeforePostTask(TaskShutdownBehavior shutdown_behavior);
92 100
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Number of BLOCK_SHUTDOWN tasks posted during shutdown. 156 // Number of BLOCK_SHUTDOWN tasks posted during shutdown.
149 HistogramBase::Sample num_block_shutdown_tasks_posted_during_shutdown_ = 0; 157 HistogramBase::Sample num_block_shutdown_tasks_posted_during_shutdown_ = 0;
150 158
151 DISALLOW_COPY_AND_ASSIGN(TaskTracker); 159 DISALLOW_COPY_AND_ASSIGN(TaskTracker);
152 }; 160 };
153 161
154 } // namespace internal 162 } // namespace internal
155 } // namespace base 163 } // namespace base
156 164
157 #endif // BASE_TASK_SCHEDULER_TASK_TRACKER_H_ 165 #endif // BASE_TASK_SCHEDULER_TASK_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698