| 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_PROXY_PROXY_SCRIPT_FETCHER_IMPL_H_ | 5 #ifndef NET_PROXY_PROXY_SCRIPT_FETCHER_IMPL_H_ |
| 6 #define NET_PROXY_PROXY_SCRIPT_FETCHER_IMPL_H_ | 6 #define NET_PROXY_PROXY_SCRIPT_FETCHER_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // to |url_request_context|. Be careful not to create cycles between the | 37 // to |url_request_context|. Be careful not to create cycles between the |
| 38 // fetcher and the context; you can break such cycles by calling Cancel(). | 38 // fetcher and the context; you can break such cycles by calling Cancel(). |
| 39 explicit ProxyScriptFetcherImpl(URLRequestContext* url_request_context); | 39 explicit ProxyScriptFetcherImpl(URLRequestContext* url_request_context); |
| 40 | 40 |
| 41 ~ProxyScriptFetcherImpl() override; | 41 ~ProxyScriptFetcherImpl() override; |
| 42 | 42 |
| 43 // Used by unit-tests to modify the default limits. | 43 // Used by unit-tests to modify the default limits. |
| 44 base::TimeDelta SetTimeoutConstraint(base::TimeDelta timeout); | 44 base::TimeDelta SetTimeoutConstraint(base::TimeDelta timeout); |
| 45 size_t SetSizeConstraint(size_t size_bytes); | 45 size_t SetSizeConstraint(size_t size_bytes); |
| 46 | 46 |
| 47 void OnResponseCompleted(URLRequest* request); | 47 void OnResponseCompleted(URLRequest* request, int net_error); |
| 48 | 48 |
| 49 // ProxyScriptFetcher methods: | 49 // ProxyScriptFetcher methods: |
| 50 int Fetch(const GURL& url, | 50 int Fetch(const GURL& url, |
| 51 base::string16* text, | 51 base::string16* text, |
| 52 const CompletionCallback& callback) override; | 52 const CompletionCallback& callback) override; |
| 53 void Cancel() override; | 53 void Cancel() override; |
| 54 URLRequestContext* GetRequestContext() const override; | 54 URLRequestContext* GetRequestContext() const override; |
| 55 | 55 |
| 56 // URLRequest::Delegate methods: | 56 // URLRequest::Delegate methods: |
| 57 void OnAuthRequired(URLRequest* request, | 57 void OnAuthRequired(URLRequest* request, |
| 58 AuthChallengeInfo* auth_info) override; | 58 AuthChallengeInfo* auth_info) override; |
| 59 void OnSSLCertificateError(URLRequest* request, | 59 void OnSSLCertificateError(URLRequest* request, |
| 60 const SSLInfo& ssl_info, | 60 const SSLInfo& ssl_info, |
| 61 bool is_hsts_ok) override; | 61 bool is_hsts_ok) override; |
| 62 void OnResponseStarted(URLRequest* request) override; | 62 void OnResponseStarted(URLRequest* request, int net_error) override; |
| 63 void OnReadCompleted(URLRequest* request, int num_bytes) override; | 63 void OnReadCompleted(URLRequest* request, int num_bytes) override; |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 enum { kBufSize = 4096 }; | 66 enum { kBufSize = 4096 }; |
| 67 | 67 |
| 68 // Read more bytes from the response. | 68 // Read more bytes from the response. |
| 69 void ReadBody(URLRequest* request); | 69 void ReadBody(URLRequest* request); |
| 70 | 70 |
| 71 // Handles a response from Read(). Returns true if we should continue trying | 71 // Handles a response from Read(). Returns true if we should continue trying |
| 72 // to read. |num_bytes| is 0 for EOF, and < 0 on errors. | 72 // to read. |num_bytes| is 0 for EOF, and < 0 on errors. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // Factory for creating the time-out task. This takes care of revoking | 127 // Factory for creating the time-out task. This takes care of revoking |
| 128 // outstanding tasks when |this| is deleted. | 128 // outstanding tasks when |this| is deleted. |
| 129 base::WeakPtrFactory<ProxyScriptFetcherImpl> weak_factory_; | 129 base::WeakPtrFactory<ProxyScriptFetcherImpl> weak_factory_; |
| 130 | 130 |
| 131 DISALLOW_COPY_AND_ASSIGN(ProxyScriptFetcherImpl); | 131 DISALLOW_COPY_AND_ASSIGN(ProxyScriptFetcherImpl); |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 } // namespace net | 134 } // namespace net |
| 135 | 135 |
| 136 #endif // NET_PROXY_PROXY_SCRIPT_FETCHER_IMPL_H_ | 136 #endif // NET_PROXY_PROXY_SCRIPT_FETCHER_IMPL_H_ |
| OLD | NEW |