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 #include "components/translate/core/browser/translate_url_fetcher.h" | 5 #include "components/translate/core/browser/translate_url_fetcher.h" |
6 | 6 |
7 #include "components/data_use_measurement/core/data_use_user_data.h" | 7 #include "components/data_use_measurement/core/data_use_user_data.h" |
8 #include "components/translate/core/browser/translate_download_manager.h" | 8 #include "components/translate/core/browser/translate_download_manager.h" |
9 #include "net/base/load_flags.h" | 9 #include "net/base/load_flags.h" |
10 #include "net/http/http_status_code.h" | 10 #include "net/http/http_status_code.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 state_(IDLE), | 24 state_(IDLE), |
25 retry_count_(0) { | 25 retry_count_(0) { |
26 } | 26 } |
27 | 27 |
28 TranslateURLFetcher::~TranslateURLFetcher() { | 28 TranslateURLFetcher::~TranslateURLFetcher() { |
29 } | 29 } |
30 | 30 |
31 bool TranslateURLFetcher::Request( | 31 bool TranslateURLFetcher::Request( |
32 const GURL& url, | 32 const GURL& url, |
33 const TranslateURLFetcher::Callback& callback) { | 33 const TranslateURLFetcher::Callback& callback) { |
34 // This function is not supposed to be called before previous operaion is not | 34 // This function is not supposed to be called if the previous operation is not |
35 // finished. | 35 // finished. |
36 if (state_ == REQUESTING) { | 36 if (state_ == REQUESTING) { |
37 NOTREACHED(); | 37 NOTREACHED(); |
38 return false; | 38 return false; |
39 } | 39 } |
40 | 40 |
41 if (retry_count_ >= kMaxRetry) | 41 if (retry_count_ >= kMaxRetry) |
42 return false; | 42 return false; |
43 retry_count_++; | 43 retry_count_++; |
44 | 44 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } else { | 76 } else { |
77 state_ = FAILED; | 77 state_ = FAILED; |
78 } | 78 } |
79 | 79 |
80 // Transfer URLFetcher's ownership before invoking a callback. | 80 // Transfer URLFetcher's ownership before invoking a callback. |
81 std::unique_ptr<const net::URLFetcher> delete_ptr(fetcher_.release()); | 81 std::unique_ptr<const net::URLFetcher> delete_ptr(fetcher_.release()); |
82 callback_.Run(id_, state_ == COMPLETED, data); | 82 callback_.Run(id_, state_ == COMPLETED, data); |
83 } | 83 } |
84 | 84 |
85 } // namespace translate | 85 } // namespace translate |
OLD | NEW |