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/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" |
11 #include "net/url_request/url_request_status.h" | 11 #include "net/url_request/url_request_status.h" |
12 | 12 |
| 13 namespace translate { |
| 14 |
13 namespace { | 15 namespace { |
14 | 16 |
15 // Retry parameter for fetching. | 17 // Retry parameter for fetching. |
16 const int kMaxRetry = 16; | 18 const int kMaxRetry = 16; |
17 | 19 |
18 } // namespace | 20 } // namespace |
19 | 21 |
20 TranslateURLFetcher::TranslateURLFetcher(int id) : id_(id), | 22 TranslateURLFetcher::TranslateURLFetcher(int id) : id_(id), |
21 state_(IDLE), | 23 state_(IDLE), |
22 retry_count_(0) { | 24 retry_count_(0) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 state_ = COMPLETED; | 75 state_ = COMPLETED; |
74 source->GetResponseAsString(&data); | 76 source->GetResponseAsString(&data); |
75 } else { | 77 } else { |
76 state_ = FAILED; | 78 state_ = FAILED; |
77 } | 79 } |
78 | 80 |
79 // Transfer URLFetcher's ownership before invoking a callback. | 81 // Transfer URLFetcher's ownership before invoking a callback. |
80 scoped_ptr<const net::URLFetcher> delete_ptr(fetcher_.release()); | 82 scoped_ptr<const net::URLFetcher> delete_ptr(fetcher_.release()); |
81 callback_.Run(id_, state_ == COMPLETED, data); | 83 callback_.Run(id_, state_ == COMPLETED, data); |
82 } | 84 } |
| 85 |
| 86 } // namespace translate |
OLD | NEW |