| OLD | NEW |
| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "net/http/http_status_code.h" | 10 #include "net/http/http_status_code.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 backoffEntry_.reset(new net::BackoffEntry(policy)); | 51 backoffEntry_.reset(new net::BackoffEntry(policy)); |
| 52 } | 52 } |
| 53 return self; | 53 return self; |
| 54 } | 54 } |
| 55 | 55 |
| 56 - (void)startFetch { | 56 - (void)startFetch { |
| 57 DCHECK(requestContextGetter_.get()); | 57 DCHECK(requestContextGetter_.get()); |
| 58 GURL url(base::SysNSStringToUTF8([delegate_ urlToFetch])); | 58 GURL url(base::SysNSStringToUTF8([delegate_ urlToFetch])); |
| 59 if (url.is_valid()) { | 59 if (url.is_valid()) { |
| 60 fetcherDelegate_.reset(new URLRequestDelegate(self)); | 60 fetcherDelegate_.reset(new URLRequestDelegate(self)); |
| 61 fetcher_.reset(net::URLFetcher::Create(url, net::URLFetcher::GET, | 61 fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, |
| 62 fetcherDelegate_.get())); | 62 fetcherDelegate_.get()); |
| 63 fetcher_->SetRequestContext(requestContextGetter_.get()); | 63 fetcher_->SetRequestContext(requestContextGetter_.get()); |
| 64 fetcher_->Start(); | 64 fetcher_->Start(); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 - (int)failureCount { | 68 - (int)failureCount { |
| 69 return backoffEntry_ ? backoffEntry_->failure_count() : 0; | 69 return backoffEntry_ ? backoffEntry_->failure_count() : 0; |
| 70 } | 70 } |
| 71 | 71 |
| 72 - (void)urlFetchDidComplete:(const net::URLFetcher*)fetcher { | 72 - (void)urlFetchDidComplete:(const net::URLFetcher*)fetcher { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 83 NSString* response = nil; | 83 NSString* response = nil; |
| 84 if (success) { | 84 if (success) { |
| 85 std::string responseString; | 85 std::string responseString; |
| 86 if (fetcher->GetResponseAsString(&responseString)) | 86 if (fetcher->GetResponseAsString(&responseString)) |
| 87 response = base::SysUTF8ToNSString(responseString); | 87 response = base::SysUTF8ToNSString(responseString); |
| 88 } | 88 } |
| 89 [delegate_ processSuccessResponse:response]; | 89 [delegate_ processSuccessResponse:response]; |
| 90 } | 90 } |
| 91 | 91 |
| 92 @end | 92 @end |
| OLD | NEW |