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

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

Issue 2900563002: Network service: Safe browsing check for sub-resources from renderer. (Closed)
Patch Set: . Created 3 years, 7 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
jam 2017/05/25 15:45:51 please add unit tests for this class to handle pau
yzshen1 2017/05/26 20:43:52 Done.
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_CHILD_THROTTLING_URL_LOADER_H_
6 #define CONTENT_CHILD_THROTTLING_URL_LOADER_H_
7
8 #include <memory>
9
10 #include "content/common/url_loader.mojom.h"
11 #include "content/common/url_loader_factory.mojom.h"
12 #include "content/public/child/url_loader_throttle.h"
13 #include "mojo/public/cpp/bindings/binding.h"
14
15 namespace content {
16
17 namespace mojom {
18 class URLLoaderFactory;
19 }
20
21 class ThrottlingURLLoader : public mojom::URLLoaderClient,
jam 2017/05/25 15:45:51 nit: please document
yzshen1 2017/05/26 20:43:52 Done.
22 public URLLoaderThrottle::Delegate {
23 public:
24 // |factory| and |client| must stay alive during the lifetime of the returned
25 // object.
26 static std::unique_ptr<ThrottlingURLLoader> CreateLoaderAndStart(
27 mojom::URLLoaderFactory* factory,
28 std::vector<std::unique_ptr<URLLoaderThrottle>> throttles,
29 int32_t routing_id,
30 int32_t request_id,
31 uint32_t options,
32 std::unique_ptr<ResourceRequest> url_request,
33 mojom::URLLoaderClient* client);
34
35 ~ThrottlingURLLoader() override;
36
37 void FollowRedirect();
38 void SetPriority(net::RequestPriority priority, int32_t intra_priority_value);
39
40 private:
41 ThrottlingURLLoader(std::vector<std::unique_ptr<URLLoaderThrottle>> throttles,
42 mojom::URLLoaderClient* client);
43
44 void Start(mojom::URLLoaderFactory* factory,
45 int32_t routing_id,
46 int32_t request_id,
47 uint32_t options,
48 std::unique_ptr<ResourceRequest> url_request);
49
50 // mojom::URLLoaderClient implementation:
51 void OnReceiveResponse(const ResourceResponseHead& response_head,
52 const base::Optional<net::SSLInfo>& ssl_info,
53 mojom::DownloadedTempFilePtr downloaded_file) override;
54 void OnReceiveRedirect(const net::RedirectInfo& redirect_info,
55 const ResourceResponseHead& response_head) override;
56 void OnDataDownloaded(int64_t data_len, int64_t encoded_data_len) override;
57 void OnUploadProgress(int64_t current_position,
58 int64_t total_size,
59 OnUploadProgressCallback ack_callback) override;
60 void OnReceiveCachedMetadata(const std::vector<uint8_t>& data) override;
61 void OnTransferSizeUpdated(int32_t transfer_size_diff) override;
62 void OnStartLoadingResponseBody(
63 mojo::ScopedDataPipeConsumerHandle body) override;
64 void OnComplete(const ResourceRequestCompletionStatus& status) override;
65
66 // URLLoaderThrottle::Delegate:
67 void CancelWithError(int error_code) override;
68 void Resume() override;
69
70 enum DeferredStage {
71 DEFERRED_NONE,
72 DEFERRED_START,
73 DEFERRED_REDIRECT,
74 DEFERRED_RESPONSE
75 };
76 DeferredStage deferred_stage_ = DEFERRED_NONE;
77 bool cancelled_by_throttle_ = false;
78
79 std::unique_ptr<URLLoaderThrottle> throttle_;
80
81 mojom::URLLoaderClient* forwarding_client_;
82 mojo::Binding<mojom::URLLoaderClient> client_binding_;
83
84 mojom::URLLoaderAssociatedPtr url_loader_;
85
86 // Set if start if deferred.
87 mojom::URLLoaderFactory* url_loader_factory_ = nullptr;
88 int32_t routing_id_ = -1;
89 int32_t request_id_ = -1;
90 uint32_t options_ = mojom::kURLLoadOptionNone;
91 std::unique_ptr<ResourceRequest> url_request_;
92
93 // Set if either response or redirect is deferred.
94 ResourceResponseHead response_head_;
95
96 // Set if response is deferred.
97 base::Optional<net::SSLInfo> ssl_info_;
98 mojom::DownloadedTempFilePtr downloaded_file_;
99
100 // Set if redirect is deferred.
101 net::RedirectInfo redirect_info_;
102
103 // Set if request is deferred and SetPriority() is called.
104 bool set_priority_cached_ = false;
105 net::RequestPriority priority_ = net::MINIMUM_PRIORITY;
106 int32_t intra_priority_value_ = 0;
107
108 DISALLOW_COPY_AND_ASSIGN(ThrottlingURLLoader);
109 };
110
111 } // namespace content
112
113 #endif // CONTENT_CHILD_THROTTLING_URL_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698