OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHILD_REQUEST_PEER_H_ | 5 #ifndef CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ |
6 #define CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ | 6 #define CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 | 12 |
13 class GURL; | 13 class GURL; |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class TimeTicks; | 16 class TimeTicks; |
17 } | 17 } |
18 | 18 |
19 namespace webkit_glue { | |
20 struct ResourceResponseInfo; | |
21 } | |
22 | |
23 namespace content { | 19 namespace content { |
24 | 20 |
| 21 struct ResourceResponseInfo; |
| 22 |
25 // This is implemented by our custom resource loader within content. The Peer | 23 // This is implemented by our custom resource loader within content. The Peer |
26 // and it's bridge should have identical lifetimes as they represent each end of | 24 // and it's bridge should have identical lifetimes as they represent each end of |
27 // a communication channel. | 25 // a communication channel. |
28 // | 26 // |
29 // These callbacks mirror net::URLRequest::Delegate and the order and | 27 // These callbacks mirror net::URLRequest::Delegate and the order and |
30 // conditions in which they will be called are identical. See url_request.h | 28 // conditions in which they will be called are identical. See url_request.h |
31 // for more information. | 29 // for more information. |
32 class CONTENT_EXPORT RequestPeer { | 30 class CONTENT_EXPORT RequestPeer { |
33 public: | 31 public: |
34 // Called as upload progress is made. | 32 // Called as upload progress is made. |
35 // note: only for requests with LOAD_ENABLE_UPLOAD_PROGRESS set | 33 // note: only for requests with LOAD_ENABLE_UPLOAD_PROGRESS set |
36 virtual void OnUploadProgress(uint64 position, uint64 size) = 0; | 34 virtual void OnUploadProgress(uint64 position, uint64 size) = 0; |
37 | 35 |
38 // Called when a redirect occurs. The implementation may return false to | 36 // Called when a redirect occurs. The implementation may return false to |
39 // suppress the redirect. The given ResponseInfo provides complete | 37 // suppress the redirect. The given ResponseInfo provides complete |
40 // information about the redirect, and new_url is the URL that will be loaded | 38 // information about the redirect, and new_url is the URL that will be loaded |
41 // if this method returns true. new_first_party_for_cookies is the new | 39 // if this method returns true. new_first_party_for_cookies is the new |
42 // first-party URL for cookies should that have changed. | 40 // first-party URL for cookies should that have changed. |
43 virtual bool OnReceivedRedirect( | 41 virtual bool OnReceivedRedirect(const GURL& new_url, |
44 const GURL& new_url, | 42 const GURL& new_first_party_for_cookies, |
45 const GURL& new_first_party_for_cookies, | 43 const ResourceResponseInfo& info) = 0; |
46 const webkit_glue::ResourceResponseInfo& info) = 0; | |
47 | 44 |
48 // Called when response headers are available (after all redirects have | 45 // Called when response headers are available (after all redirects have |
49 // been followed). | 46 // been followed). |
50 virtual void OnReceivedResponse( | 47 virtual void OnReceivedResponse(const ResourceResponseInfo& info) = 0; |
51 const webkit_glue::ResourceResponseInfo& info) = 0; | |
52 | 48 |
53 // Called when a chunk of response data is downloaded. This method may be | 49 // Called when a chunk of response data is downloaded. This method may be |
54 // called multiple times or not at all if an error occurs. This method is | 50 // called multiple times or not at all if an error occurs. This method is |
55 // only called if RequestInfo::download_to_file was set to true, and in | 51 // only called if RequestInfo::download_to_file was set to true, and in |
56 // that case, OnReceivedData will not be called. | 52 // that case, OnReceivedData will not be called. |
57 // The encoded_data_length is the length of the encoded data transferred | 53 // The encoded_data_length is the length of the encoded data transferred |
58 // over the network, which could be different from data length (e.g. for | 54 // over the network, which could be different from data length (e.g. for |
59 // gzipped content). | 55 // gzipped content). |
60 virtual void OnDownloadedData(int len, int encoded_data_length) = 0; | 56 virtual void OnDownloadedData(int len, int encoded_data_length) = 0; |
61 | 57 |
(...skipping 19 matching lines...) Expand all Loading... |
81 const base::TimeTicks& completion_time, | 77 const base::TimeTicks& completion_time, |
82 int64 total_transfer_size) = 0; | 78 int64 total_transfer_size) = 0; |
83 | 79 |
84 protected: | 80 protected: |
85 virtual ~RequestPeer() {} | 81 virtual ~RequestPeer() {} |
86 }; | 82 }; |
87 | 83 |
88 } // namespace content | 84 } // namespace content |
89 | 85 |
90 #endif // CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ | 86 #endif // CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ |
OLD | NEW |