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

Side by Side Diff: content/renderer/fetchers/resource_fetcher_impl.cc

Issue 2869663002: ResourceFetcher::Start should be given a WebLocalFrame (Closed)
Patch Set: fix 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
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/renderer/fetchers/resource_fetcher_impl.h" 5 #include "content/renderer/fetchers/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/WebSecurityOrigin.h" 15 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
16 #include "third_party/WebKit/public/platform/WebString.h" 16 #include "third_party/WebKit/public/platform/WebString.h"
17 #include "third_party/WebKit/public/platform/WebURL.h" 17 #include "third_party/WebKit/public/platform/WebURL.h"
18 #include "third_party/WebKit/public/platform/WebURLError.h" 18 #include "third_party/WebKit/public/platform/WebURLError.h"
19 #include "third_party/WebKit/public/platform/WebURLLoader.h" 19 #include "third_party/WebKit/public/platform/WebURLLoader.h"
20 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 20 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
21 #include "third_party/WebKit/public/platform/WebURLResponse.h" 21 #include "third_party/WebKit/public/platform/WebURLResponse.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 ResourceFetcher* ResourceFetcher::Create(const GURL& url) { 30 ResourceFetcher* ResourceFetcher::Create(const GURL& url) {
31 return new ResourceFetcherImpl(url); 31 return new ResourceFetcherImpl(url);
32 } 32 }
33 33
34 class ResourceFetcherImpl::ClientImpl : public blink::WebURLLoaderClient { 34 class ResourceFetcherImpl::ClientImpl : public blink::WebURLLoaderClient {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 blink::kWebReferrerPolicyDefault, request_.Url(), 164 blink::kWebReferrerPolicyDefault, request_.Url(),
165 blink::WebString::FromUTF8(value)); 165 blink::WebString::FromUTF8(value));
166 request_.SetHTTPReferrer(referrer, blink::kWebReferrerPolicyDefault); 166 request_.SetHTTPReferrer(referrer, blink::kWebReferrerPolicyDefault);
167 } else { 167 } else {
168 request_.SetHTTPHeaderField(blink::WebString::FromUTF8(header), 168 request_.SetHTTPHeaderField(blink::WebString::FromUTF8(header),
169 blink::WebString::FromUTF8(value)); 169 blink::WebString::FromUTF8(value));
170 } 170 }
171 } 171 }
172 172
173 void ResourceFetcherImpl::Start( 173 void ResourceFetcherImpl::Start(
174 blink::WebFrame* frame, 174 blink::WebLocalFrame* frame,
175 blink::WebURLRequest::RequestContext request_context, 175 blink::WebURLRequest::RequestContext request_context,
176 const Callback& callback) { 176 const Callback& callback) {
177 DCHECK(!loader_); 177 DCHECK(!loader_);
178 DCHECK(!client_); 178 DCHECK(!client_);
179 DCHECK(!request_.IsNull()); 179 DCHECK(!request_.IsNull());
180 DCHECK(frame);
181 DCHECK(!frame->GetDocument().IsNull());
180 if (!request_.HttpBody().IsNull()) 182 if (!request_.HttpBody().IsNull())
181 DCHECK_NE("GET", request_.HttpMethod().Utf8()) << "GETs can't have bodies."; 183 DCHECK_NE("GET", request_.HttpMethod().Utf8()) << "GETs can't have bodies.";
182 184
183 request_.SetRequestContext(request_context); 185 request_.SetRequestContext(request_context);
184 request_.SetFirstPartyForCookies(frame->GetDocument().FirstPartyForCookies()); 186 request_.SetFirstPartyForCookies(frame->GetDocument().FirstPartyForCookies());
185 request_.AddHTTPOriginIfNeeded(blink::WebSecurityOrigin::CreateUnique()); 187 request_.AddHTTPOriginIfNeeded(blink::WebSecurityOrigin::CreateUnique());
186 188
187 client_.reset(new ClientImpl(this, callback)); 189 client_.reset(new ClientImpl(this, callback));
188 190
189 loader_ = blink::Platform::Current()->CreateURLLoader(); 191 loader_ = blink::Platform::Current()->CreateURLLoader();
(...skipping 14 matching lines...) Expand all
204 void ResourceFetcherImpl::OnLoadComplete() { 206 void ResourceFetcherImpl::OnLoadComplete() {
205 timeout_timer_.Stop(); 207 timeout_timer_.Stop();
206 } 208 }
207 209
208 void ResourceFetcherImpl::Cancel() { 210 void ResourceFetcherImpl::Cancel() {
209 loader_->Cancel(); 211 loader_->Cancel();
210 client_->Cancel(); 212 client_->Cancel();
211 } 213 }
212 214
213 } // namespace content 215 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/fetchers/resource_fetcher_impl.h ('k') | content/renderer/mojo_context_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698