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

Side by Side Diff: content/browser/loader/resource_loader.h

Issue 1970693002: Use mojo for Chrome Loading, Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BROWSER_LOADER_RESOURCE_LOADER_H_ 5 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_
6 #define CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ 6 #define CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "content/browser/loader/resource_handler.h" 13 #include "content/browser/loader/resource_handler.h"
14 #include "content/browser/ssl/ssl_client_auth_handler.h" 14 #include "content/browser/ssl/ssl_client_auth_handler.h"
15 #include "content/browser/ssl/ssl_error_handler.h" 15 #include "content/browser/ssl/ssl_error_handler.h"
16 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 #include "content/common/url_loader.mojom.h"
17 #include "content/public/browser/resource_controller.h" 18 #include "content/public/browser/resource_controller.h"
18 #include "net/url_request/url_request.h" 19 #include "net/url_request/url_request.h"
19 20
20 namespace net { 21 namespace net {
21 class X509Certificate; 22 class X509Certificate;
22 } 23 }
23 24
24 namespace content { 25 namespace content {
25 class CertStore; 26 class CertStore;
26 class ResourceDispatcherHostLoginDelegate; 27 class ResourceDispatcherHostLoginDelegate;
27 class ResourceLoaderDelegate; 28 class ResourceLoaderDelegate;
28 class ResourceRequestInfoImpl; 29 class ResourceRequestInfoImpl;
29 30
30 // This class is responsible for driving the URLRequest (i.e., calling Start, 31 // This class is responsible for driving the URLRequest (i.e., calling Start,
31 // Read, and servicing events). It has a ResourceHandler, which is typically a 32 // Read, and servicing events). It has a ResourceHandler, which is typically a
32 // chain of ResourceHandlers, and is the ResourceController for its handler. 33 // chain of ResourceHandlers, and is the ResourceController for its handler.
33 class CONTENT_EXPORT ResourceLoader : public net::URLRequest::Delegate, 34 class CONTENT_EXPORT ResourceLoader : public net::URLRequest::Delegate,
34 public SSLErrorHandler::Delegate, 35 public SSLErrorHandler::Delegate,
35 public SSLClientAuthHandler::Delegate, 36 public SSLClientAuthHandler::Delegate,
36 public ResourceController { 37 public ResourceController {
37 public: 38 public:
38 ResourceLoader(std::unique_ptr<net::URLRequest> request, 39 ResourceLoader(std::unique_ptr<net::URLRequest> request,
39 std::unique_ptr<ResourceHandler> handler, 40 std::unique_ptr<ResourceHandler> handler,
40 CertStore* cert_store, 41 CertStore* cert_store,
42 std::unique_ptr<mojom::URLLoader> mojo_loader,
43 mojom::URLLoaderClientPtr mojo_loader_client,
44 ResourceLoaderDelegate* delegate);
45 ResourceLoader(std::unique_ptr<net::URLRequest> request,
46 std::unique_ptr<ResourceHandler> handler,
47 CertStore* cert_store,
41 ResourceLoaderDelegate* delegate); 48 ResourceLoaderDelegate* delegate);
42 ~ResourceLoader() override; 49 ~ResourceLoader() override;
43 50
44 void StartRequest(); 51 void StartRequest();
45 void CancelRequest(bool from_renderer); 52 void CancelRequest(bool from_renderer);
46 53
47 bool is_transferring() const { return is_transferring_; } 54 bool is_transferring() const { return is_transferring_; }
48 void MarkAsTransferring(const scoped_refptr<ResourceResponse>& response); 55 void MarkAsTransferring(const scoped_refptr<ResourceResponse>& response);
49 void CompleteTransfer(); 56 void CompleteTransfer();
50 57
51 net::URLRequest* request() { return request_.get(); } 58 net::URLRequest* request() { return request_.get(); }
52 ResourceRequestInfoImpl* GetRequestInfo(); 59 ResourceRequestInfoImpl* GetRequestInfo();
53 60
54 void ClearLoginDelegate(); 61 void ClearLoginDelegate();
55 62
56 // Returns a pointer to the ResourceResponse for a request that is 63 // Returns a pointer to the ResourceResponse for a request that is
57 // being transferred to a new consumer. The response is valid between 64 // being transferred to a new consumer. The response is valid between
58 // the time that the request is marked as transferring via 65 // the time that the request is marked as transferring via
59 // MarkAsTransferring() and the time that the transfer is completed 66 // MarkAsTransferring() and the time that the transfer is completed
60 // via CompleteTransfer(). 67 // via CompleteTransfer().
61 ResourceResponse* transferring_response() { 68 ResourceResponse* transferring_response() {
62 return transferring_response_.get(); 69 return transferring_response_.get();
63 } 70 }
64 71
72 mojom::URLLoaderClient* client() const { return mojo_loader_client_.get(); }
73
65 private: 74 private:
66 // net::URLRequest::Delegate implementation: 75 // net::URLRequest::Delegate implementation:
67 void OnReceivedRedirect(net::URLRequest* request, 76 void OnReceivedRedirect(net::URLRequest* request,
68 const net::RedirectInfo& redirect_info, 77 const net::RedirectInfo& redirect_info,
69 bool* defer) override; 78 bool* defer) override;
70 void OnAuthRequired(net::URLRequest* request, 79 void OnAuthRequired(net::URLRequest* request,
71 net::AuthChallengeInfo* info) override; 80 net::AuthChallengeInfo* info) override;
72 void OnCertificateRequested(net::URLRequest* request, 81 void OnCertificateRequested(net::URLRequest* request,
73 net::SSLCertRequestInfo* info) override; 82 net::SSLCertRequestInfo* info) override;
74 void OnSSLCertificateError(net::URLRequest* request, 83 void OnSSLCertificateError(net::URLRequest* request,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 DEFERRED_REDIRECT, 133 DEFERRED_REDIRECT,
125 DEFERRED_READ, 134 DEFERRED_READ,
126 DEFERRED_RESPONSE_COMPLETE, 135 DEFERRED_RESPONSE_COMPLETE,
127 DEFERRED_FINISH 136 DEFERRED_FINISH
128 }; 137 };
129 DeferredStage deferred_stage_; 138 DeferredStage deferred_stage_;
130 139
131 std::unique_ptr<net::URLRequest> request_; 140 std::unique_ptr<net::URLRequest> request_;
132 std::unique_ptr<ResourceHandler> handler_; 141 std::unique_ptr<ResourceHandler> handler_;
133 ResourceLoaderDelegate* delegate_; 142 ResourceLoaderDelegate* delegate_;
143 std::unique_ptr<mojom::URLLoader> mojo_loader_;
144 mojom::URLLoaderClientPtr mojo_loader_client_;
134 145
135 scoped_refptr<ResourceDispatcherHostLoginDelegate> login_delegate_; 146 scoped_refptr<ResourceDispatcherHostLoginDelegate> login_delegate_;
136 std::unique_ptr<SSLClientAuthHandler> ssl_client_auth_handler_; 147 std::unique_ptr<SSLClientAuthHandler> ssl_client_auth_handler_;
137 148
138 base::TimeTicks read_deferral_start_time_; 149 base::TimeTicks read_deferral_start_time_;
139 150
140 // Indicates that we are in a state of being transferred to a new downstream 151 // Indicates that we are in a state of being transferred to a new downstream
141 // consumer. We are waiting for a notification to complete the transfer, at 152 // consumer. We are waiting for a notification to complete the transfer, at
142 // which point we'll receive a new ResourceHandler. 153 // which point we'll receive a new ResourceHandler.
143 bool is_transferring_; 154 bool is_transferring_;
(...skipping 15 matching lines...) Expand all
159 CertStore* cert_store_; 170 CertStore* cert_store_;
160 171
161 base::WeakPtrFactory<ResourceLoader> weak_ptr_factory_; 172 base::WeakPtrFactory<ResourceLoader> weak_ptr_factory_;
162 173
163 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); 174 DISALLOW_COPY_AND_ASSIGN(ResourceLoader);
164 }; 175 };
165 176
166 } // namespace content 177 } // namespace content
167 178
168 #endif // CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ 179 #endif // CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698