OLD | NEW |
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 "chrome/browser/policy/cloud/test_request_interceptor.h" | 5 #include "chrome/browser/policy/cloud/test_request_interceptor.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <memory> | 8 #include <memory> |
9 #include <queue> | 9 #include <queue> |
10 #include <utility> | 10 #include <utility> |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 return BadRequestJobCallback(request, network_delegate); | 225 return BadRequestJobCallback(request, network_delegate); |
226 } | 226 } |
227 | 227 |
228 // Invoke any callbacks that are waiting for the next request to be serviced | 228 // Invoke any callbacks that are waiting for the next request to be serviced |
229 // after this job is serviced. | 229 // after this job is serviced. |
230 if (!request_serviced_callbacks_.empty()) { | 230 if (!request_serviced_callbacks_.empty()) { |
231 std::unique_ptr<std::vector<base::Closure>> callbacks( | 231 std::unique_ptr<std::vector<base::Closure>> callbacks( |
232 new std::vector<base::Closure>); | 232 new std::vector<base::Closure>); |
233 callbacks->swap(request_serviced_callbacks_); | 233 callbacks->swap(request_serviced_callbacks_); |
234 io_task_runner_->PostTask( | 234 io_task_runner_->PostTask( |
235 FROM_HERE, base::Bind(&Delegate::InvokeRequestServicedCallbacks, | 235 FROM_HERE, base::BindOnce(&Delegate::InvokeRequestServicedCallbacks, |
236 base::Passed(&callbacks))); | 236 base::Passed(&callbacks))); |
237 } | 237 } |
238 | 238 |
239 JobCallback callback = pending_job_callbacks_.front(); | 239 JobCallback callback = pending_job_callbacks_.front(); |
240 pending_job_callbacks_.pop(); | 240 pending_job_callbacks_.pop(); |
241 return callback.Run(request, network_delegate); | 241 return callback.Run(request, network_delegate); |
242 } | 242 } |
243 | 243 |
244 void TestRequestInterceptor::Delegate::GetPendingSize( | 244 void TestRequestInterceptor::Delegate::GetPendingSize( |
245 size_t* pending_size) const { | 245 size_t* pending_size) const { |
246 CHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 246 CHECK(io_task_runner_->RunsTasksOnCurrentThread()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 // static | 337 // static |
338 TestRequestInterceptor::JobCallback TestRequestInterceptor::FileJob( | 338 TestRequestInterceptor::JobCallback TestRequestInterceptor::FileJob( |
339 const base::FilePath& file_path) { | 339 const base::FilePath& file_path) { |
340 return base::Bind(&FileJobCallback, file_path); | 340 return base::Bind(&FileJobCallback, file_path); |
341 } | 341 } |
342 | 342 |
343 void TestRequestInterceptor::PostToIOAndWait(const base::Closure& task) { | 343 void TestRequestInterceptor::PostToIOAndWait(const base::Closure& task) { |
344 io_task_runner_->PostTask(FROM_HERE, task); | 344 io_task_runner_->PostTask(FROM_HERE, task); |
345 base::RunLoop run_loop; | 345 base::RunLoop run_loop; |
346 io_task_runner_->PostTask( | 346 io_task_runner_->PostTask( |
347 FROM_HERE, | 347 FROM_HERE, base::BindOnce(base::IgnoreResult(&base::TaskRunner::PostTask), |
348 base::Bind( | 348 base::ThreadTaskRunnerHandle::Get(), FROM_HERE, |
349 base::IgnoreResult(&base::TaskRunner::PostTask), | 349 run_loop.QuitClosure())); |
350 base::ThreadTaskRunnerHandle::Get(), | |
351 FROM_HERE, | |
352 run_loop.QuitClosure())); | |
353 run_loop.Run(); | 350 run_loop.Run(); |
354 } | 351 } |
355 | 352 |
356 } // namespace policy | 353 } // namespace policy |
OLD | NEW |