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

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

Issue 2473553004: Request Picker task (Closed)
Patch Set: Replace use of header file with forward declare for enum 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
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 #include "components/offline_pages/core/task_queue.h" 5 #include "components/offline_pages/core/task_queue.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/threading/thread_task_runner_handle.h" 8 #include "base/threading/thread_task_runner_handle.h"
9 9
10 namespace offline_pages { 10 namespace offline_pages {
(...skipping 12 matching lines...) Expand all
23 23
24 bool TaskQueue::HasPendingTasks() const { 24 bool TaskQueue::HasPendingTasks() const {
25 return !tasks_.empty() || HasRunningTask(); 25 return !tasks_.empty() || HasRunningTask();
26 } 26 }
27 27
28 bool TaskQueue::HasRunningTask() const { 28 bool TaskQueue::HasRunningTask() const {
29 return current_task_.get() != nullptr; 29 return current_task_.get() != nullptr;
30 } 30 }
31 31
32 void TaskQueue::MaybeStartTask() { 32 void TaskQueue::MaybeStartTask() {
33 DVLOG(2) << "running? " << HasRunningTask() << ", pending? "
fgorski 2016/11/09 17:58:07 is this needed?
Pete Williamson 2016/11/09 23:53:56 Yes. I've added it about 5 times while debugging,
34 << HasPendingTasks() << " " << __func__;
33 if (HasRunningTask() || !HasPendingTasks()) 35 if (HasRunningTask() || !HasPendingTasks())
34 return; 36 return;
35 37
36 current_task_ = std::move(tasks_.front()); 38 current_task_ = std::move(tasks_.front());
37 tasks_.pop(); 39 tasks_.pop();
38 current_task_->Run(); 40 current_task_->Run();
39 } 41 }
40 42
41 void TaskQueue::TaskCompleted(Task* task) { 43 void TaskQueue::TaskCompleted(Task* task) {
42 DCHECK_EQ(task, current_task_.get()); 44 DCHECK_EQ(task, current_task_.get());
43 if (task == current_task_.get()) { 45 if (task == current_task_.get()) {
44 current_task_.reset(nullptr); 46 current_task_.reset(nullptr);
45 MaybeStartTask(); 47 MaybeStartTask();
46 } 48 }
47 } 49 }
48 50
49 } // namespace offline_pages 51 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698