summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host/translation_service.cc
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-10 18:26:11 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-10 18:26:11 +0000
commitef122393f32e86fb5312d373136d99de62274bf8 (patch)
tree645665e7b050dc4810032d7d13ff03a8c45fb53c /chrome/browser/renderer_host/translation_service.cc
parenta6c898d9732a133867229811c43e88274898d93f (diff)
downloadchromium_src-ef122393f32e86fb5312d373136d99de62274bf8.zip
chromium_src-ef122393f32e86fb5312d373136d99de62274bf8.tar.gz
chromium_src-ef122393f32e86fb5312d373136d99de62274bf8.tar.bz2
This CL addresses 2 issues:
- we were not computing the max request text size correctly in some cases (by forgetting the size of the &q= string) causing assertions. - the translate server might send inconsistent response in some cases, this CL makes sure we deal with them. A common case is when sending separators only strings, which we are not doing now anymore. Other more complicated case are less clear. BUG=35055 TEST=Visit www.spiegel.de and translate the page. The page should be translated correctly. Review URL: http://codereview.chromium.org/594023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38637 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/translation_service.cc')
-rw-r--r--chrome/browser/renderer_host/translation_service.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/chrome/browser/renderer_host/translation_service.cc b/chrome/browser/renderer_host/translation_service.cc
index 095802d..6ddef41 100644
--- a/chrome/browser/renderer_host/translation_service.cc
+++ b/chrome/browser/renderer_host/translation_service.cc
@@ -134,6 +134,10 @@ class SendTranslationRequestTask : public CancelableTask {
} // namespace
// static
+// The string is: '&' + kTextParam + '='.
+size_t TranslationService::text_param_length_ = 1 + arraysize(kTextParam) + 1;
+
+// static
base::LazyInstance<std::set<std::string> >
TranslationService::supported_languages_(base::LINKER_INITIALIZED);
@@ -260,8 +264,8 @@ void TranslationService::Translate(int routing_id,
// after we updated the request.
translation_request->send_query_task->Cancel();
translation_request->send_query_task = NULL;
- if (translation_request->query.size() + text.size() >=
- kTextRequestMaxSize) {
+ if (translation_request->query.size() + text.size() +
+ text_param_length_ >= kTextRequestMaxSize) {
// The request would be too big with that last addition of text, send
// the request now. (Single requests too big to be sent in 1 translation
// request are dealt with below.)
@@ -616,6 +620,8 @@ void TranslationService::AddTextToRequestString(std::string* request,
request->append("=1");
}
}
+ // IMPORTANT NOTE: if you make any change below, make sure to reflect them in
+ // text_param_length_ in TranslationService constructor.
request->append("&");
request->append(kTextParam);
request->append("=");