OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "headless/public/util/testing/generic_url_request_mocks.h" | 5 #include "headless/public/util/testing/generic_url_request_mocks.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
9 | 11 |
10 namespace net { | 12 namespace net { |
11 class URLRequestJob; | 13 class URLRequestJob; |
12 } // namespace net | 14 } // namespace net |
13 | 15 |
14 namespace headless { | 16 namespace headless { |
15 | 17 |
16 // MockGenericURLRequestJobDelegate | 18 // MockGenericURLRequestJobDelegate |
17 MockGenericURLRequestJobDelegate::MockGenericURLRequestJobDelegate() | 19 MockGenericURLRequestJobDelegate::MockGenericURLRequestJobDelegate() |
18 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} | 20 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
19 | 21 |
20 MockGenericURLRequestJobDelegate::~MockGenericURLRequestJobDelegate() {} | 22 MockGenericURLRequestJobDelegate::~MockGenericURLRequestJobDelegate() {} |
21 | 23 |
22 // GenericURLRequestJob::Delegate methods: | 24 // GenericURLRequestJob::Delegate methods: |
23 void MockGenericURLRequestJobDelegate::OnPendingRequest( | 25 void MockGenericURLRequestJobDelegate::OnPendingRequest( |
24 PendingRequest* pending_request) { | 26 PendingRequest* pending_request) { |
25 // Simulate the client acknowledging the callback from a different thread. | 27 // Simulate the client acknowledging the callback from a different thread. |
26 main_thread_task_runner_->PostTask( | 28 main_thread_task_runner_->PostTask( |
27 FROM_HERE, base::Bind(&MockGenericURLRequestJobDelegate::ApplyPolicy, | 29 FROM_HERE, base::Bind(&MockGenericURLRequestJobDelegate::ApplyPolicy, |
28 base::Unretained(this), pending_request)); | 30 base::Unretained(this), pending_request)); |
29 } | 31 } |
30 | 32 |
31 void MockGenericURLRequestJobDelegate::SetPolicy(Policy policy) { | 33 void MockGenericURLRequestJobDelegate::SetPolicy(Policy policy) { |
32 policy_ = policy; | 34 policy_ = std::move(policy); |
33 } | 35 } |
34 | 36 |
35 void MockGenericURLRequestJobDelegate::ApplyPolicy( | 37 void MockGenericURLRequestJobDelegate::ApplyPolicy( |
36 PendingRequest* pending_request) { | 38 PendingRequest* pending_request) { |
37 if (policy_.is_null()) { | 39 if (policy_.is_null()) { |
38 pending_request->AllowRequest(); | 40 pending_request->AllowRequest(); |
39 } else { | 41 } else { |
40 policy_.Run(pending_request); | 42 policy_.Run(pending_request); |
41 } | 43 } |
42 } | 44 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 int bytes_read) {} | 177 int bytes_read) {} |
176 const std::string& MockURLRequestDelegate::response_data() const { | 178 const std::string& MockURLRequestDelegate::response_data() const { |
177 return response_data_; | 179 return response_data_; |
178 } | 180 } |
179 | 181 |
180 const net::IOBufferWithSize* MockURLRequestDelegate::metadata() const { | 182 const net::IOBufferWithSize* MockURLRequestDelegate::metadata() const { |
181 return nullptr; | 183 return nullptr; |
182 } | 184 } |
183 | 185 |
184 } // namespace headless | 186 } // namespace headless |
OLD | NEW |