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

Side by Side Diff: content/child/test_request_peer.h

Issue 2629513003: Implement CachedMetadata handling on MojoAsyncResourceHandler (Closed)
Patch Set: fix Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_CHILD_TEST_REQUEST_PEER_H_ 5 #ifndef CONTENT_CHILD_TEST_REQUEST_PEER_H_
6 #define CONTENT_CHILD_TEST_REQUEST_PEER_H_ 6 #define CONTENT_CHILD_TEST_REQUEST_PEER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <vector>
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "content/public/child/request_peer.h" 13 #include "content/public/child/request_peer.h"
13 14
14 namespace net { 15 namespace net {
15 struct RedirectInfo; 16 struct RedirectInfo;
16 } // namespace net 17 } // namespace net
17 18
18 namespace content { 19 namespace content {
19 20
20 class ReceivedData; 21 class ReceivedData;
21 class ResourceDispatcher; 22 class ResourceDispatcher;
22 struct ResourceResponseInfo; 23 struct ResourceResponseInfo;
23 24
24 // Listens for request response data and stores it so that it can be compared 25 // Listens for request response data and stores it so that it can be compared
25 // to the reference data. 26 // to the reference data.
26 class TestRequestPeer : public RequestPeer { 27 class TestRequestPeer : public RequestPeer {
27 public: 28 public:
28 struct Context; 29 struct Context;
29 TestRequestPeer(ResourceDispatcher* dispatcher, Context* context); 30 TestRequestPeer(ResourceDispatcher* dispatcher, Context* context);
30 ~TestRequestPeer() override; 31 ~TestRequestPeer() override;
31 32
32 void OnUploadProgress(uint64_t position, uint64_t size) override; 33 void OnUploadProgress(uint64_t position, uint64_t size) override;
33 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, 34 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info,
34 const ResourceResponseInfo& info) override; 35 const ResourceResponseInfo& info) override;
35 void OnReceivedResponse(const ResourceResponseInfo& info) override; 36 void OnReceivedResponse(const ResourceResponseInfo& info) override;
36 void OnDownloadedData(int len, int encoded_data_length) override; 37 void OnDownloadedData(int len, int encoded_data_length) override;
37 void OnReceivedData(std::unique_ptr<ReceivedData> data) override; 38 void OnReceivedData(std::unique_ptr<ReceivedData> data) override;
38 void OnTransferSizeUpdated(int transfer_size_diff) override; 39 void OnTransferSizeUpdated(int transfer_size_diff) override;
40 void OnReceivedCachedMetadata(const char* data, int len) override;
39 void OnCompletedRequest(int error_code, 41 void OnCompletedRequest(int error_code,
40 bool was_ignored_by_handler, 42 bool was_ignored_by_handler,
41 bool stale_copy_in_cache, 43 bool stale_copy_in_cache,
42 const base::TimeTicks& completion_time, 44 const base::TimeTicks& completion_time,
43 int64_t total_transfer_size, 45 int64_t total_transfer_size,
44 int64_t encoded_body_size) override; 46 int64_t encoded_body_size) override;
45 47
46 struct Context final { 48 struct Context final {
47 Context(); 49 Context();
48 ~Context(); 50 ~Context();
49 51
50 // True if should follow redirects, false if should cancel them. 52 // True if should follow redirects, false if should cancel them.
51 bool follow_redirects = true; 53 bool follow_redirects = true;
52 // True if the request should be deferred on redirects. 54 // True if the request should be deferred on redirects.
53 bool defer_on_redirect = false; 55 bool defer_on_redirect = false;
54 56
55 // Number of total redirects seen. 57 // Number of total redirects seen.
56 int seen_redirects = 0; 58 int seen_redirects = 0;
57 59
58 bool cancel_on_receive_response = false; 60 bool cancel_on_receive_response = false;
59 bool cancel_on_receive_data = false; 61 bool cancel_on_receive_data = false;
60 bool received_response = false; 62 bool received_response = false;
61 63
64 std::vector<char> cached_metadata;
62 // Data received. If downloading to file, remains empty. 65 // Data received. If downloading to file, remains empty.
63 std::string data; 66 std::string data;
64 67
65 // Total encoded data length, regardless of whether downloading to a file or 68 // Total encoded data length, regardless of whether downloading to a file or
66 // not. 69 // not.
67 int total_encoded_data_length = 0; 70 int total_encoded_data_length = 0;
68 bool defer_on_transfer_size_updated = false; 71 bool defer_on_transfer_size_updated = false;
69 72
70 // Total length when downloading to a file. 73 // Total length when downloading to a file.
71 int total_downloaded_data_length = 0; 74 int total_downloaded_data_length = 0;
72 75
73 bool complete = false; 76 bool complete = false;
74 bool cancelled = false; 77 bool cancelled = false;
75 int request_id = -1; 78 int request_id = -1;
76 }; 79 };
77 80
78 private: 81 private:
79 ResourceDispatcher* dispatcher_; 82 ResourceDispatcher* dispatcher_;
80 Context* context_; 83 Context* context_;
81 84
82 DISALLOW_COPY_AND_ASSIGN(TestRequestPeer); 85 DISALLOW_COPY_AND_ASSIGN(TestRequestPeer);
83 }; 86 };
84 87
85 } // namespace content 88 } // namespace content
86 89
87 #endif // CONTENT_CHILD_TEST_REQUEST_PEER_H_ 90 #endif // CONTENT_CHILD_TEST_REQUEST_PEER_H_
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_fetch_dispatcher.cc ('k') | content/child/test_request_peer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698