OLD | NEW |
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 #include "content/renderer/fetchers/associated_resource_fetcher_impl.h" | 5 #include "content/renderer/fetchers/associated_resource_fetcher_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "third_party/WebKit/public/platform/Platform.h" | 13 #include "third_party/WebKit/public/platform/Platform.h" |
14 #include "third_party/WebKit/public/platform/WebHTTPBody.h" | 14 #include "third_party/WebKit/public/platform/WebHTTPBody.h" |
15 #include "third_party/WebKit/public/platform/WebString.h" | 15 #include "third_party/WebKit/public/platform/WebString.h" |
16 #include "third_party/WebKit/public/platform/WebURL.h" | 16 #include "third_party/WebKit/public/platform/WebURL.h" |
17 #include "third_party/WebKit/public/platform/WebURLError.h" | 17 #include "third_party/WebKit/public/platform/WebURLError.h" |
18 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 18 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
19 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 19 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
20 #include "third_party/WebKit/public/web/WebAssociatedURLLoader.h" | 20 #include "third_party/WebKit/public/web/WebAssociatedURLLoader.h" |
21 #include "third_party/WebKit/public/web/WebAssociatedURLLoaderClient.h" | 21 #include "third_party/WebKit/public/web/WebAssociatedURLLoaderClient.h" |
22 #include "third_party/WebKit/public/web/WebDocument.h" | 22 #include "third_party/WebKit/public/web/WebDocument.h" |
23 #include "third_party/WebKit/public/web/WebFrame.h" | |
24 #include "third_party/WebKit/public/web/WebKit.h" | 23 #include "third_party/WebKit/public/web/WebKit.h" |
| 24 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
25 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 25 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 | 28 |
29 // static | 29 // static |
30 AssociatedResourceFetcher* AssociatedResourceFetcher::Create(const GURL& url) { | 30 AssociatedResourceFetcher* AssociatedResourceFetcher::Create(const GURL& url) { |
31 return new AssociatedResourceFetcherImpl(url); | 31 return new AssociatedResourceFetcherImpl(url); |
32 } | 32 } |
33 | 33 |
34 class AssociatedResourceFetcherImpl::ClientImpl | 34 class AssociatedResourceFetcherImpl::ClientImpl |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 void AssociatedResourceFetcherImpl::SetLoaderOptions( | 146 void AssociatedResourceFetcherImpl::SetLoaderOptions( |
147 const blink::WebAssociatedURLLoaderOptions& options) { | 147 const blink::WebAssociatedURLLoaderOptions& options) { |
148 DCHECK(!request_.IsNull()); | 148 DCHECK(!request_.IsNull()); |
149 DCHECK(!loader_); | 149 DCHECK(!loader_); |
150 | 150 |
151 options_ = options; | 151 options_ = options; |
152 } | 152 } |
153 | 153 |
154 void AssociatedResourceFetcherImpl::Start( | 154 void AssociatedResourceFetcherImpl::Start( |
155 blink::WebFrame* frame, | 155 blink::WebLocalFrame* frame, |
156 blink::WebURLRequest::RequestContext request_context, | 156 blink::WebURLRequest::RequestContext request_context, |
157 blink::WebURLRequest::FrameType frame_type, | 157 blink::WebURLRequest::FrameType frame_type, |
158 const Callback& callback) { | 158 const Callback& callback) { |
159 DCHECK(!loader_); | 159 DCHECK(!loader_); |
160 DCHECK(!client_); | 160 DCHECK(!client_); |
161 DCHECK(!request_.IsNull()); | 161 DCHECK(!request_.IsNull()); |
162 if (!request_.HttpBody().IsNull()) | 162 if (!request_.HttpBody().IsNull()) |
163 DCHECK_NE("GET", request_.HttpMethod().Utf8()) << "GETs can't have bodies."; | 163 DCHECK_NE("GET", request_.HttpMethod().Utf8()) << "GETs can't have bodies."; |
164 | 164 |
165 request_.SetRequestContext(request_context); | 165 request_.SetRequestContext(request_context); |
166 request_.SetFrameType(frame_type); | 166 request_.SetFrameType(frame_type); |
167 request_.SetFirstPartyForCookies(frame->GetDocument().FirstPartyForCookies()); | 167 request_.SetFirstPartyForCookies(frame->GetDocument().FirstPartyForCookies()); |
168 | 168 |
169 client_.reset(new ClientImpl(callback)); | 169 client_.reset(new ClientImpl(callback)); |
170 | 170 |
171 loader_.reset(frame->CreateAssociatedURLLoader(options_)); | 171 loader_.reset(frame->CreateAssociatedURLLoader(options_)); |
172 loader_->LoadAsynchronously(request_, client_.get()); | 172 loader_->LoadAsynchronously(request_, client_.get()); |
173 | 173 |
174 // No need to hold on to the request; reset it now. | 174 // No need to hold on to the request; reset it now. |
175 request_ = blink::WebURLRequest(); | 175 request_ = blink::WebURLRequest(); |
176 } | 176 } |
177 | 177 |
178 void AssociatedResourceFetcherImpl::Cancel() { | 178 void AssociatedResourceFetcherImpl::Cancel() { |
179 loader_->Cancel(); | 179 loader_->Cancel(); |
180 client_->Cancel(); | 180 client_->Cancel(); |
181 } | 181 } |
182 | 182 |
183 } // namespace content | 183 } // namespace content |
OLD | NEW |