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

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

Issue 2796323002: Network traffic annotation added to translate_url_fetcher. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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"
11 #include "net/traffic_annotation/network_traffic_annotation.h"
11 #include "net/url_request/url_fetcher.h" 12 #include "net/url_request/url_fetcher.h"
12 #include "net/url_request/url_request_status.h" 13 #include "net/url_request/url_request_status.h"
13 14
14 namespace translate { 15 namespace translate {
15 16
16 namespace { 17 namespace {
17 18
18 // Retry parameter for fetching. 19 // Retry parameter for fetching.
19 const int kMaxRetry = 16; 20 const int kMaxRetry = 16;
20 21
(...skipping 18 matching lines...) Expand all
39 } 40 }
40 41
41 if (retry_count_ >= kMaxRetry) 42 if (retry_count_ >= kMaxRetry)
42 return false; 43 return false;
43 retry_count_++; 44 retry_count_++;
44 45
45 state_ = REQUESTING; 46 state_ = REQUESTING;
46 url_ = url; 47 url_ = url;
47 callback_ = callback; 48 callback_ = callback;
48 49
49 fetcher_ = net::URLFetcher::Create(id_, url_, net::URLFetcher::GET, this); 50 net::NetworkTrafficAnnotationTag traffic_annotation =
Takashi Toyoshima 2017/04/10 09:18:58 rogerm: can you modify following my descriptions t
51 net::DefineNetworkTrafficAnnotation("...", R"(
52 semantics {
53 sender: "..."
Takashi Toyoshima 2017/04/10 09:18:57 sender: "translate"
Ramin Halavati 2017/04/10 13:28:26 Done.
54 description: "..."
Takashi Toyoshima 2017/04/10 09:18:58 description: "Chrome can provide a feature to tran
Ramin Halavati 2017/04/10 13:28:26 Done.
Roger McFarlane (Chromium) 2017/04/10 15:51:03 How about: Chrome can provide translations for th
Takashi Toyoshima 2017/04/11 06:39:26 Thanks, Roger. Ramin, can you update your patch s
Ramin Halavati 2017/04/11 06:57:29 Done.
55 trigger: "..."
Takashi Toyoshima 2017/04/10 09:18:57 trigger: "When Chrome translates a web site, it tr
Ramin Halavati 2017/04/11 06:57:29 Done.
56 data: "..."
Takashi Toyoshima 2017/04/10 09:18:57 data: "Translation library that is obtained via th
Ramin Halavati 2017/04/10 13:28:26 Done.
57 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER
Takashi Toyoshima 2017/04/10 09:18:57 destination: GOOGLE_OWNED_SERVICE
Ramin Halavati 2017/04/10 13:28:26 Done.
58 }
59 policy {
60 cookies_allowed: false
61 setting: "..."
Takashi Toyoshima 2017/04/10 09:18:58 setting: "chrome://settings/ Languages section has
Ramin Halavati 2017/04/10 13:28:26 Done.
62 chrome_policy {
63 [POLICY_NAME] {
64 policy_options {mode: MANDATORY/RECOMMENDED/UNSET}
Takashi Toyoshima 2017/04/10 09:18:58 policy_options: RECOMMENDED (according to http://d
Ramin Halavati 2017/04/10 13:28:26 Thank you. RECOMMENDED=true is the default case. H
Takashi Toyoshima 2017/04/11 06:39:26 Thank you for correction.
65 [POLICY_NAME]: ... //(value to disable it)
Takashi Toyoshima 2017/04/10 09:18:58 POLICY_NAME is TranslateEnabled. I think disabling
Ramin Halavati 2017/04/10 13:28:26 Done.
66 }
67 }
68 policy_exception_justification: "..."
Takashi Toyoshima 2017/04/10 09:18:57 n/a
Ramin Halavati 2017/04/10 13:28:26 Done.
69 })");
70 fetcher_ = net::URLFetcher::Create(id_, url_, net::URLFetcher::GET, this,
71 traffic_annotation);
50 data_use_measurement::DataUseUserData::AttachToFetcher( 72 data_use_measurement::DataUseUserData::AttachToFetcher(
51 fetcher_.get(), data_use_measurement::DataUseUserData::TRANSLATE); 73 fetcher_.get(), data_use_measurement::DataUseUserData::TRANSLATE);
52 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 74 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
53 net::LOAD_DO_NOT_SAVE_COOKIES); 75 net::LOAD_DO_NOT_SAVE_COOKIES);
54 fetcher_->SetRequestContext( 76 fetcher_->SetRequestContext(
55 TranslateDownloadManager::GetInstance()->request_context()); 77 TranslateDownloadManager::GetInstance()->request_context());
56 // Set retry parameter for HTTP status code 5xx. This doesn't work against 78 // Set retry parameter for HTTP status code 5xx. This doesn't work against
57 // 106 (net::ERR_INTERNET_DISCONNECTED) and so on. 79 // 106 (net::ERR_INTERNET_DISCONNECTED) and so on.
58 // TranslateLanguageList handles network status, and implements retry. 80 // TranslateLanguageList handles network status, and implements retry.
59 fetcher_->SetMaxRetriesOn5xx(max_retry_on_5xx_); 81 fetcher_->SetMaxRetriesOn5xx(max_retry_on_5xx_);
(...skipping 16 matching lines...) Expand all
76 } else { 98 } else {
77 state_ = FAILED; 99 state_ = FAILED;
78 } 100 }
79 101
80 // Transfer URLFetcher's ownership before invoking a callback. 102 // Transfer URLFetcher's ownership before invoking a callback.
81 std::unique_ptr<const net::URLFetcher> delete_ptr(fetcher_.release()); 103 std::unique_ptr<const net::URLFetcher> delete_ptr(fetcher_.release());
82 callback_.Run(id_, state_ == COMPLETED, data); 104 callback_.Run(id_, state_ == COMPLETED, data);
83 } 105 }
84 106
85 } // namespace translate 107 } // namespace translate
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698