| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 public URLRequest::Delegate { | 29 public URLRequest::Delegate { |
| 30 public: | 30 public: |
| 31 // Creates a ProxyScriptFetcher that issues requests through | 31 // Creates a ProxyScriptFetcher that issues requests through |
| 32 // |url_request_context|. |url_request_context| must remain valid for the | 32 // |url_request_context|. |url_request_context| must remain valid for the |
| 33 // lifetime of ProxyScriptFetcherImpl. | 33 // lifetime of ProxyScriptFetcherImpl. |
| 34 // Note that while a request is in progress, we will be holding a reference | 34 // Note that while a request is in progress, we will be holding a reference |
| 35 // to |url_request_context|. Be careful not to create cycles between the | 35 // to |url_request_context|. Be careful not to create cycles between the |
| 36 // fetcher and the context; you can break such cycles by calling Cancel(). | 36 // fetcher and the context; you can break such cycles by calling Cancel(). |
| 37 explicit ProxyScriptFetcherImpl(URLRequestContext* url_request_context); | 37 explicit ProxyScriptFetcherImpl(URLRequestContext* url_request_context); |
| 38 | 38 |
| 39 virtual ~ProxyScriptFetcherImpl(); | 39 ~ProxyScriptFetcherImpl() override; |
| 40 | 40 |
| 41 // Used by unit-tests to modify the default limits. | 41 // Used by unit-tests to modify the default limits. |
| 42 base::TimeDelta SetTimeoutConstraint(base::TimeDelta timeout); | 42 base::TimeDelta SetTimeoutConstraint(base::TimeDelta timeout); |
| 43 size_t SetSizeConstraint(size_t size_bytes); | 43 size_t SetSizeConstraint(size_t size_bytes); |
| 44 | 44 |
| 45 void OnResponseCompleted(URLRequest* request); | 45 void OnResponseCompleted(URLRequest* request); |
| 46 | 46 |
| 47 // ProxyScriptFetcher methods: | 47 // ProxyScriptFetcher methods: |
| 48 virtual int Fetch(const GURL& url, base::string16* text, | 48 int Fetch(const GURL& url, |
| 49 const net::CompletionCallback& callback) override; | 49 base::string16* text, |
| 50 virtual void Cancel() override; | 50 const net::CompletionCallback& callback) override; |
| 51 virtual URLRequestContext* GetRequestContext() const override; | 51 void Cancel() override; |
| 52 URLRequestContext* GetRequestContext() const override; |
| 52 | 53 |
| 53 // URLRequest::Delegate methods: | 54 // URLRequest::Delegate methods: |
| 54 virtual void OnAuthRequired(URLRequest* request, | 55 void OnAuthRequired(URLRequest* request, |
| 55 AuthChallengeInfo* auth_info) override; | 56 AuthChallengeInfo* auth_info) override; |
| 56 virtual void OnSSLCertificateError(URLRequest* request, | 57 void OnSSLCertificateError(URLRequest* request, |
| 57 const SSLInfo& ssl_info, | 58 const SSLInfo& ssl_info, |
| 58 bool is_hsts_ok) override; | 59 bool is_hsts_ok) override; |
| 59 virtual void OnResponseStarted(URLRequest* request) override; | 60 void OnResponseStarted(URLRequest* request) override; |
| 60 virtual void OnReadCompleted(URLRequest* request, int num_bytes) override; | 61 void OnReadCompleted(URLRequest* request, int num_bytes) override; |
| 61 | 62 |
| 62 private: | 63 private: |
| 63 enum { kBufSize = 4096 }; | 64 enum { kBufSize = 4096 }; |
| 64 | 65 |
| 65 // Read more bytes from the response. | 66 // Read more bytes from the response. |
| 66 void ReadBody(URLRequest* request); | 67 void ReadBody(URLRequest* request); |
| 67 | 68 |
| 68 // Handles a response from Read(). Returns true if we should continue trying | 69 // Handles a response from Read(). Returns true if we should continue trying |
| 69 // to read. |num_bytes| is 0 for EOF, and < 0 on errors. | 70 // to read. |num_bytes| is 0 for EOF, and < 0 on errors. |
| 70 bool ConsumeBytesRead(URLRequest* request, int num_bytes); | 71 bool ConsumeBytesRead(URLRequest* request, int num_bytes); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // Factory for creating the time-out task. This takes care of revoking | 119 // Factory for creating the time-out task. This takes care of revoking |
| 119 // outstanding tasks when |this| is deleted. | 120 // outstanding tasks when |this| is deleted. |
| 120 base::WeakPtrFactory<ProxyScriptFetcherImpl> weak_factory_; | 121 base::WeakPtrFactory<ProxyScriptFetcherImpl> weak_factory_; |
| 121 | 122 |
| 122 DISALLOW_COPY_AND_ASSIGN(ProxyScriptFetcherImpl); | 123 DISALLOW_COPY_AND_ASSIGN(ProxyScriptFetcherImpl); |
| 123 }; | 124 }; |
| 124 | 125 |
| 125 } // namespace net | 126 } // namespace net |
| 126 | 127 |
| 127 #endif // NET_PROXY_PROXY_SCRIPT_FETCHER_IMPL_H_ | 128 #endif // NET_PROXY_PROXY_SCRIPT_FETCHER_IMPL_H_ |
| OLD | NEW |