OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ |
| 6 #define CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "content/common/content_export.h" |
| 12 |
| 13 class GURL; |
| 14 |
| 15 namespace base { |
| 16 class TimeTicks; |
| 17 } |
| 18 |
| 19 namespace webkit_glue { |
| 20 struct ResourceResponseInfo; |
| 21 } |
| 22 |
| 23 namespace content { |
| 24 |
| 25 // 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 |
| 27 // a communication channel. |
| 28 // |
| 29 // These callbacks mirror net::URLRequest::Delegate and the order and |
| 30 // conditions in which they will be called are identical. See url_request.h |
| 31 // for more information. |
| 32 class CONTENT_EXPORT RequestPeer { |
| 33 public: |
| 34 // Called as upload progress is made. |
| 35 // note: only for requests with LOAD_ENABLE_UPLOAD_PROGRESS set |
| 36 virtual void OnUploadProgress(uint64 position, uint64 size) = 0; |
| 37 |
| 38 // Called when a redirect occurs. The implementation may return false to |
| 39 // suppress the redirect. The given ResponseInfo provides complete |
| 40 // information about the redirect, and new_url is the URL that will be |
| 41 // loaded if this method returns true. If this method returns true, the |
| 42 // output parameter *has_new_first_party_for_cookies indicates whether the |
| 43 // output parameter *new_first_party_for_cookies contains the new URL that |
| 44 // should be consulted for the third-party cookie blocking policy. |
| 45 virtual bool OnReceivedRedirect(const GURL& new_url, |
| 46 const webkit_glue::ResourceResponseInfo& info, |
| 47 bool* has_new_first_party_for_cookies, |
| 48 GURL* new_first_party_for_cookies) = 0; |
| 49 |
| 50 // Called when response headers are available (after all redirects have |
| 51 // been followed). |
| 52 virtual void OnReceivedResponse( |
| 53 const webkit_glue::ResourceResponseInfo& info) = 0; |
| 54 |
| 55 // Called when a chunk of response data is downloaded. This method may be |
| 56 // called multiple times or not at all if an error occurs. This method is |
| 57 // only called if RequestInfo::download_to_file was set to true, and in |
| 58 // that case, OnReceivedData will not be called. |
| 59 // The encoded_data_length is the length of the encoded data transferred |
| 60 // over the network, which could be different from data length (e.g. for |
| 61 // gzipped content). |
| 62 virtual void OnDownloadedData(int len, int encoded_data_length) = 0; |
| 63 |
| 64 // Called when a chunk of response data is available. This method may |
| 65 // be called multiple times or not at all if an error occurs. |
| 66 // The encoded_data_length is the length of the encoded data transferred |
| 67 // over the network, which could be different from data length (e.g. for |
| 68 // gzipped content). |
| 69 virtual void OnReceivedData(const char* data, |
| 70 int data_length, |
| 71 int encoded_data_length) = 0; |
| 72 |
| 73 // Called when metadata generated by the renderer is retrieved from the |
| 74 // cache. This method may be called zero or one times. |
| 75 virtual void OnReceivedCachedMetadata(const char* data, int len) {} |
| 76 |
| 77 // Called when the response is complete. This method signals completion of |
| 78 // the resource load. |
| 79 virtual void OnCompletedRequest(int error_code, |
| 80 bool was_ignored_by_handler, |
| 81 bool stale_copy_in_cache, |
| 82 const std::string& security_info, |
| 83 const base::TimeTicks& completion_time, |
| 84 int64 total_transfer_size) = 0; |
| 85 |
| 86 protected: |
| 87 virtual ~RequestPeer() {} |
| 88 }; |
| 89 |
| 90 } // namespace content |
| 91 |
| 92 #endif // CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ |
OLD | NEW |