OLD | NEW |
---|---|
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 #include "content/browser/renderer_host/resource_loader.h" | 5 #include "content/browser/renderer_host/resource_loader.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "content/browser/child_process_security_policy_impl.h" | 9 #include "content/browser/child_process_security_policy_impl.h" |
10 #include "content/browser/renderer_host/doomed_resource_handler.h" | 10 #include "content/browser/renderer_host/doomed_resource_handler.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 if (ssl_client_auth_handler_) | 75 if (ssl_client_auth_handler_) |
76 ssl_client_auth_handler_->OnRequestCancelled(); | 76 ssl_client_auth_handler_->OnRequestCancelled(); |
77 | 77 |
78 // Run ResourceHandler destructor before we tear-down the rest of our state | 78 // Run ResourceHandler destructor before we tear-down the rest of our state |
79 // as the ResourceHandler may want to inspect the URLRequest and other state. | 79 // as the ResourceHandler may want to inspect the URLRequest and other state. |
80 handler_.reset(); | 80 handler_.reset(); |
81 } | 81 } |
82 | 82 |
83 void ResourceLoader::StartRequest() { | 83 void ResourceLoader::StartRequest() { |
84 if (delegate_->HandleExternalProtocol(this, request_->url())) { | 84 if (delegate_->HandleExternalProtocol(this, request_->url())) { |
85 CancelRequestInternal(net::ERR_UNKNOWN_URL_SCHEME, false); | 85 GetRequestInfo()->set_handled_externally(true); |
86 CancelRequestInternal(net::ERR_ABORTED, false); | |
86 return; | 87 return; |
87 } | 88 } |
88 | 89 |
89 // Give the handler a chance to delay the URLRequest from being started. | 90 // Give the handler a chance to delay the URLRequest from being started. |
90 bool defer_start = false; | 91 bool defer_start = false; |
91 if (!handler_->OnWillStart(GetRequestInfo()->GetRequestID(), request_->url(), | 92 if (!handler_->OnWillStart(GetRequestInfo()->GetRequestID(), request_->url(), |
92 &defer_start)) { | 93 &defer_start)) { |
93 Cancel(); | 94 Cancel(); |
94 return; | 95 return; |
95 } | 96 } |
96 | 97 |
97 if (defer_start) { | 98 if (defer_start) { |
98 deferred_stage_ = DEFERRED_START; | 99 deferred_stage_ = DEFERRED_START; |
99 } else { | 100 } else { |
100 StartRequestInternal(); | 101 StartRequestInternal(); |
101 } | 102 } |
102 } | 103 } |
103 | 104 |
104 void ResourceLoader::CancelRequest(bool from_renderer) { | 105 void ResourceLoader::CancelRequest(bool from_renderer) { |
105 CancelRequestInternal(net::ERR_ABORTED, from_renderer); | 106 CancelRequestInternal(net::ERR_ABORTED, from_renderer); |
106 } | 107 } |
107 | 108 |
109 void ResourceLoader::CancelWithHandledExternally() { | |
110 GetRequestInfo()->set_handled_externally(true); | |
111 CancelRequestInternal(net::ERR_ABORTED, false); | |
darin (slow to review)
2012/06/25 16:15:32
another idea, which may be too crazy, is to just g
| |
112 } | |
113 | |
108 void ResourceLoader::ReportUploadProgress() { | 114 void ResourceLoader::ReportUploadProgress() { |
109 ResourceRequestInfoImpl* info = GetRequestInfo(); | 115 ResourceRequestInfoImpl* info = GetRequestInfo(); |
110 | 116 |
111 if (waiting_for_upload_progress_ack_) | 117 if (waiting_for_upload_progress_ack_) |
112 return; // Send one progress event at a time. | 118 return; // Send one progress event at a time. |
113 | 119 |
114 uint64 size = info->GetUploadSize(); | 120 uint64 size = info->GetUploadSize(); |
115 if (!size) | 121 if (!size) |
116 return; // Nothing to upload. | 122 return; // Nothing to upload. |
117 | 123 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 | 202 |
197 // Tell the renderer that this request was disallowed. | 203 // Tell the renderer that this request was disallowed. |
198 Cancel(); | 204 Cancel(); |
199 return; | 205 return; |
200 } | 206 } |
201 | 207 |
202 delegate_->DidReceiveRedirect(this, new_url); | 208 delegate_->DidReceiveRedirect(this, new_url); |
203 | 209 |
204 if (delegate_->HandleExternalProtocol(this, new_url)) { | 210 if (delegate_->HandleExternalProtocol(this, new_url)) { |
205 // The request is complete so we can remove it. | 211 // The request is complete so we can remove it. |
206 CancelRequestInternal(net::ERR_UNKNOWN_URL_SCHEME, false); | 212 GetRequestInfo()->set_handled_externally(true); |
213 CancelRequestInternal(net::ERR_ABORTED, false); | |
207 return; | 214 return; |
208 } | 215 } |
209 | 216 |
210 scoped_refptr<ResourceResponse> response(new ResourceResponse()); | 217 scoped_refptr<ResourceResponse> response(new ResourceResponse()); |
211 PopulateResourceResponse(request_.get(), response); | 218 PopulateResourceResponse(request_.get(), response); |
212 | 219 |
213 if (!handler_->OnRequestRedirected(info->GetRequestID(), new_url, response, | 220 if (!handler_->OnRequestRedirected(info->GetRequestID(), new_url, response, |
214 defer)) { | 221 defer)) { |
215 Cancel(); | 222 Cancel(); |
216 } | 223 } |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
640 } else { | 647 } else { |
641 OnResponseStarted(request_.get()); | 648 OnResponseStarted(request_.get()); |
642 } | 649 } |
643 } | 650 } |
644 | 651 |
645 void ResourceLoader::CallDidFinishLoading() { | 652 void ResourceLoader::CallDidFinishLoading() { |
646 delegate_->DidFinishLoading(this); | 653 delegate_->DidFinishLoading(this); |
647 } | 654 } |
648 | 655 |
649 } // namespace content | 656 } // namespace content |
OLD | NEW |