| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/public/test/test_download_request_handler.h" | 5 #include "content/public/test/test_download_request_handler.h" |
| 6 | 6 |
| 7 #include <inttypes.h> | 7 #include <inttypes.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 new Interceptor(url, client_task_runner)); | 491 new Interceptor(url, client_task_runner)); |
| 492 base::WeakPtr<Interceptor> weak_reference = | 492 base::WeakPtr<Interceptor> weak_reference = |
| 493 interceptor->weak_ptr_factory_.GetWeakPtr(); | 493 interceptor->weak_ptr_factory_.GetWeakPtr(); |
| 494 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); | 494 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); |
| 495 filter->AddUrlInterceptor(url, std::move(interceptor)); | 495 filter->AddUrlInterceptor(url, std::move(interceptor)); |
| 496 return weak_reference; | 496 return weak_reference; |
| 497 } | 497 } |
| 498 | 498 |
| 499 void TestDownloadRequestHandler::Interceptor::Unregister() { | 499 void TestDownloadRequestHandler::Interceptor::Unregister() { |
| 500 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); | 500 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); |
| 501 filter->RemoveUrlHandler(url_); | 501 GURL url = url_; // Make a copy as |this| will be deleted. |
| 502 filter->RemoveUrlHandler(url); |
| 502 // We are deleted now since the filter owned |this|. | 503 // We are deleted now since the filter owned |this|. |
| 503 } | 504 } |
| 504 | 505 |
| 505 void TestDownloadRequestHandler::Interceptor::SetJobFactory( | 506 void TestDownloadRequestHandler::Interceptor::SetJobFactory( |
| 506 const JobFactory& job_factory) { | 507 const JobFactory& job_factory) { |
| 507 job_factory_ = job_factory; | 508 job_factory_ = job_factory; |
| 508 } | 509 } |
| 509 | 510 |
| 510 void TestDownloadRequestHandler::Interceptor::GetAndResetCompletedRequests( | 511 void TestDownloadRequestHandler::Interceptor::GetAndResetCompletedRequests( |
| 511 TestDownloadRequestHandler::CompletedRequests* requests) { | 512 TestDownloadRequestHandler::CompletedRequests* requests) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 base::RunLoop run_loop; | 670 base::RunLoop run_loop; |
| 670 BrowserThread::PostTaskAndReply( | 671 BrowserThread::PostTaskAndReply( |
| 671 BrowserThread::IO, FROM_HERE, | 672 BrowserThread::IO, FROM_HERE, |
| 672 base::Bind(&Interceptor::GetAndResetCompletedRequests, interceptor_, | 673 base::Bind(&Interceptor::GetAndResetCompletedRequests, interceptor_, |
| 673 requests), | 674 requests), |
| 674 run_loop.QuitClosure()); | 675 run_loop.QuitClosure()); |
| 675 run_loop.Run(); | 676 run_loop.Run(); |
| 676 } | 677 } |
| 677 | 678 |
| 678 } // namespace content | 679 } // namespace content |
| OLD | NEW |