OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/url_request/url_fetcher_impl.h" | 5 #include "net/url_request/url_fetcher_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "crypto/nss_util.h" | 35 #include "crypto/nss_util.h" |
36 #include "net/base/elements_upload_data_stream.h" | 36 #include "net/base/elements_upload_data_stream.h" |
37 #include "net/base/network_change_notifier.h" | 37 #include "net/base/network_change_notifier.h" |
38 #include "net/base/upload_bytes_element_reader.h" | 38 #include "net/base/upload_bytes_element_reader.h" |
39 #include "net/base/upload_element_reader.h" | 39 #include "net/base/upload_element_reader.h" |
40 #include "net/base/upload_file_element_reader.h" | 40 #include "net/base/upload_file_element_reader.h" |
41 #include "net/dns/mock_host_resolver.h" | 41 #include "net/dns/mock_host_resolver.h" |
42 #include "net/http/http_response_headers.h" | 42 #include "net/http/http_response_headers.h" |
43 #include "net/test/embedded_test_server/embedded_test_server.h" | 43 #include "net/test/embedded_test_server/embedded_test_server.h" |
44 #include "net/test/gtest_util.h" | 44 #include "net/test/gtest_util.h" |
| 45 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
45 #include "net/url_request/url_fetcher_delegate.h" | 46 #include "net/url_request/url_fetcher_delegate.h" |
46 #include "net/url_request/url_request_context_getter.h" | 47 #include "net/url_request/url_request_context_getter.h" |
47 #include "net/url_request/url_request_test_util.h" | 48 #include "net/url_request/url_request_test_util.h" |
48 #include "net/url_request/url_request_throttler_manager.h" | 49 #include "net/url_request/url_request_throttler_manager.h" |
49 #include "testing/gmock/include/gmock/gmock.h" | 50 #include "testing/gmock/include/gmock/gmock.h" |
50 #include "testing/gtest/include/gtest/gtest.h" | 51 #include "testing/gtest/include/gtest/gtest.h" |
51 | 52 |
52 #if defined(USE_NSS_CERTS) | 53 #if defined(USE_NSS_CERTS) |
53 #include "net/cert_net/nss_ocsp.h" | 54 #include "net/cert_net/nss_ocsp.h" |
54 #endif | 55 #endif |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // Simple URLRequestDelegate that waits for the specified fetcher to complete. | 89 // Simple URLRequestDelegate that waits for the specified fetcher to complete. |
89 // Can only be used once. | 90 // Can only be used once. |
90 class WaitingURLFetcherDelegate : public URLFetcherDelegate { | 91 class WaitingURLFetcherDelegate : public URLFetcherDelegate { |
91 public: | 92 public: |
92 WaitingURLFetcherDelegate() : did_complete_(false) {} | 93 WaitingURLFetcherDelegate() : did_complete_(false) {} |
93 | 94 |
94 void CreateFetcher( | 95 void CreateFetcher( |
95 const GURL& url, | 96 const GURL& url, |
96 URLFetcher::RequestType request_type, | 97 URLFetcher::RequestType request_type, |
97 scoped_refptr<net::URLRequestContextGetter> context_getter) { | 98 scoped_refptr<net::URLRequestContextGetter> context_getter) { |
98 fetcher_.reset(new URLFetcherImpl(url, request_type, this)); | 99 fetcher_.reset(new URLFetcherImpl(url, request_type, this, |
| 100 TRAFFIC_ANNOTATION_FOR_TESTS)); |
99 fetcher_->SetRequestContext(context_getter.get()); | 101 fetcher_->SetRequestContext(context_getter.get()); |
100 } | 102 } |
101 | 103 |
102 URLFetcher* fetcher() const { return fetcher_.get(); } | 104 URLFetcher* fetcher() const { return fetcher_.get(); } |
103 | 105 |
104 // Wait until the request has completed or been canceled. | 106 // Wait until the request has completed or been canceled. |
105 void StartFetcherAndWait() { | 107 void StartFetcherAndWait() { |
106 fetcher_->Start(); | 108 fetcher_->Start(); |
107 WaitForComplete(); | 109 WaitForComplete(); |
108 } | 110 } |
(...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 EXPECT_EQ(-1, delegate.fetcher()->GetResponseCode()); | 1570 EXPECT_EQ(-1, delegate.fetcher()->GetResponseCode()); |
1569 EXPECT_FALSE(delegate.fetcher()->GetResponseHeaders()); | 1571 EXPECT_FALSE(delegate.fetcher()->GetResponseHeaders()); |
1570 std::string data; | 1572 std::string data; |
1571 EXPECT_TRUE(delegate.fetcher()->GetResponseAsString(&data)); | 1573 EXPECT_TRUE(delegate.fetcher()->GetResponseAsString(&data)); |
1572 EXPECT_TRUE(data.empty()); | 1574 EXPECT_TRUE(data.empty()); |
1573 } | 1575 } |
1574 | 1576 |
1575 } // namespace | 1577 } // namespace |
1576 | 1578 |
1577 } // namespace net | 1579 } // namespace net |
OLD | NEW |