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

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

Issue 2867673003: Have content::ResourceFetcher use FetchContext::CreateURLLoader (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
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/WebLocalFrameImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
14 #include "third_party/WebKit/public/platform/WebHTTPBody.h" 13 #include "third_party/WebKit/public/platform/WebHTTPBody.h"
15 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 14 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
16 #include "third_party/WebKit/public/platform/WebString.h" 15 #include "third_party/WebKit/public/platform/WebString.h"
17 #include "third_party/WebKit/public/platform/WebURL.h" 16 #include "third_party/WebKit/public/platform/WebURL.h"
18 #include "third_party/WebKit/public/platform/WebURLError.h" 17 #include "third_party/WebKit/public/platform/WebURLError.h"
19 #include "third_party/WebKit/public/platform/WebURLLoader.h" 18 #include "third_party/WebKit/public/platform/WebURLLoader.h"
20 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 19 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
21 #include "third_party/WebKit/public/platform/WebURLResponse.h" 20 #include "third_party/WebKit/public/platform/WebURLResponse.h"
22 #include "third_party/WebKit/public/web/WebDocument.h" 21 #include "third_party/WebKit/public/web/WebDocument.h"
23 #include "third_party/WebKit/public/web/WebKit.h" 22 #include "third_party/WebKit/public/web/WebKit.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 DCHECK(!frame->GetDocument().IsNull()); 180 DCHECK(!frame->GetDocument().IsNull());
182 if (!request_.HttpBody().IsNull()) 181 if (!request_.HttpBody().IsNull())
183 DCHECK_NE("GET", request_.HttpMethod().Utf8()) << "GETs can't have bodies."; 182 DCHECK_NE("GET", request_.HttpMethod().Utf8()) << "GETs can't have bodies.";
184 183
185 request_.SetRequestContext(request_context); 184 request_.SetRequestContext(request_context);
186 request_.SetFirstPartyForCookies(frame->GetDocument().FirstPartyForCookies()); 185 request_.SetFirstPartyForCookies(frame->GetDocument().FirstPartyForCookies());
187 request_.AddHTTPOriginIfNeeded(blink::WebSecurityOrigin::CreateUnique()); 186 request_.AddHTTPOriginIfNeeded(blink::WebSecurityOrigin::CreateUnique());
188 187
189 client_.reset(new ClientImpl(this, callback)); 188 client_.reset(new ClientImpl(this, callback));
190 189
191 loader_ = blink::Platform::Current()->CreateURLLoader(); 190 loader_ = frame->CreateURLLoader();
192 loader_->LoadAsynchronously(request_, client_.get()); 191 loader_->LoadAsynchronously(request_, client_.get());
193 192
194 // No need to hold on to the request; reset it now. 193 // No need to hold on to the request; reset it now.
195 request_ = blink::WebURLRequest(); 194 request_ = blink::WebURLRequest();
196 } 195 }
197 196
198 void ResourceFetcherImpl::SetTimeout(const base::TimeDelta& timeout) { 197 void ResourceFetcherImpl::SetTimeout(const base::TimeDelta& timeout) {
199 DCHECK(loader_); 198 DCHECK(loader_);
200 DCHECK(client_); 199 DCHECK(client_);
201 DCHECK(!client_->completed()); 200 DCHECK(!client_->completed());
202 201
203 timeout_timer_.Start(FROM_HERE, timeout, this, &ResourceFetcherImpl::Cancel); 202 timeout_timer_.Start(FROM_HERE, timeout, this, &ResourceFetcherImpl::Cancel);
204 } 203 }
205 204
206 void ResourceFetcherImpl::OnLoadComplete() { 205 void ResourceFetcherImpl::OnLoadComplete() {
207 timeout_timer_.Stop(); 206 timeout_timer_.Stop();
208 } 207 }
209 208
210 void ResourceFetcherImpl::Cancel() { 209 void ResourceFetcherImpl::Cancel() {
211 loader_->Cancel(); 210 loader_->Cancel();
212 client_->Cancel(); 211 client_->Cancel();
213 } 212 }
214 213
215 } // namespace content 214 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/WebLocalFrameImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698