Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: content/public/child/request_peer.h

Issue 1103813002: Make WebURLLoader capable of retaining received buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <vector>
9 10
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
11 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
12 14
13 class GURL; 15 class GURL;
14 16
15 namespace base { 17 namespace base {
16 class TimeTicks; 18 class TimeTicks;
17 } 19 }
18 20
19 namespace net { 21 namespace net {
20 struct RedirectInfo; 22 struct RedirectInfo;
21 } 23 }
22 24
23 namespace content { 25 namespace content {
24 26
25 struct ResourceResponseInfo; 27 struct ResourceResponseInfo;
26 28
27 // This is implemented by our custom resource loader within content. The Peer 29 // This is implemented by our custom resource loader within content. The Peer
28 // and it's bridge should have identical lifetimes as they represent each end of 30 // and it's bridge should have identical lifetimes as they represent each end of
29 // a communication channel. 31 // a communication channel.
30 // 32 //
31 // These callbacks mirror net::URLRequest::Delegate and the order and 33 // These callbacks mirror net::URLRequest::Delegate and the order and
32 // conditions in which they will be called are identical. See url_request.h 34 // conditions in which they will be called are identical. See url_request.h
33 // for more information. 35 // for more information.
34 class CONTENT_EXPORT RequestPeer { 36 class CONTENT_EXPORT RequestPeer {
35 public: 37 public:
38 // This class represents data gotten from the Browser process. Each data
39 // consists of |payload|, |length| and |encoded_length|. The payload is
40 // valid only when the data instance is valid.
41 // In order to work with Chrome resource loading IPC, it is desirable to
42 // reclaim data in FIFO order in a RequestPeer in terms of performance.
43 // |payload|, |length| and |encoded_length| functions are thread-safe, but
44 // the data object itself must be destroyed on the original thread.
45 class CONTENT_EXPORT ReceivedData {
46 public:
47 virtual ~ReceivedData() {}
48 virtual const char* payload() const = 0;
49 virtual int length() const = 0;
50 // The encoded_length is the length of the encoded data transferred
51 // over the network, which could be different from data length (e.g. for
52 // gzipped content).
53 virtual int encoded_length() const = 0;
54 };
55
56 class CONTENT_EXPORT FixedReceivedData final : public ReceivedData {
jochen (gone - plz use gerrit) 2015/06/01 13:08:28 hum, that looks a bit odd, maybe content/public/ch
yhirano 2015/06/02 02:08:47 Done.
57 public:
58 FixedReceivedData(const char* data, size_t length, int encoded_length);
59 FixedReceivedData(scoped_ptr<ReceivedData> data);
60 FixedReceivedData(const std::vector<char>& data, int encoded_length);
61 ~FixedReceivedData() override;
62
63 const char* payload() const override;
64 int length() const override;
65 int encoded_length() const override;
66
67 private:
68 std::vector<char> data_;
69 int encoded_length_;
70
71 DISALLOW_COPY_AND_ASSIGN(FixedReceivedData);
72 };
73
36 // Called as upload progress is made. 74 // Called as upload progress is made.
37 // note: only for requests with upload progress enabled. 75 // note: only for requests with upload progress enabled.
38 virtual void OnUploadProgress(uint64 position, uint64 size) = 0; 76 virtual void OnUploadProgress(uint64 position, uint64 size) = 0;
39 77
40 // Called when a redirect occurs. The implementation may return false to 78 // Called when a redirect occurs. The implementation may return false to
41 // suppress the redirect. The ResourceResponseInfo provides information about 79 // suppress the redirect. The ResourceResponseInfo provides information about
42 // the redirect response and the RedirectInfo includes information about the 80 // the redirect response and the RedirectInfo includes information about the
43 // request to be made if the method returns true. 81 // request to be made if the method returns true.
44 virtual bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, 82 virtual bool OnReceivedRedirect(const net::RedirectInfo& redirect_info,
45 const ResourceResponseInfo& info) = 0; 83 const ResourceResponseInfo& info) = 0;
46 84
47 // Called when response headers are available (after all redirects have 85 // Called when response headers are available (after all redirects have
48 // been followed). 86 // been followed).
49 virtual void OnReceivedResponse(const ResourceResponseInfo& info) = 0; 87 virtual void OnReceivedResponse(const ResourceResponseInfo& info) = 0;
50 88
51 // Called when a chunk of response data is downloaded. This method may be 89 // Called when a chunk of response data is downloaded. This method may be
52 // called multiple times or not at all if an error occurs. This method is 90 // called multiple times or not at all if an error occurs. This method is
53 // only called if RequestInfo::download_to_file was set to true, and in 91 // only called if RequestInfo::download_to_file was set to true, and in
54 // that case, OnReceivedData will not be called. 92 // that case, OnReceivedData will not be called.
55 // The encoded_data_length is the length of the encoded data transferred 93 // The encoded_data_length is the length of the encoded data transferred
56 // over the network, which could be different from data length (e.g. for 94 // over the network, which could be different from data length (e.g. for
57 // gzipped content). 95 // gzipped content).
58 virtual void OnDownloadedData(int len, int encoded_data_length) = 0; 96 virtual void OnDownloadedData(int len, int encoded_data_length) = 0;
59 97
60 // Called when a chunk of response data is available. This method may 98 // Called when a chunk of response data is available. This method may
61 // be called multiple times or not at all if an error occurs. 99 // be called multiple times or not at all if an error occurs.
62 // The encoded_data_length is the length of the encoded data transferred 100 virtual void OnReceivedData(scoped_ptr<ReceivedData> data) = 0;
63 // over the network, which could be different from data length (e.g. for
64 // gzipped content).
65 virtual void OnReceivedData(const char* data,
66 int data_length,
67 int encoded_data_length) = 0;
68 101
69 // Called when metadata generated by the renderer is retrieved from the 102 // Called when metadata generated by the renderer is retrieved from the
70 // cache. This method may be called zero or one times. 103 // cache. This method may be called zero or one times.
71 virtual void OnReceivedCachedMetadata(const char* data, int len) {} 104 virtual void OnReceivedCachedMetadata(const char* data, int len) {}
72 105
73 // Called when the response is complete. This method signals completion of 106 // Called when the response is complete. This method signals completion of
74 // the resource load. 107 // the resource load.
75 virtual void OnCompletedRequest(int error_code, 108 virtual void OnCompletedRequest(int error_code,
76 bool was_ignored_by_handler, 109 bool was_ignored_by_handler,
77 bool stale_copy_in_cache, 110 bool stale_copy_in_cache,
78 const std::string& security_info, 111 const std::string& security_info,
79 const base::TimeTicks& completion_time, 112 const base::TimeTicks& completion_time,
80 int64 total_transfer_size) = 0; 113 int64 total_transfer_size) = 0;
81 114
82 protected: 115 protected:
83 virtual ~RequestPeer() {} 116 virtual ~RequestPeer() {}
84 }; 117 };
85 118
86 } // namespace content 119 } // namespace content
87 120
88 #endif // CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ 121 #endif // CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_
OLDNEW
« content/child/web_url_loader_impl.cc ('K') | « content/content_tests.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698