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 "net/cert_net/cert_net_fetcher_impl.h" | 5 #include "net/cert_net/cert_net_fetcher_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
10 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
11 #include "net/cert/mock_cert_verifier.h" | 12 #include "net/cert/mock_cert_verifier.h" |
12 #include "net/dns/mock_host_resolver.h" | 13 #include "net/dns/mock_host_resolver.h" |
13 #include "net/http/http_server_properties_impl.h" | 14 #include "net/http/http_server_properties_impl.h" |
14 #include "net/test/embedded_test_server/embedded_test_server.h" | 15 #include "net/test/embedded_test_server/embedded_test_server.h" |
15 #include "net/url_request/url_request_job_factory_impl.h" | 16 #include "net/url_request/url_request_job_factory_impl.h" |
16 #include "net/url_request/url_request_test_util.h" | 17 #include "net/url_request/url_request_test_util.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 const CertNetFetcher::FetchCallback& callback() const { return callback_; } | 96 const CertNetFetcher::FetchCallback& callback() const { return callback_; } |
96 | 97 |
97 scoped_ptr<FetchResult> WaitForResult() { | 98 scoped_ptr<FetchResult> WaitForResult() { |
98 DCHECK(quit_closure_.is_null()); | 99 DCHECK(quit_closure_.is_null()); |
99 while (!HasResult()) { | 100 while (!HasResult()) { |
100 base::RunLoop run_loop; | 101 base::RunLoop run_loop; |
101 quit_closure_ = run_loop.QuitClosure(); | 102 quit_closure_ = run_loop.QuitClosure(); |
102 run_loop.Run(); | 103 run_loop.Run(); |
103 quit_closure_.Reset(); | 104 quit_closure_.Reset(); |
104 } | 105 } |
105 return result_.Pass(); | 106 return std::move(result_); |
106 } | 107 } |
107 | 108 |
108 bool HasResult() const { return result_.get(); } | 109 bool HasResult() const { return result_.get(); } |
109 | 110 |
110 // Sets an extra action (in addition to recording the result) that is run when | 111 // Sets an extra action (in addition to recording the result) that is run when |
111 // the FetchCallback is invoked. | 112 // the FetchCallback is invoked. |
112 void set_extra_closure(const base::Closure& closure) { | 113 void set_extra_closure(const base::Closure& closure) { |
113 extra_closure_ = closure; | 114 extra_closure_ = closure; |
114 } | 115 } |
115 | 116 |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 EXPECT_EQ(1, network_delegate_.created_requests()); | 749 EXPECT_EQ(1, network_delegate_.created_requests()); |
749 | 750 |
750 scoped_ptr<FetchResult> result = callback1.WaitForResult(); | 751 scoped_ptr<FetchResult> result = callback1.WaitForResult(); |
751 result->VerifySuccess("-cert.crt-\n"); | 752 result->VerifySuccess("-cert.crt-\n"); |
752 | 753 |
753 // request2 was cancelled. | 754 // request2 was cancelled. |
754 EXPECT_FALSE(callback2.HasResult()); | 755 EXPECT_FALSE(callback2.HasResult()); |
755 } | 756 } |
756 | 757 |
757 } // namespace net | 758 } // namespace net |
OLD | NEW |