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

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

Issue 2831033002: Use unique_ptr for Platform::CreateURLLoader (Closed)
Patch Set: Created 3 years, 8 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"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 DCHECK(!request_.IsNull()); 177 DCHECK(!request_.IsNull());
178 if (!request_.HttpBody().IsNull()) 178 if (!request_.HttpBody().IsNull())
179 DCHECK_NE("GET", request_.HttpMethod().Utf8()) << "GETs can't have bodies."; 179 DCHECK_NE("GET", request_.HttpMethod().Utf8()) << "GETs can't have bodies.";
180 180
181 request_.SetRequestContext(request_context); 181 request_.SetRequestContext(request_context);
182 request_.SetFirstPartyForCookies(frame->GetDocument().FirstPartyForCookies()); 182 request_.SetFirstPartyForCookies(frame->GetDocument().FirstPartyForCookies());
183 request_.AddHTTPOriginIfNeeded(blink::WebSecurityOrigin::CreateUnique()); 183 request_.AddHTTPOriginIfNeeded(blink::WebSecurityOrigin::CreateUnique());
184 184
185 client_.reset(new ClientImpl(this, callback)); 185 client_.reset(new ClientImpl(this, callback));
186 186
187 loader_.reset(blink::Platform::Current()->CreateURLLoader()); 187 loader_ = blink::Platform::Current()->CreateURLLoader();
188 loader_->LoadAsynchronously(request_, client_.get()); 188 loader_->LoadAsynchronously(request_, client_.get());
189 189
190 // No need to hold on to the request; reset it now. 190 // No need to hold on to the request; reset it now.
191 request_ = blink::WebURLRequest(); 191 request_ = blink::WebURLRequest();
192 } 192 }
193 193
194 void ResourceFetcherImpl::SetTimeout(const base::TimeDelta& timeout) { 194 void ResourceFetcherImpl::SetTimeout(const base::TimeDelta& timeout) {
195 DCHECK(loader_); 195 DCHECK(loader_);
196 DCHECK(client_); 196 DCHECK(client_);
197 DCHECK(!client_->completed()); 197 DCHECK(!client_->completed());
198 198
199 timeout_timer_.Start(FROM_HERE, timeout, this, &ResourceFetcherImpl::Cancel); 199 timeout_timer_.Start(FROM_HERE, timeout, this, &ResourceFetcherImpl::Cancel);
200 } 200 }
201 201
202 void ResourceFetcherImpl::OnLoadComplete() { 202 void ResourceFetcherImpl::OnLoadComplete() {
203 timeout_timer_.Stop(); 203 timeout_timer_.Stop();
204 } 204 }
205 205
206 void ResourceFetcherImpl::Cancel() { 206 void ResourceFetcherImpl::Cancel() {
207 loader_->Cancel(); 207 loader_->Cancel();
208 client_->Cancel(); 208 client_->Cancel();
209 } 209 }
210 210
211 } // namespace content 211 } // namespace content
OLDNEW
« no previous file with comments | « content/ppapi_plugin/ppapi_blink_platform_impl.cc ('k') | content/renderer/renderer_blink_platform_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698