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

Side by Side Diff: components/offline_pages/core/task_queue.h

Issue 2535273003: [Offline pages] TaskQueue polishing (Closed)
Patch Set: Created 4 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
« no previous file with comments | « components/offline_pages/core/task.h ('k') | components/offline_pages/core/task_queue.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 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 COMPONENTS_OFFLINE_PAGES_CORE_TASK_QUEUE_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_TASK_QUEUE_H_
6 #define COMPONENTS_OFFLINE_PAGES_CORE_TASK_QUEUE_H_ 6 #define COMPONENTS_OFFLINE_PAGES_CORE_TASK_QUEUE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <queue> 9 #include <queue>
10 10
(...skipping 25 matching lines...) Expand all
36 void AddTask(std::unique_ptr<Task> task); 36 void AddTask(std::unique_ptr<Task> task);
37 // Whether the task queue has any pending (not-running) tasks. 37 // Whether the task queue has any pending (not-running) tasks.
38 bool HasPendingTasks() const; 38 bool HasPendingTasks() const;
39 // Whether there is a task currently running. 39 // Whether there is a task currently running.
40 bool HasRunningTask() const; 40 bool HasRunningTask() const;
41 41
42 private: 42 private:
43 // Checks whether there are any tasks to run, as well as whether no task is 43 // Checks whether there are any tasks to run, as well as whether no task is
44 // currently running. When both are met, it will start the next task in the 44 // currently running. When both are met, it will start the next task in the
45 // queue. 45 // queue.
46 void MaybeStartTask(); 46 void StartTaskIfAvailable();
47 47
48 // Callback for informing the queue that a task was completed. 48 // Callback for informing the queue that a task was completed.
49 void TaskCompleted(Task* task); 49 void TaskCompleted(Task* task);
50 50
51 // Currently running tasks. 51 // Currently running tasks.
52 std::unique_ptr<Task> current_task_; 52 std::unique_ptr<Task> current_task_;
53 53
54 // A FIFO queue of tasks that will be run using this task queue. 54 // A FIFO queue of tasks that will be run using this task queue.
55 std::queue<std::unique_ptr<Task>> tasks_; 55 std::queue<std::unique_ptr<Task>> tasks_;
56 56
57 base::WeakPtrFactory<TaskQueue> weak_ptr_factory_; 57 base::WeakPtrFactory<TaskQueue> weak_ptr_factory_;
58 58
59 DISALLOW_COPY_AND_ASSIGN(TaskQueue); 59 DISALLOW_COPY_AND_ASSIGN(TaskQueue);
60 }; 60 };
61 61
62 } // namespace offline_pages 62 } // namespace offline_pages
63 63
64 #endif // COMPONENTS_OFFLINE_PAGES_CORE_TASK_QUEUE_H_ 64 #endif // COMPONENTS_OFFLINE_PAGES_CORE_TASK_QUEUE_H_
OLDNEW
« no previous file with comments | « components/offline_pages/core/task.h ('k') | components/offline_pages/core/task_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698