Chromium Code Reviews| Index: chrome/browser/translate/chrome_translate_client.h |
| diff --git a/chrome/browser/translate/chrome_translate_client.h b/chrome/browser/translate/chrome_translate_client.h |
| index 681f1b1d9b2e533b59cfb43644f5b0640e898427..731ec05fa185897c7aee9590a223635f487ce70e 100644 |
| --- a/chrome/browser/translate/chrome_translate_client.h |
| +++ b/chrome/browser/translate/chrome_translate_client.h |
| @@ -10,6 +10,7 @@ |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/weak_ptr.h" |
| #include "chrome/browser/ui/translate/translate_bubble_model.h" |
| +#include "components/translate/content/browser/browser_cld_data_provider.h" |
| #include "components/translate/content/browser/content_translate_driver.h" |
| #include "components/translate/core/browser/translate_client.h" |
| #include "components/translate/core/browser/translate_step.h" |
| @@ -17,13 +18,6 @@ |
| #include "content/public/browser/web_contents_observer.h" |
| #include "content/public/browser/web_contents_user_data.h" |
| -#if defined(CLD2_DYNAMIC_MODE) |
| -#include "base/basictypes.h" |
| -#include "base/lazy_instance.h" |
| -#include "base/synchronization/lock.h" |
| -#include "base/task_runner.h" |
| -#endif |
| - |
| namespace base { |
| class File; |
| } // namespace base |
| @@ -128,41 +122,6 @@ class ChromeTranslateClient |
| const std::string& translated_lang, |
| TranslateErrors::Type error_type); |
| -#if defined(CLD2_DYNAMIC_MODE) |
| - // Called when we receive ChromeViewHostMsg_NeedCLDData from a renderer. |
| - // If we have already cached the data, responds immediately; else, enqueues |
| - // a HandleCLDDataRequest on the blocking pool to cache the data. |
| - // Acquires and releases s_file_lock_ in a non-blocking manner; queries |
| - // handled while the file is being cached will gracefully and immediately |
| - // fail. |
| - // It is up to the originator of the message to poll again later if required; |
| - // no "negative response" will be generated. |
| - void OnCLDDataRequested(); |
| - |
| - // Invoked on the blocking pool in order to cache the data. When successful, |
| - // immediately responds to the request that initiated OnCLDDataRequested. |
| - // Holds s_file_lock_ while the file is being cached. |
| - static void HandleCLDDataRequest(); |
| - |
| - // If the CLD data is ready, send it to the renderer. Briefly checks the lock. |
| - void MaybeSendCLDDataAvailable(); |
| - |
| - // Sends the renderer a response containing the data file handle. No locking. |
| - void SendCLDDataAvailable(const base::File* handle, |
| - const uint64 data_offset, |
| - const uint64 data_length); |
| - |
| - // The data file, cached as long as the process stays alive. |
| - // We also track the offset at which the data starts, and its length. |
| - static base::File* s_cached_file_; // guarded by file_lock_ |
| - static uint64 s_cached_data_offset_; // guarded by file_lock_ |
| - static uint64 s_cached_data_length_; // guarded by file_lock_ |
| - |
| - // Guards s_cached_file_ |
| - static base::LazyInstance<base::Lock> s_file_lock_; |
| - |
| -#endif |
| - |
| // Shows the translate bubble. |
| void ShowBubble(translate::TranslateStep step, |
| TranslateErrors::Type error_type); |
| @@ -173,9 +132,9 @@ class ChromeTranslateClient |
| ContentTranslateDriver translate_driver_; |
| scoped_ptr<TranslateManager> translate_manager_; |
| - // Necessary for binding the callback to HandleCLDDataRequest on the blocking |
|
Takashi Toyoshima
2014/06/19 10:20:34
Why do you remove these comments for WeakPtrFactor
Andrew Hayden (chromium.org)
2014/06/19 13:40:19
Because this factory was here before HandleCLDData
|
| - // pool and for delaying translation initialization until the page has |
| - // finished loading on a reload. |
| + // Provides CLD data for this process. |
| + scoped_ptr<content::BrowserCldDataProvider> cld_data_provider_; |
| + |
| base::WeakPtrFactory<ChromeTranslateClient> weak_pointer_factory_; |
| DISALLOW_COPY_AND_ASSIGN(ChromeTranslateClient); |