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_script.h" | 5 #include "components/translate/core/browser/translate_script.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/profiler/scoped_profile.h" | 11 #include "base/profiler/scoped_tracker.h" |
12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "components/translate/core/browser/translate_url_fetcher.h" | 15 #include "components/translate/core/browser/translate_url_fetcher.h" |
16 #include "components/translate/core/browser/translate_url_util.h" | 16 #include "components/translate/core/browser/translate_url_util.h" |
17 #include "components/translate/core/common/translate_switches.h" | 17 #include "components/translate/core/common/translate_switches.h" |
18 #include "components/translate/core/common/translate_util.h" | 18 #include "components/translate/core/common/translate_util.h" |
19 #include "google_apis/google_api_keys.h" | 19 #include "google_apis/google_api_keys.h" |
20 #include "grit/components_resources.h" | 20 #include "grit/components_resources.h" |
21 #include "net/base/escape.h" | 21 #include "net/base/escape.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 fetcher_->set_extra_request_header(kRequestHeader); | 111 fetcher_->set_extra_request_header(kRequestHeader); |
112 fetcher_->Request( | 112 fetcher_->Request( |
113 translate_script_url, | 113 translate_script_url, |
114 base::Bind(&TranslateScript::OnScriptFetchComplete, | 114 base::Bind(&TranslateScript::OnScriptFetchComplete, |
115 base::Unretained(this))); | 115 base::Unretained(this))); |
116 } | 116 } |
117 | 117 |
118 | 118 |
119 void TranslateScript::OnScriptFetchComplete( | 119 void TranslateScript::OnScriptFetchComplete( |
120 int id, bool success, const std::string& data) { | 120 int id, bool success, const std::string& data) { |
121 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422577 is fixed. | 121 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422577 is fixed. |
122 tracked_objects::ScopedProfile tracking_profile( | 122 tracked_objects::ScopedTracker tracking_profile( |
123 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 123 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
124 "422577 TranslateScript::OnScriptFetchComplete")); | 124 "422577 TranslateScript::OnScriptFetchComplete")); |
125 | 125 |
126 DCHECK_EQ(kFetcherId, id); | 126 DCHECK_EQ(kFetcherId, id); |
127 | 127 |
128 scoped_ptr<const TranslateURLFetcher> delete_ptr(fetcher_.release()); | 128 scoped_ptr<const TranslateURLFetcher> delete_ptr(fetcher_.release()); |
129 | 129 |
130 if (success) { | 130 if (success) { |
131 DCHECK(data_.empty()); | 131 DCHECK(data_.empty()); |
132 // Insert variable definitions on API Key and security origin. | 132 // Insert variable definitions on API Key and security origin. |
(...skipping 22 matching lines...) Expand all Loading... |
155 | 155 |
156 for (RequestCallbackList::iterator it = callback_list_.begin(); | 156 for (RequestCallbackList::iterator it = callback_list_.begin(); |
157 it != callback_list_.end(); | 157 it != callback_list_.end(); |
158 ++it) { | 158 ++it) { |
159 it->Run(success, data); | 159 it->Run(success, data); |
160 } | 160 } |
161 callback_list_.clear(); | 161 callback_list_.clear(); |
162 } | 162 } |
163 | 163 |
164 } // namespace translate | 164 } // namespace translate |
OLD | NEW |