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

Side by Side Diff: components/scheduler/base/work_queue_sets.h

Issue 1685093002: Fix bug with TaskQueueSelector and blocked queues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix UAF Created 4 years, 10 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
« no previous file with comments | « components/scheduler/base/work_queue.cc ('k') | components/scheduler/base/work_queue_sets.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 COMPONENTS_SCHEDULER_BASE_WORK_QUEUE_SETS_H_ 5 #ifndef COMPONENTS_SCHEDULER_BASE_WORK_QUEUE_SETS_H_
6 #define COMPONENTS_SCHEDULER_BASE_WORK_QUEUE_SETS_H_ 6 #define COMPONENTS_SCHEDULER_BASE_WORK_QUEUE_SETS_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/trace_event/trace_event_argument.h" 15 #include "base/trace_event/trace_event_argument.h"
16 #include "components/scheduler/base/task_queue_impl.h" 16 #include "components/scheduler/base/task_queue_impl.h"
17 #include "components/scheduler/scheduler_export.h" 17 #include "components/scheduler/scheduler_export.h"
18 18
19 namespace scheduler { 19 namespace scheduler {
20 namespace internal { 20 namespace internal {
21 class TaskQueueImpl; 21 class TaskQueueImpl;
22 22
23 class SCHEDULER_EXPORT WorkQueueSets { 23 class SCHEDULER_EXPORT WorkQueueSets {
24 public: 24 public:
25 explicit WorkQueueSets(size_t num_sets); 25 WorkQueueSets(size_t num_sets, const char* name);
26 ~WorkQueueSets(); 26 ~WorkQueueSets();
27 27
28 // O(log num queues) 28 // O(log num queues)
29 void AddQueue(WorkQueue* queue, size_t set_index);
30
31 // O(log num queues)
29 void RemoveQueue(WorkQueue* work_queue); 32 void RemoveQueue(WorkQueue* work_queue);
30 33
31 // O(log num queues) 34 // O(log num queues)
32 void AssignQueueToSet(WorkQueue* queue, size_t set_index); 35 void ChangeSetIndex(WorkQueue* queue, size_t set_index);
33 36
34 // O(log num queues) 37 // O(log num queues)
35 void OnPushQueue(WorkQueue* work_queue); 38 void OnPushQueue(WorkQueue* work_queue);
36 39
37 // If empty it's O(1) amortized, otherwise it's O(log num queues) 40 // If empty it's O(1) amortized, otherwise it's O(log num queues)
38 void OnPopQueue(WorkQueue* work_queue); 41 void OnPopQueue(WorkQueue* work_queue);
39 42
40 // O(1) 43 // O(1)
41 bool GetOldestQueueInSet(size_t set_index, WorkQueue** out_work_queue) const; 44 bool GetOldestQueueInSet(size_t set_index, WorkQueue** out_work_queue) const;
42 45
43 // O(1) 46 // O(1)
44 bool IsSetEmpty(size_t set_index) const; 47 bool IsSetEmpty(size_t set_index) const;
45 48
46 #if DCHECK_IS_ON() || !defined(NDEBUG) 49 #if DCHECK_IS_ON() || !defined(NDEBUG)
47 // Note this iterates over everything in |enqueue_order_to_work_queue_maps_|. 50 // Note this iterates over everything in |enqueue_order_to_work_queue_maps_|.
48 // It's intended for use with DCHECKS and for testing 51 // It's intended for use with DCHECKS and for testing
49 bool ContainsWorkQueueForTest(WorkQueue* queue) const; 52 bool ContainsWorkQueueForTest(const WorkQueue* queue) const;
50 #endif 53 #endif
51 54
55 const char* name() const { return name_; }
56
52 private: 57 private:
53 typedef std::map<EnqueueOrder, WorkQueue*> EnqueueOrderToWorkQueueMap; 58 typedef std::map<EnqueueOrder, WorkQueue*> EnqueueOrderToWorkQueueMap;
54 std::vector<EnqueueOrderToWorkQueueMap> enqueue_order_to_work_queue_maps_; 59 std::vector<EnqueueOrderToWorkQueueMap> enqueue_order_to_work_queue_maps_;
60 const char* name_;
55 61
56 DISALLOW_COPY_AND_ASSIGN(WorkQueueSets); 62 DISALLOW_COPY_AND_ASSIGN(WorkQueueSets);
57 }; 63 };
58 64
59 } // namespace internal 65 } // namespace internal
60 } // namespace scheduler 66 } // namespace scheduler
61 67
62 #endif // COMPONENTS_SCHEDULER_BASE_WORK_QUEUE_SETS_H_ 68 #endif // COMPONENTS_SCHEDULER_BASE_WORK_QUEUE_SETS_H_
OLDNEW
« no previous file with comments | « components/scheduler/base/work_queue.cc ('k') | components/scheduler/base/work_queue_sets.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698