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

Side by Side Diff: ios/chrome/browser/net/retryable_url_fetcher.mm

Issue 1861593005: Convert //ios 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "ios/chrome/browser/net/retryable_url_fetcher.h" 5 #import "ios/chrome/browser/net/retryable_url_fetcher.h"
6 6
7 #include <memory>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
10 #include "net/http/http_status_code.h" 11 #include "net/http/http_status_code.h"
11 #include "net/url_request/url_fetcher.h" 12 #include "net/url_request/url_fetcher.h"
12 #include "net/url_request/url_fetcher_delegate.h" 13 #include "net/url_request/url_fetcher_delegate.h"
13 #include "net/url_request/url_request_context_getter.h" 14 #include "net/url_request/url_request_context_getter.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 16
16 @interface RetryableURLFetcher () 17 @interface RetryableURLFetcher ()
17 - (void)urlFetchDidComplete:(const net::URLFetcher*)fetcher; 18 - (void)urlFetchDidComplete:(const net::URLFetcher*)fetcher;
18 @end 19 @end
19 20
20 class URLRequestDelegate : public net::URLFetcherDelegate { 21 class URLRequestDelegate : public net::URLFetcherDelegate {
21 public: 22 public:
22 explicit URLRequestDelegate(RetryableURLFetcher* owner) : owner_(owner) {} 23 explicit URLRequestDelegate(RetryableURLFetcher* owner) : owner_(owner) {}
23 void OnURLFetchComplete(const net::URLFetcher* source) override { 24 void OnURLFetchComplete(const net::URLFetcher* source) override {
24 [owner_ urlFetchDidComplete:source]; 25 [owner_ urlFetchDidComplete:source];
25 } 26 }
26 27
27 private: 28 private:
28 RetryableURLFetcher* owner_; // Weak. 29 RetryableURLFetcher* owner_; // Weak.
29 }; 30 };
30 31
31 @implementation RetryableURLFetcher { 32 @implementation RetryableURLFetcher {
32 scoped_refptr<net::URLRequestContextGetter> requestContextGetter_; 33 scoped_refptr<net::URLRequestContextGetter> requestContextGetter_;
33 scoped_ptr<URLRequestDelegate> fetcherDelegate_; 34 std::unique_ptr<URLRequestDelegate> fetcherDelegate_;
34 scoped_ptr<net::URLFetcher> fetcher_; 35 std::unique_ptr<net::URLFetcher> fetcher_;
35 scoped_ptr<net::BackoffEntry> backoffEntry_; 36 std::unique_ptr<net::BackoffEntry> backoffEntry_;
36 int retryCount_; 37 int retryCount_;
37 id<RetryableURLFetcherDelegate> delegate_; // Weak. 38 id<RetryableURLFetcherDelegate> delegate_; // Weak.
38 } 39 }
39 40
40 - (instancetype) 41 - (instancetype)
41 initWithRequestContextGetter:(net::URLRequestContextGetter*)context 42 initWithRequestContextGetter:(net::URLRequestContextGetter*)context
42 delegate:(id<RetryableURLFetcherDelegate>)delegate 43 delegate:(id<RetryableURLFetcherDelegate>)delegate
43 backoffPolicy:(const net::BackoffEntry::Policy*)policy { 44 backoffPolicy:(const net::BackoffEntry::Policy*)policy {
44 self = [super init]; 45 self = [super init];
45 if (self) { 46 if (self) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 NSString* response = nil; 84 NSString* response = nil;
84 if (success) { 85 if (success) {
85 std::string responseString; 86 std::string responseString;
86 if (fetcher->GetResponseAsString(&responseString)) 87 if (fetcher->GetResponseAsString(&responseString))
87 response = base::SysUTF8ToNSString(responseString); 88 response = base::SysUTF8ToNSString(responseString);
88 } 89 }
89 [delegate_ processSuccessResponse:response]; 90 [delegate_ processSuccessResponse:response];
90 } 91 }
91 92
92 @end 93 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/net/proxy_service_factory.cc ('k') | ios/chrome/browser/net/retryable_url_fetcher_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698