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

Side by Side Diff: components/dom_distiller/core/distiller_url_fetcher.cc

Issue 1879613003: Convert //components/dom_distiller from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/dom_distiller/core/distiller_url_fetcher.h" 5 #include "components/dom_distiller/core/distiller_url_fetcher.h"
6 6
7 #include "net/http/http_status_code.h" 7 #include "net/http/http_status_code.h"
8 #include "net/url_request/url_fetcher.h" 8 #include "net/url_request/url_fetcher.h"
9 #include "net/url_request/url_fetcher_delegate.h" 9 #include "net/url_request/url_fetcher_delegate.h"
10 #include "net/url_request/url_request_context_getter.h" 10 #include "net/url_request/url_request_context_getter.h"
(...skipping 25 matching lines...) Expand all
36 36
37 void DistillerURLFetcher::FetchURL(const std::string& url, 37 void DistillerURLFetcher::FetchURL(const std::string& url,
38 const URLFetcherCallback& callback) { 38 const URLFetcherCallback& callback) {
39 // Don't allow a fetch if one is pending. 39 // Don't allow a fetch if one is pending.
40 DCHECK(!url_fetcher_ || !url_fetcher_->GetStatus().is_io_pending()); 40 DCHECK(!url_fetcher_ || !url_fetcher_->GetStatus().is_io_pending());
41 callback_ = callback; 41 callback_ = callback;
42 url_fetcher_ = CreateURLFetcher(context_getter_, url); 42 url_fetcher_ = CreateURLFetcher(context_getter_, url);
43 url_fetcher_->Start(); 43 url_fetcher_->Start();
44 } 44 }
45 45
46 scoped_ptr<URLFetcher> DistillerURLFetcher::CreateURLFetcher( 46 std::unique_ptr<URLFetcher> DistillerURLFetcher::CreateURLFetcher(
47 net::URLRequestContextGetter* context_getter, 47 net::URLRequestContextGetter* context_getter,
48 const std::string& url) { 48 const std::string& url) {
49 scoped_ptr<net::URLFetcher> fetcher = 49 std::unique_ptr<net::URLFetcher> fetcher =
50 URLFetcher::Create(GURL(url), URLFetcher::GET, this); 50 URLFetcher::Create(GURL(url), URLFetcher::GET, this);
51 fetcher->SetRequestContext(context_getter); 51 fetcher->SetRequestContext(context_getter);
52 static const int kMaxRetries = 5; 52 static const int kMaxRetries = 5;
53 fetcher->SetMaxRetriesOn5xx(kMaxRetries); 53 fetcher->SetMaxRetriesOn5xx(kMaxRetries);
54 return fetcher; 54 return fetcher;
55 } 55 }
56 56
57 void DistillerURLFetcher::OnURLFetchComplete( 57 void DistillerURLFetcher::OnURLFetchComplete(
58 const URLFetcher* source) { 58 const URLFetcher* source) {
59 std::string response; 59 std::string response;
60 if (source && source->GetStatus().is_success() && 60 if (source && source->GetStatus().is_success() &&
61 source->GetResponseCode() == net::HTTP_OK) { 61 source->GetResponseCode() == net::HTTP_OK) {
62 // Only copy over the data if the request was successful. Insert 62 // Only copy over the data if the request was successful. Insert
63 // an empty string into the proto otherwise. 63 // an empty string into the proto otherwise.
64 source->GetResponseAsString(&response); 64 source->GetResponseAsString(&response);
65 } 65 }
66 callback_.Run(response); 66 callback_.Run(response);
67 } 67 }
68 68
69 } // namespace dom_distiller 69 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/core/distiller_url_fetcher.h ('k') | components/dom_distiller/core/distiller_url_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698