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 <queue> | 8 #include <queue> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop/message_loop_proxy.h" | 14 #include "base/message_loop/message_loop_proxy.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/sequenced_task_runner.h" | 16 #include "base/sequenced_task_runner.h" |
17 #include "base/thread_task_runner_handle.h" | |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
19 #include "net/base/upload_bytes_element_reader.h" | 20 #include "net/base/upload_bytes_element_reader.h" |
20 #include "net/base/upload_data_stream.h" | 21 #include "net/base/upload_data_stream.h" |
21 #include "net/base/upload_element_reader.h" | 22 #include "net/base/upload_element_reader.h" |
22 #include "net/test/url_request/url_request_mock_http_job.h" | 23 #include "net/test/url_request/url_request_mock_http_job.h" |
23 #include "net/url_request/url_request_error_job.h" | 24 #include "net/url_request/url_request_error_job.h" |
24 #include "net/url_request/url_request_filter.h" | 25 #include "net/url_request/url_request_filter.h" |
25 #include "net/url_request/url_request_interceptor.h" | 26 #include "net/url_request/url_request_interceptor.h" |
26 #include "net/url_request/url_request_test_job.h" | 27 #include "net/url_request/url_request_test_job.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 size_t pending_size = std::numeric_limits<size_t>::max(); | 280 size_t pending_size = std::numeric_limits<size_t>::max(); |
280 PostToIOAndWait(base::Bind(&Delegate::GetPendingSize, | 281 PostToIOAndWait(base::Bind(&Delegate::GetPendingSize, |
281 base::Unretained(delegate_), | 282 base::Unretained(delegate_), |
282 &pending_size)); | 283 &pending_size)); |
283 return pending_size; | 284 return pending_size; |
284 } | 285 } |
285 | 286 |
286 void TestRequestInterceptor::AddRequestServicedCallback( | 287 void TestRequestInterceptor::AddRequestServicedCallback( |
287 const base::Closure& callback) { | 288 const base::Closure& callback) { |
288 base::Closure post_callback = | 289 base::Closure post_callback = |
289 base::Bind(base::IgnoreResult(&base::MessageLoopProxy::PostTask), | 290 base::Bind(base::IgnoreResult(&base::MessageLoopProxy::PostTask), |
pneubeck (no reviews)
2015/04/30 08:00:08
this reads very inconsistent.
Shouldn't this be ch
Pranay
2015/05/04 03:26:59
Done.
| |
290 base::MessageLoopProxy::current(), | 291 base::ThreadTaskRunnerHandle::Get(), |
291 FROM_HERE, | 292 FROM_HERE, |
292 callback); | 293 callback); |
293 PostToIOAndWait(base::Bind(&Delegate::AddRequestServicedCallback, | 294 PostToIOAndWait(base::Bind(&Delegate::AddRequestServicedCallback, |
294 base::Unretained(delegate_), | 295 base::Unretained(delegate_), |
295 post_callback)); | 296 post_callback)); |
296 } | 297 } |
297 | 298 |
298 void TestRequestInterceptor::PushJobCallback(const JobCallback& callback) { | 299 void TestRequestInterceptor::PushJobCallback(const JobCallback& callback) { |
299 PostToIOAndWait(base::Bind(&Delegate::PushJobCallback, | 300 PostToIOAndWait(base::Bind(&Delegate::PushJobCallback, |
300 base::Unretained(delegate_), | 301 base::Unretained(delegate_), |
(...skipping 23 matching lines...) Expand all Loading... | |
324 const base::FilePath& file_path) { | 325 const base::FilePath& file_path) { |
325 return base::Bind(&FileJobCallback, file_path); | 326 return base::Bind(&FileJobCallback, file_path); |
326 } | 327 } |
327 | 328 |
328 void TestRequestInterceptor::PostToIOAndWait(const base::Closure& task) { | 329 void TestRequestInterceptor::PostToIOAndWait(const base::Closure& task) { |
329 io_task_runner_->PostTask(FROM_HERE, task); | 330 io_task_runner_->PostTask(FROM_HERE, task); |
330 base::RunLoop run_loop; | 331 base::RunLoop run_loop; |
331 io_task_runner_->PostTask( | 332 io_task_runner_->PostTask( |
332 FROM_HERE, | 333 FROM_HERE, |
333 base::Bind( | 334 base::Bind( |
334 base::IgnoreResult(&base::MessageLoopProxy::PostTask), | 335 base::IgnoreResult(&base::MessageLoopProxy::PostTask), |
pneubeck (no reviews)
2015/04/30 08:00:08
ditto.
now you should be able to remove the inclu
Pranay
2015/05/04 03:26:59
Done.
| |
335 base::MessageLoopProxy::current(), | 336 base::ThreadTaskRunnerHandle::Get(), |
336 FROM_HERE, | 337 FROM_HERE, |
337 run_loop.QuitClosure())); | 338 run_loop.QuitClosure())); |
338 run_loop.Run(); | 339 run_loop.Run(); |
339 } | 340 } |
340 | 341 |
341 } // namespace policy | 342 } // namespace policy |
OLD | NEW |