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

Side by Side Diff: content/browser/cache_storage/cache_storage_scheduler.cc

Issue 2167483002: [CacheStorage] Simpler way to wrap callbacks to run pending operation completions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment clarification Created 4 years, 5 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 | « content/browser/cache_storage/cache_storage_scheduler.h ('k') | no next file » | 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 #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/location.h"
11 #include "base/logging.h" 10 #include "base/logging.h"
12 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
14 13
15 namespace content { 14 namespace content {
16 15
17 CacheStorageScheduler::CacheStorageScheduler() : operation_running_(false) { 16 CacheStorageScheduler::CacheStorageScheduler()
18 } 17 : operation_running_(false), weak_ptr_factory_(this) {}
19 18
20 CacheStorageScheduler::~CacheStorageScheduler() { 19 CacheStorageScheduler::~CacheStorageScheduler() {
21 } 20 }
22 21
23 void CacheStorageScheduler::ScheduleOperation(const base::Closure& closure) { 22 void CacheStorageScheduler::ScheduleOperation(const base::Closure& closure) {
24 pending_operations_.push_back(closure); 23 pending_operations_.push_back(closure);
25 RunOperationIfIdle(); 24 RunOperationIfIdle();
26 } 25 }
27 26
28 void CacheStorageScheduler::CompleteOperationAndRunNext() { 27 void CacheStorageScheduler::CompleteOperationAndRunNext() {
(...skipping 11 matching lines...) Expand all
40 operation_running_ = true; 39 operation_running_ = true;
41 // TODO(jkarlin): Run multiple operations in parallel where allowed. 40 // TODO(jkarlin): Run multiple operations in parallel where allowed.
42 base::Closure closure = pending_operations_.front(); 41 base::Closure closure = pending_operations_.front();
43 pending_operations_.pop_front(); 42 pending_operations_.pop_front();
44 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 43 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
45 base::Bind(closure)); 44 base::Bind(closure));
46 } 45 }
47 } 46 }
48 47
49 } // namespace content 48 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/cache_storage/cache_storage_scheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698