| 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> | 
| 11 | 11 | 
| 12 #include "base/macros.h" | 12 #include "base/macros.h" | 
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" | 
|  | 14 #include "headless/public/headless_export.h" | 
| 14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" | 
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" | 
| 16 | 17 | 
| 17 namespace net { | 18 namespace net { | 
| 18 class HttpRequestHeaders; | 19 class HttpRequestHeaders; | 
| 19 class HttpResponseHeaders; | 20 class HttpResponseHeaders; | 
| 20 }  // namespace net | 21 }  // namespace net | 
| 21 | 22 | 
| 22 namespace headless { | 23 namespace headless { | 
| 23 | 24 | 
| 24 // An interface for fetching URLs. Note these are only intended to be used once. | 25 // An interface for fetching URLs. Note these are only intended to be used once. | 
| 25 class URLFetcher { | 26 class HEADLESS_EXPORT URLFetcher { | 
| 26  public: | 27  public: | 
| 27   URLFetcher() {} | 28   URLFetcher() {} | 
| 28   virtual ~URLFetcher() {} | 29   virtual ~URLFetcher() {} | 
| 29 | 30 | 
| 30   // Interface for reporting the fetch result. | 31   // Interface for reporting the fetch result. | 
| 31   class ResultListener { | 32   class HEADLESS_EXPORT ResultListener { | 
| 32    public: | 33    public: | 
| 33     ResultListener() {} | 34     ResultListener() {} | 
| 34 | 35 | 
| 35     // Informs the listener that the fetch failed. | 36     // Informs the listener that the fetch failed. | 
| 36     virtual void OnFetchStartError(net::Error error) = 0; | 37     virtual void OnFetchStartError(net::Error error) = 0; | 
| 37 | 38 | 
| 38     // Informs the listener that the fetch succeeded and returns the HTTP | 39     // Informs the listener that the fetch succeeded and returns the HTTP | 
| 39     // 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 | 
| 40     // valid until the fetcher is destroyed, | 41     // valid until the fetcher is destroyed, | 
| 41     virtual void OnFetchComplete( | 42     virtual void OnFetchComplete( | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 71                           const net::HttpRequestHeaders& request_headers, | 72                           const net::HttpRequestHeaders& request_headers, | 
| 72                           ResultListener* result_listener); | 73                           ResultListener* result_listener); | 
| 73 | 74 | 
| 74  private: | 75  private: | 
| 75   DISALLOW_COPY_AND_ASSIGN(URLFetcher); | 76   DISALLOW_COPY_AND_ASSIGN(URLFetcher); | 
| 76 }; | 77 }; | 
| 77 | 78 | 
| 78 }  // namespace headless | 79 }  // namespace headless | 
| 79 | 80 | 
| 80 #endif  // HEADLESS_PUBLIC_UTIL_URL_FETCHER_H_ | 81 #endif  // HEADLESS_PUBLIC_UTIL_URL_FETCHER_H_ | 
| OLD | NEW | 
|---|