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 <utility> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
16 #include "base/sequenced_task_runner.h" | 17 #include "base/sequenced_task_runner.h" |
17 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 "\n"; | 148 "\n"; |
148 std::string headers(kGoodHeaders, arraysize(kGoodHeaders)); | 149 std::string headers(kGoodHeaders, arraysize(kGoodHeaders)); |
149 return new net::URLRequestTestJob( | 150 return new net::URLRequestTestJob( |
150 request, network_delegate, headers, data, true); | 151 request, network_delegate, headers, data, true); |
151 } | 152 } |
152 | 153 |
153 void RegisterHttpInterceptor( | 154 void RegisterHttpInterceptor( |
154 const std::string& hostname, | 155 const std::string& hostname, |
155 scoped_ptr<net::URLRequestInterceptor> interceptor) { | 156 scoped_ptr<net::URLRequestInterceptor> interceptor) { |
156 net::URLRequestFilter::GetInstance()->AddHostnameInterceptor( | 157 net::URLRequestFilter::GetInstance()->AddHostnameInterceptor( |
157 "http", hostname, interceptor.Pass()); | 158 "http", hostname, std::move(interceptor)); |
158 } | 159 } |
159 | 160 |
160 void UnregisterHttpInterceptor(const std::string& hostname) { | 161 void UnregisterHttpInterceptor(const std::string& hostname) { |
161 net::URLRequestFilter::GetInstance()->RemoveHostnameHandler("http", hostname); | 162 net::URLRequestFilter::GetInstance()->RemoveHostnameHandler("http", hostname); |
162 } | 163 } |
163 | 164 |
164 } // namespace | 165 } // namespace |
165 | 166 |
166 class TestRequestInterceptor::Delegate : public net::URLRequestInterceptor { | 167 class TestRequestInterceptor::Delegate : public net::URLRequestInterceptor { |
167 public: | 168 public: |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 FROM_HERE, | 335 FROM_HERE, |
335 base::Bind( | 336 base::Bind( |
336 base::IgnoreResult(&base::TaskRunner::PostTask), | 337 base::IgnoreResult(&base::TaskRunner::PostTask), |
337 base::ThreadTaskRunnerHandle::Get(), | 338 base::ThreadTaskRunnerHandle::Get(), |
338 FROM_HERE, | 339 FROM_HERE, |
339 run_loop.QuitClosure())); | 340 run_loop.QuitClosure())); |
340 run_loop.Run(); | 341 run_loop.Run(); |
341 } | 342 } |
342 | 343 |
343 } // namespace policy | 344 } // namespace policy |
OLD | NEW |