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

Side by Side Diff: storage/browser/fileapi/recursive_operation_delegate.cc

Issue 1115663002: [storage/browser/fileapi] Replace MessageLoopProxy usage with ThreadTaskRunnerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « storage/browser/fileapi/plugin_private_file_system_backend.cc ('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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "storage/browser/fileapi/recursive_operation_delegate.h" 5 #include "storage/browser/fileapi/recursive_operation_delegate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/single_thread_task_runner.h"
9 #include "base/thread_task_runner_handle.h"
8 #include "storage/browser/fileapi/file_system_context.h" 10 #include "storage/browser/fileapi/file_system_context.h"
9 #include "storage/browser/fileapi/file_system_operation_runner.h" 11 #include "storage/browser/fileapi/file_system_operation_runner.h"
10 12
11 namespace storage { 13 namespace storage {
12 14
13 namespace { 15 namespace {
14 // Don't start too many inflight operations. 16 // Don't start too many inflight operations.
15 const int kMaxInflightOperations = 5; 17 const int kMaxInflightOperations = 5;
16 } 18 }
17 19
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 if ((pending_files_.empty() || canceled_) && inflight_operations_ == 0) { 145 if ((pending_files_.empty() || canceled_) && inflight_operations_ == 0) {
144 ProcessSubDirectory(); 146 ProcessSubDirectory();
145 return; 147 return;
146 } 148 }
147 149
148 // Do not post any new tasks. 150 // Do not post any new tasks.
149 if (canceled_) 151 if (canceled_)
150 return; 152 return;
151 153
152 // Run ProcessFile in parallel (upto kMaxInflightOperations). 154 // Run ProcessFile in parallel (upto kMaxInflightOperations).
153 scoped_refptr<base::MessageLoopProxy> current_message_loop = 155 scoped_refptr<base::SingleThreadTaskRunner> current_task_runner =
154 base::MessageLoopProxy::current(); 156 base::ThreadTaskRunnerHandle::Get();
155 while (!pending_files_.empty() && 157 while (!pending_files_.empty() &&
156 inflight_operations_ < kMaxInflightOperations) { 158 inflight_operations_ < kMaxInflightOperations) {
157 ++inflight_operations_; 159 ++inflight_operations_;
158 current_message_loop->PostTask( 160 current_task_runner->PostTask(
159 FROM_HERE, 161 FROM_HERE,
160 base::Bind(&RecursiveOperationDelegate::ProcessFile, 162 base::Bind(&RecursiveOperationDelegate::ProcessFile,
161 AsWeakPtr(), pending_files_.front(), 163 AsWeakPtr(), pending_files_.front(),
162 base::Bind(&RecursiveOperationDelegate::DidProcessFile, 164 base::Bind(&RecursiveOperationDelegate::DidProcessFile,
163 AsWeakPtr()))); 165 AsWeakPtr())));
164 pending_files_.pop(); 166 pending_files_.pop();
165 } 167 }
166 } 168 }
167 169
168 void RecursiveOperationDelegate::DidProcessFile( 170 void RecursiveOperationDelegate::DidProcessFile(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 232
231 void RecursiveOperationDelegate::Done(base::File::Error error) { 233 void RecursiveOperationDelegate::Done(base::File::Error error) {
232 if (canceled_ && error == base::File::FILE_OK) { 234 if (canceled_ && error == base::File::FILE_OK) {
233 callback_.Run(base::File::FILE_ERROR_ABORT); 235 callback_.Run(base::File::FILE_ERROR_ABORT);
234 } else { 236 } else {
235 callback_.Run(error); 237 callback_.Run(error);
236 } 238 }
237 } 239 }
238 240
239 } // namespace storage 241 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/fileapi/plugin_private_file_system_backend.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698