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

Side by Side Diff: components/translate/core/browser/translate_url_fetcher.cc

Issue 1117703002: Adjust URLFetcher::Create API so that object is returned as scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unneeded Pass() calls Created 5 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
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 #include "components/translate/core/browser/translate_url_fetcher.h" 5 #include "components/translate/core/browser/translate_url_fetcher.h"
6 6
7 #include "components/translate/core/browser/translate_download_manager.h" 7 #include "components/translate/core/browser/translate_download_manager.h"
8 #include "net/base/load_flags.h" 8 #include "net/base/load_flags.h"
9 #include "net/http/http_status_code.h" 9 #include "net/http/http_status_code.h"
10 #include "net/url_request/url_fetcher.h" 10 #include "net/url_request/url_fetcher.h"
(...skipping 27 matching lines...) Expand all
38 } 38 }
39 39
40 if (retry_count_ >= kMaxRetry) 40 if (retry_count_ >= kMaxRetry)
41 return false; 41 return false;
42 retry_count_++; 42 retry_count_++;
43 43
44 state_ = REQUESTING; 44 state_ = REQUESTING;
45 url_ = url; 45 url_ = url;
46 callback_ = callback; 46 callback_ = callback;
47 47
48 fetcher_.reset(net::URLFetcher::Create( 48 fetcher_ = net::URLFetcher::Create(id_, url_, net::URLFetcher::GET, this);
49 id_,
50 url_,
51 net::URLFetcher::GET,
52 this));
53 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 49 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
54 net::LOAD_DO_NOT_SAVE_COOKIES); 50 net::LOAD_DO_NOT_SAVE_COOKIES);
55 fetcher_->SetRequestContext( 51 fetcher_->SetRequestContext(
56 TranslateDownloadManager::GetInstance()->request_context()); 52 TranslateDownloadManager::GetInstance()->request_context());
57 // Set retry parameter for HTTP status code 5xx. This doesn't work against 53 // Set retry parameter for HTTP status code 5xx. This doesn't work against
58 // 106 (net::ERR_INTERNET_DISCONNECTED) and so on. 54 // 106 (net::ERR_INTERNET_DISCONNECTED) and so on.
59 // TranslateLanguageList handles network status, and implements retry. 55 // TranslateLanguageList handles network status, and implements retry.
60 fetcher_->SetMaxRetriesOn5xx(max_retry_on_5xx_); 56 fetcher_->SetMaxRetriesOn5xx(max_retry_on_5xx_);
61 if (!extra_request_header_.empty()) 57 if (!extra_request_header_.empty())
62 fetcher_->SetExtraRequestHeaders(extra_request_header_); 58 fetcher_->SetExtraRequestHeaders(extra_request_header_);
(...skipping 14 matching lines...) Expand all
77 } else { 73 } else {
78 state_ = FAILED; 74 state_ = FAILED;
79 } 75 }
80 76
81 // Transfer URLFetcher's ownership before invoking a callback. 77 // Transfer URLFetcher's ownership before invoking a callback.
82 scoped_ptr<const net::URLFetcher> delete_ptr(fetcher_.release()); 78 scoped_ptr<const net::URLFetcher> delete_ptr(fetcher_.release());
83 callback_.Run(id_, state_ == COMPLETED, data); 79 callback_.Run(id_, state_ == COMPLETED, data);
84 } 80 }
85 81
86 } // namespace translate 82 } // namespace translate
OLDNEW
« no previous file with comments | « components/suggestions/suggestions_service.cc ('k') | components/update_client/request_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698