| 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 // This file contains URLFetcher, a wrapper around URLRequest that handles | 5 // This file contains URLFetcher, a wrapper around URLRequest that handles |
| 6 // low-level details like thread safety, ref counting, and incremental buffer | 6 // low-level details like thread safety, ref counting, and incremental buffer |
| 7 // reading. This is useful for callers who simply want to get the data from a | 7 // reading. This is useful for callers who simply want to get the data from a |
| 8 // URL and don't care about all the nitty-gritty details. | 8 // URL and don't care about all the nitty-gritty details. |
| 9 // | 9 // |
| 10 // NOTE(willchan): Only one "IO" thread is supported for URLFetcher. This is a | 10 // NOTE(willchan): Only one "IO" thread is supported for URLFetcher. This is a |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 class URLFetcherFactory; | 27 class URLFetcherFactory; |
| 28 | 28 |
| 29 class NET_EXPORT_PRIVATE URLFetcherImpl : public URLFetcher { | 29 class NET_EXPORT_PRIVATE URLFetcherImpl : public URLFetcher { |
| 30 public: | 30 public: |
| 31 // |url| is the URL to send the request to. | 31 // |url| is the URL to send the request to. |
| 32 // |request_type| is the type of request to make. | 32 // |request_type| is the type of request to make. |
| 33 // |d| the object that will receive the callback on fetch completion. | 33 // |d| the object that will receive the callback on fetch completion. |
| 34 URLFetcherImpl(const GURL& url, | 34 URLFetcherImpl(const GURL& url, |
| 35 RequestType request_type, | 35 RequestType request_type, |
| 36 URLFetcherDelegate* d); | 36 URLFetcherDelegate* d); |
| 37 virtual ~URLFetcherImpl(); | 37 ~URLFetcherImpl() override; |
| 38 | 38 |
| 39 // URLFetcher implementation: | 39 // URLFetcher implementation: |
| 40 virtual void SetUploadData(const std::string& upload_content_type, | 40 void SetUploadData(const std::string& upload_content_type, |
| 41 const std::string& upload_content) override; | 41 const std::string& upload_content) override; |
| 42 virtual void SetUploadFilePath( | 42 void SetUploadFilePath( |
| 43 const std::string& upload_content_type, | 43 const std::string& upload_content_type, |
| 44 const base::FilePath& file_path, | 44 const base::FilePath& file_path, |
| 45 uint64 range_offset, | 45 uint64 range_offset, |
| 46 uint64 range_length, | 46 uint64 range_length, |
| 47 scoped_refptr<base::TaskRunner> file_task_runner) override; | 47 scoped_refptr<base::TaskRunner> file_task_runner) override; |
| 48 virtual void SetChunkedUpload( | 48 void SetChunkedUpload(const std::string& upload_content_type) override; |
| 49 const std::string& upload_content_type) override; | 49 void AppendChunkToUpload(const std::string& data, |
| 50 virtual void AppendChunkToUpload(const std::string& data, | 50 bool is_last_chunk) override; |
| 51 bool is_last_chunk) override; | 51 void SetLoadFlags(int load_flags) override; |
| 52 virtual void SetLoadFlags(int load_flags) override; | 52 int GetLoadFlags() const override; |
| 53 virtual int GetLoadFlags() const override; | 53 void SetReferrer(const std::string& referrer) override; |
| 54 virtual void SetReferrer(const std::string& referrer) override; | 54 void SetReferrerPolicy(URLRequest::ReferrerPolicy referrer_policy) override; |
| 55 virtual void SetReferrerPolicy( | 55 void SetExtraRequestHeaders( |
| 56 URLRequest::ReferrerPolicy referrer_policy) override; | |
| 57 virtual void SetExtraRequestHeaders( | |
| 58 const std::string& extra_request_headers) override; | 56 const std::string& extra_request_headers) override; |
| 59 virtual void AddExtraRequestHeader(const std::string& header_line) override; | 57 void AddExtraRequestHeader(const std::string& header_line) override; |
| 60 virtual void SetRequestContext( | 58 void SetRequestContext( |
| 61 URLRequestContextGetter* request_context_getter) override; | 59 URLRequestContextGetter* request_context_getter) override; |
| 62 virtual void SetFirstPartyForCookies( | 60 void SetFirstPartyForCookies(const GURL& first_party_for_cookies) override; |
| 63 const GURL& first_party_for_cookies) override; | 61 void SetURLRequestUserData( |
| 64 virtual void SetURLRequestUserData( | |
| 65 const void* key, | 62 const void* key, |
| 66 const CreateDataCallback& create_data_callback) override; | 63 const CreateDataCallback& create_data_callback) override; |
| 67 virtual void SetStopOnRedirect(bool stop_on_redirect) override; | 64 void SetStopOnRedirect(bool stop_on_redirect) override; |
| 68 virtual void SetAutomaticallyRetryOn5xx(bool retry) override; | 65 void SetAutomaticallyRetryOn5xx(bool retry) override; |
| 69 virtual void SetMaxRetriesOn5xx(int max_retries) override; | 66 void SetMaxRetriesOn5xx(int max_retries) override; |
| 70 virtual int GetMaxRetriesOn5xx() const override; | 67 int GetMaxRetriesOn5xx() const override; |
| 71 virtual base::TimeDelta GetBackoffDelay() const override; | 68 base::TimeDelta GetBackoffDelay() const override; |
| 72 virtual void SetAutomaticallyRetryOnNetworkChanges(int max_retries) override; | 69 void SetAutomaticallyRetryOnNetworkChanges(int max_retries) override; |
| 73 virtual void SaveResponseToFileAtPath( | 70 void SaveResponseToFileAtPath( |
| 74 const base::FilePath& file_path, | 71 const base::FilePath& file_path, |
| 75 scoped_refptr<base::SequencedTaskRunner> file_task_runner) override; | 72 scoped_refptr<base::SequencedTaskRunner> file_task_runner) override; |
| 76 virtual void SaveResponseToTemporaryFile( | 73 void SaveResponseToTemporaryFile( |
| 77 scoped_refptr<base::SequencedTaskRunner> file_task_runner) override; | 74 scoped_refptr<base::SequencedTaskRunner> file_task_runner) override; |
| 78 virtual void SaveResponseWithWriter( | 75 void SaveResponseWithWriter( |
| 79 scoped_ptr<URLFetcherResponseWriter> response_writer) override; | 76 scoped_ptr<URLFetcherResponseWriter> response_writer) override; |
| 80 virtual HttpResponseHeaders* GetResponseHeaders() const override; | 77 HttpResponseHeaders* GetResponseHeaders() const override; |
| 81 virtual HostPortPair GetSocketAddress() const override; | 78 HostPortPair GetSocketAddress() const override; |
| 82 virtual bool WasFetchedViaProxy() const override; | 79 bool WasFetchedViaProxy() const override; |
| 83 virtual void Start() override; | 80 void Start() override; |
| 84 virtual const GURL& GetOriginalURL() const override; | 81 const GURL& GetOriginalURL() const override; |
| 85 virtual const GURL& GetURL() const override; | 82 const GURL& GetURL() const override; |
| 86 virtual const URLRequestStatus& GetStatus() const override; | 83 const URLRequestStatus& GetStatus() const override; |
| 87 virtual int GetResponseCode() const override; | 84 int GetResponseCode() const override; |
| 88 virtual const ResponseCookies& GetCookies() const override; | 85 const ResponseCookies& GetCookies() const override; |
| 89 virtual void ReceivedContentWasMalformed() override; | 86 void ReceivedContentWasMalformed() override; |
| 90 virtual bool GetResponseAsString( | 87 bool GetResponseAsString(std::string* out_response_string) const override; |
| 91 std::string* out_response_string) const override; | 88 bool GetResponseAsFilePath(bool take_ownership, |
| 92 virtual bool GetResponseAsFilePath( | 89 base::FilePath* out_response_path) const override; |
| 93 bool take_ownership, | |
| 94 base::FilePath* out_response_path) const override; | |
| 95 | 90 |
| 96 static void CancelAll(); | 91 static void CancelAll(); |
| 97 | 92 |
| 98 static void SetEnableInterceptionForTests(bool enabled); | 93 static void SetEnableInterceptionForTests(bool enabled); |
| 99 static void SetIgnoreCertificateRequests(bool ignored); | 94 static void SetIgnoreCertificateRequests(bool ignored); |
| 100 | 95 |
| 101 // TODO(akalin): Make these private again once URLFetcher::Create() | 96 // TODO(akalin): Make these private again once URLFetcher::Create() |
| 102 // is in net/. | 97 // is in net/. |
| 103 | 98 |
| 104 static URLFetcherFactory* factory(); | 99 static URLFetcherFactory* factory(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 122 static int GetNumFetcherCores(); | 117 static int GetNumFetcherCores(); |
| 123 | 118 |
| 124 const scoped_refptr<URLFetcherCore> core_; | 119 const scoped_refptr<URLFetcherCore> core_; |
| 125 | 120 |
| 126 DISALLOW_COPY_AND_ASSIGN(URLFetcherImpl); | 121 DISALLOW_COPY_AND_ASSIGN(URLFetcherImpl); |
| 127 }; | 122 }; |
| 128 | 123 |
| 129 } // namespace net | 124 } // namespace net |
| 130 | 125 |
| 131 #endif // NET_URL_REQUEST_URL_FETCHER_IMPL_H_ | 126 #endif // NET_URL_REQUEST_URL_FETCHER_IMPL_H_ |
| OLD | NEW |