| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 HEADLESS_PUBLIC_UTIL_URL_FETCHER_H_ | 5 #ifndef HEADLESS_PUBLIC_UTIL_URL_FETCHER_H_ |
| 6 #define HEADLESS_PUBLIC_UTIL_URL_FETCHER_H_ | 6 #define HEADLESS_PUBLIC_UTIL_URL_FETCHER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 ResultListener() {} | 34 ResultListener() {} |
| 35 | 35 |
| 36 // Informs the listener that the fetch failed. | 36 // Informs the listener that the fetch failed. |
| 37 virtual void OnFetchStartError(net::Error error) = 0; | 37 virtual void OnFetchStartError(net::Error error) = 0; |
| 38 | 38 |
| 39 // Informs the listener that the fetch succeeded and returns the HTTP | 39 // Informs the listener that the fetch succeeded and returns the HTTP |
| 40 // headers and the body. NOTE |body| must be owned by the caller and remain | 40 // headers and the body. NOTE |body| must be owned by the caller and remain |
| 41 // valid until the fetcher is destroyed, | 41 // valid until the fetcher is destroyed, |
| 42 virtual void OnFetchComplete( | 42 virtual void OnFetchComplete( |
| 43 const GURL& final_url, | 43 const GURL& final_url, |
| 44 int http_response_code, | |
| 45 scoped_refptr<net::HttpResponseHeaders> response_headers, | 44 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 46 const char* body, | 45 const char* body, |
| 47 size_t body_size) = 0; | 46 size_t body_size) = 0; |
| 48 | 47 |
| 49 // Helper function which extracts the headers from |response_data| and calls | 48 // Helper function which extracts the headers from |response_data| and calls |
| 50 // OnFetchComplete. | 49 // OnFetchComplete. |
| 51 void OnFetchCompleteExtractHeaders(const GURL& final_url, | 50 void OnFetchCompleteExtractHeaders(const GURL& final_url, |
| 52 int http_response_code, | |
| 53 const char* response_data, | 51 const char* response_data, |
| 54 size_t response_data_size); | 52 size_t response_data_size); |
| 55 | 53 |
| 56 protected: | 54 protected: |
| 57 virtual ~ResultListener() {} | 55 virtual ~ResultListener() {} |
| 58 | 56 |
| 59 private: | 57 private: |
| 60 DISALLOW_COPY_AND_ASSIGN(ResultListener); | 58 DISALLOW_COPY_AND_ASSIGN(ResultListener); |
| 61 }; | 59 }; |
| 62 | 60 |
| 63 virtual void StartFetch(const GURL& url, | 61 virtual void StartFetch(const GURL& url, |
| 64 const std::string& method, | 62 const std::string& method, |
| 65 const std::string& post_data, | 63 const std::string& post_data, |
| 66 const net::HttpRequestHeaders& request_headers, | 64 const net::HttpRequestHeaders& request_headers, |
| 67 ResultListener* result_listener) = 0; | 65 ResultListener* result_listener) = 0; |
| 68 | 66 |
| 69 private: | 67 private: |
| 70 DISALLOW_COPY_AND_ASSIGN(URLFetcher); | 68 DISALLOW_COPY_AND_ASSIGN(URLFetcher); |
| 71 }; | 69 }; |
| 72 | 70 |
| 73 } // namespace headless | 71 } // namespace headless |
| 74 | 72 |
| 75 #endif // HEADLESS_PUBLIC_UTIL_URL_FETCHER_H_ | 73 #endif // HEADLESS_PUBLIC_UTIL_URL_FETCHER_H_ |
| OLD | NEW |