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 CONTENT_PUBLIC_COMMON_URL_FETCHER_DELEGATE_H_ | 5 #ifndef NET_URL_REQUEST_URL_FETCHER_DELEGATE_H_ |
6 #define CONTENT_PUBLIC_COMMON_URL_FETCHER_DELEGATE_H_ | 6 #define NET_URL_REQUEST_URL_FETCHER_DELEGATE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "content/common/content_export.h" | 13 #include "net/base/net_export.h" |
14 | 14 |
15 namespace content { | 15 namespace net { |
16 | 16 |
17 class URLFetcher; | 17 class URLFetcher; |
18 | 18 |
19 // A delegate interface for users of URLFetcher. | 19 // A delegate interface for users of URLFetcher. |
20 class CONTENT_EXPORT URLFetcherDelegate { | 20 class NET_EXPORT URLFetcherDelegate { |
21 public: | 21 public: |
22 // This will be called when the URL has been fetched, successfully or not. | 22 // This will be called when the URL has been fetched, successfully or not. |
23 // Use accessor methods on |source| to get the results. | 23 // Use accessor methods on |source| to get the results. |
24 virtual void OnURLFetchComplete(const URLFetcher* source) = 0; | 24 virtual void OnURLFetchComplete(const URLFetcher* source) = 0; |
25 | 25 |
26 // This will be called when some part of the response is read. |current| | 26 // This will be called when some part of the response is read. |current| |
27 // denotes the number of bytes received up to the call, and |total| is the | 27 // denotes the number of bytes received up to the call, and |total| is the |
28 // expected total size of the response (or -1 if not determined). | 28 // expected total size of the response (or -1 if not determined). |
29 virtual void OnURLFetchDownloadProgress(const URLFetcher* source, | 29 virtual void OnURLFetchDownloadProgress(const URLFetcher* source, |
30 int64 current, int64 total) {} | 30 int64 current, int64 total); |
31 | 31 |
32 // This will be called when some part of the response is read. | 32 // This will be called when some part of the response is read. |
33 // |download_data| contains the current bytes received since the last call. | 33 // |download_data| contains the current bytes received since the last call. |
34 // This will be called after ShouldSendDownloadData() and only if the latter | 34 // This will be called after ShouldSendDownloadData() and only if the latter |
35 // returns true. | 35 // returns true. |
36 virtual void OnURLFetchDownloadData(const URLFetcher* source, | 36 virtual void OnURLFetchDownloadData(const URLFetcher* source, |
37 scoped_ptr<std::string> download_data) {} | 37 scoped_ptr<std::string> download_data); |
38 | 38 |
39 // This indicates if OnURLFetchDownloadData should be called. | 39 // This indicates if OnURLFetchDownloadData should be called. |
40 // This will be called before OnURLFetchDownloadData is called, and only if | 40 // This will be called before OnURLFetchDownloadData is called, and only if |
41 // this returns true. | 41 // this returns true. |
42 // Default implementation is false. | 42 // Default implementation is false. |
43 virtual bool ShouldSendDownloadData(); | 43 virtual bool ShouldSendDownloadData(); |
44 | 44 |
45 // This will be called when uploading of POST or PUT requests proceeded. | 45 // This will be called when uploading of POST or PUT requests proceeded. |
46 // |current| denotes the number of bytes sent so far, and |total| is the | 46 // |current| denotes the number of bytes sent so far, and |total| is the |
47 // total size of uploading data (or -1 if chunked upload is enabled). | 47 // total size of uploading data (or -1 if chunked upload is enabled). |
48 virtual void OnURLFetchUploadProgress(const URLFetcher* source, | 48 virtual void OnURLFetchUploadProgress(const URLFetcher* source, |
49 int64 current, int64 total) {} | 49 int64 current, int64 total); |
| 50 |
| 51 // TODO(akalin): Remove this hack once rlz is updated to use |
| 52 // net::URLFetcher{,Delegate}. |
| 53 #ifdef RLZ_LIB_FINANCIAL_PING_H_ |
| 54 struct content { |
| 55 typedef ::net::URLFetcher URLFetcher; |
| 56 }; |
| 57 #endif |
50 | 58 |
51 protected: | 59 protected: |
52 virtual ~URLFetcherDelegate() {} | 60 virtual ~URLFetcherDelegate(); |
53 }; | 61 }; |
54 | 62 |
55 } // namespace content | 63 } // namespace net |
56 | 64 |
57 #endif // CONTENT_PUBLIC_COMMON_URL_FETCHER_DELEGATE_H_ | 65 #endif // NET_URL_REQUEST_URL_FETCHER_DELEGATE_H_ |
OLD | NEW |