OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/content/renderer/translate_helper.h" | 5 #include "components/translate/content/renderer/translate_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 AdjustDelay(kTranslateStatusCheckDelayMs)); | 503 AdjustDelay(kTranslateStatusCheckDelayMs)); |
504 } | 504 } |
505 | 505 |
506 void TranslateHelper::TranslatePageImpl(int page_seq_no, int count) { | 506 void TranslateHelper::TranslatePageImpl(int page_seq_no, int count) { |
507 DCHECK_LT(count, kMaxTranslateInitCheckAttempts); | 507 DCHECK_LT(count, kMaxTranslateInitCheckAttempts); |
508 if (page_seq_no_ != page_seq_no) | 508 if (page_seq_no_ != page_seq_no) |
509 return; | 509 return; |
510 | 510 |
511 if (!IsTranslateLibReady()) { | 511 if (!IsTranslateLibReady()) { |
512 // The library is not ready, try again later, unless we have tried several | 512 // The library is not ready, try again later, unless we have tried several |
513 // times unsucessfully already. | 513 // times unsuccessfully already. |
514 if (++count >= kMaxTranslateInitCheckAttempts) { | 514 if (++count >= kMaxTranslateInitCheckAttempts) { |
515 NotifyBrowserTranslationFailed(TranslateErrors::INITIALIZATION_ERROR); | 515 NotifyBrowserTranslationFailed(TranslateErrors::INITIALIZATION_ERROR); |
516 return; | 516 return; |
517 } | 517 } |
518 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 518 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
519 FROM_HERE, | 519 FROM_HERE, |
520 base::Bind(&TranslateHelper::TranslatePageImpl, | 520 base::Bind(&TranslateHelper::TranslatePageImpl, |
521 weak_method_factory_.GetWeakPtr(), page_seq_no, count), | 521 weak_method_factory_.GetWeakPtr(), page_seq_no, count), |
522 AdjustDelay(count * kTranslateInitCheckDelayMs)); | 522 AdjustDelay(count * kTranslateInitCheckDelayMs)); |
523 return; | 523 return; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 // this, everything should start being ON_TIME. This should never run more | 633 // this, everything should start being ON_TIME. This should never run more |
634 // than twice in a page load, under any conditions. | 634 // than twice in a page load, under any conditions. |
635 // Also note that language detection is triggered off of a delay AFTER the | 635 // Also note that language detection is triggered off of a delay AFTER the |
636 // page load completed event has fired, making this very much off the critical | 636 // page load completed event has fired, making this very much off the critical |
637 // path. | 637 // path. |
638 content::RenderThread::Get()->UpdateHistograms( | 638 content::RenderThread::Get()->UpdateHistograms( |
639 content::kHistogramSynchronizerReservedSequenceNumber); | 639 content::kHistogramSynchronizerReservedSequenceNumber); |
640 } | 640 } |
641 | 641 |
642 } // namespace translate | 642 } // namespace translate |
OLD | NEW |