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 CONTENT_PUBLIC_COMMON_URL_FETCHER_DELEGATE_H_ |
6 #define CONTENT_PUBLIC_COMMON_URL_FETCHER_DELEGATE_H_ | 6 #define CONTENT_PUBLIC_COMMON_URL_FETCHER_DELEGATE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include "net/url_request/url_fetcher_delegate.h" |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "content/common/content_export.h" | |
14 | 10 |
15 namespace content { | 11 namespace content { |
16 | 12 |
| 13 // TODO(akalin): Update all users of URLFetcherDelegate to use |
| 14 // net::URLFetcherDelegate and remove this file. |
| 15 |
17 class URLFetcher; | 16 class URLFetcher; |
18 | 17 |
19 // A delegate interface for users of URLFetcher. | 18 // We inherit from net::URLFetcherDelegate so that we can still |
20 class CONTENT_EXPORT URLFetcherDelegate { | 19 // forward-declare URLFetcherDelegate (which we can't do with a |
21 public: | 20 // typedef). |
22 // This will be called when the URL has been fetched, successfully or not. | 21 class URLFetcherDelegate : public net::URLFetcherDelegate {}; |
23 // Use accessor methods on |source| to get the results. | |
24 virtual void OnURLFetchComplete(const URLFetcher* source) = 0; | |
25 | |
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 | |
28 // expected total size of the response (or -1 if not determined). | |
29 virtual void OnURLFetchDownloadProgress(const URLFetcher* source, | |
30 int64 current, int64 total) {} | |
31 | |
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. | |
34 // This will be called after ShouldSendDownloadData() and only if the latter | |
35 // returns true. | |
36 virtual void OnURLFetchDownloadData(const URLFetcher* source, | |
37 scoped_ptr<std::string> download_data) {} | |
38 | |
39 // This indicates if OnURLFetchDownloadData should be called. | |
40 // This will be called before OnURLFetchDownloadData is called, and only if | |
41 // this returns true. | |
42 // Default implementation is false. | |
43 virtual bool ShouldSendDownloadData(); | |
44 | |
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 | |
47 // total size of uploading data (or -1 if chunked upload is enabled). | |
48 virtual void OnURLFetchUploadProgress(const URLFetcher* source, | |
49 int64 current, int64 total) {} | |
50 | |
51 protected: | |
52 virtual ~URLFetcherDelegate() {} | |
53 }; | |
54 | 22 |
55 } // namespace content | 23 } // namespace content |
56 | 24 |
57 #endif // CONTENT_PUBLIC_COMMON_URL_FETCHER_DELEGATE_H_ | 25 #endif // CONTENT_PUBLIC_COMMON_URL_FETCHER_DELEGATE_H_ |
OLD | NEW |