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 #ifndef NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ | 5 #ifndef NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ |
6 #define NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ | 6 #define NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 URLRequestFailedJob(URLRequest* request, | 37 URLRequestFailedJob(URLRequest* request, |
38 NetworkDelegate* network_delegate, | 38 NetworkDelegate* network_delegate, |
39 int net_error); | 39 int net_error); |
40 | 40 |
41 // URLRequestJob implementation: | 41 // URLRequestJob implementation: |
42 void Start() override; | 42 void Start() override; |
43 int ReadRawData(IOBuffer* buf, int buf_size) override; | 43 int ReadRawData(IOBuffer* buf, int buf_size) override; |
44 int GetResponseCode() const override; | 44 int GetResponseCode() const override; |
45 void GetResponseInfo(HttpResponseInfo* info) override; | 45 void GetResponseInfo(HttpResponseInfo* info) override; |
46 void PopulateNetErrorDetails(NetErrorDetails* details) const override; | 46 void PopulateNetErrorDetails(NetErrorDetails* details) const override; |
47 int64_t GetTotalReceivedBytes() const override; | |
48 | 47 |
49 // Adds the testing URLs to the URLRequestFilter. | 48 // Adds the testing URLs to the URLRequestFilter. |
50 static void AddUrlHandler(); | 49 static void AddUrlHandler(); |
51 static void AddUrlHandlerForHostname(const std::string& hostname); | 50 static void AddUrlHandlerForHostname(const std::string& hostname); |
52 | 51 |
53 // Given a net error code, constructs a mock URL that will return that error | 52 // Given a net error code, constructs a mock URL that will return that error |
54 // asynchronously when started. |net_error| must be a valid net error code | 53 // asynchronously when started. |net_error| must be a valid net error code |
55 // other than net::OK. Passing net::ERR_IO_PENDING for |net_error| causes the | 54 // other than net::OK. Passing net::ERR_IO_PENDING for |net_error| causes the |
56 // resulting request to hang. | 55 // resulting request to hang. |
57 static GURL GetMockHttpUrl(int net_error); | 56 static GURL GetMockHttpUrl(int net_error); |
(...skipping 15 matching lines...) Expand all Loading... |
73 const std::string& hostname); | 72 const std::string& hostname); |
74 | 73 |
75 protected: | 74 protected: |
76 ~URLRequestFailedJob() override; | 75 ~URLRequestFailedJob() override; |
77 void StartAsync(); | 76 void StartAsync(); |
78 | 77 |
79 private: | 78 private: |
80 HttpResponseInfo response_info_; | 79 HttpResponseInfo response_info_; |
81 const FailurePhase phase_; | 80 const FailurePhase phase_; |
82 const int net_error_; | 81 const int net_error_; |
83 int64_t total_received_bytes_; | |
84 | 82 |
85 base::WeakPtrFactory<URLRequestFailedJob> weak_factory_; | 83 base::WeakPtrFactory<URLRequestFailedJob> weak_factory_; |
86 | 84 |
87 DISALLOW_COPY_AND_ASSIGN(URLRequestFailedJob); | 85 DISALLOW_COPY_AND_ASSIGN(URLRequestFailedJob); |
88 }; | 86 }; |
89 | 87 |
90 } // namespace net | 88 } // namespace net |
91 | 89 |
92 #endif // NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ | 90 #endif // NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ |
OLD | NEW |