OLD | NEW |
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 #include "content/browser/cache_storage/cache_storage_scheduler.h" | 5 #include "content/browser/cache_storage/cache_storage_scheduler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
| 9 #include "base/bind.h" |
| 10 #include "base/location.h" |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop/message_loop_proxy.h" |
10 | 13 |
11 namespace content { | 14 namespace content { |
12 | 15 |
13 CacheStorageScheduler::CacheStorageScheduler() : operation_running_(false) { | 16 CacheStorageScheduler::CacheStorageScheduler() : operation_running_(false) { |
14 } | 17 } |
15 | 18 |
16 CacheStorageScheduler::~CacheStorageScheduler() { | 19 CacheStorageScheduler::~CacheStorageScheduler() { |
17 } | 20 } |
18 | 21 |
19 void CacheStorageScheduler::ScheduleOperation(const base::Closure& closure) { | 22 void CacheStorageScheduler::ScheduleOperation(const base::Closure& closure) { |
(...skipping 10 matching lines...) Expand all Loading... |
30 bool CacheStorageScheduler::ScheduledOperations() const { | 33 bool CacheStorageScheduler::ScheduledOperations() const { |
31 return operation_running_ || !pending_operations_.empty(); | 34 return operation_running_ || !pending_operations_.empty(); |
32 } | 35 } |
33 | 36 |
34 void CacheStorageScheduler::RunOperationIfIdle() { | 37 void CacheStorageScheduler::RunOperationIfIdle() { |
35 if (!operation_running_ && !pending_operations_.empty()) { | 38 if (!operation_running_ && !pending_operations_.empty()) { |
36 operation_running_ = true; | 39 operation_running_ = true; |
37 // TODO(jkarlin): Run multiple operations in parallel where allowed. | 40 // TODO(jkarlin): Run multiple operations in parallel where allowed. |
38 base::Closure closure = pending_operations_.front(); | 41 base::Closure closure = pending_operations_.front(); |
39 pending_operations_.pop_front(); | 42 pending_operations_.pop_front(); |
40 closure.Run(); | 43 base::MessageLoopProxy::current()->PostTask(FROM_HERE, base::Bind(closure)); |
41 } | 44 } |
42 } | 45 } |
43 | 46 |
44 } // namespace content | 47 } // namespace content |
OLD | NEW |