| Index: chrome/browser/translate/translate_tab_helper.h
|
| diff --git a/chrome/browser/translate/translate_tab_helper.h b/chrome/browser/translate/translate_tab_helper.h
|
| index fb18ac1206dba116b0366e70180f98adcd1fe30d..e0581c4794edd25e7e02dda4bf1cb2bbfdbca072 100644
|
| --- a/chrome/browser/translate/translate_tab_helper.h
|
| +++ b/chrome/browser/translate/translate_tab_helper.h
|
| @@ -8,6 +8,10 @@
|
| #include <string>
|
|
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "base/platform_file.h"
|
| +#include "base/synchronization/lock.h"
|
| +#include "base/task_runner.h"
|
| #include "chrome/browser/ui/translate/translate_bubble_model.h"
|
| #include "components/translate/content/browser/content_translate_driver.h"
|
| #include "components/translate/core/common/translate_errors.h"
|
| @@ -92,12 +96,38 @@ class TranslateTabHelper
|
| const std::string& translated_lang,
|
| TranslateErrors::Type error_type);
|
|
|
| + // 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.
|
| + 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.
|
| + void HandleCLDDataRequest();
|
| +
|
| + // Sends the renderer a response containing the data file handle. No locking.
|
| + void SendCLDDataAvailable(const base::PlatformFile handle);
|
| +
|
| + // Necessary for binding the callback to HandleCLDDataRequest on the blocking
|
| + // pool.
|
| + base::WeakPtrFactory<TranslateTabHelper> weak_pointer_factory_;
|
| +
|
| // Shows the translate bubble.
|
| void ShowBubble(TranslateStep step, TranslateErrors::Type error_type);
|
|
|
| ContentTranslateDriver translate_driver_;
|
| scoped_ptr<TranslateManager> translate_manager_;
|
|
|
| + // The data file, cached as long as the process stays alive.
|
| + static base::PlatformFile s_cached_platform_file_; // guarded by file_lock_
|
| +
|
| + // Guards s_cached_platform_file_
|
| + static base::Lock s_file_lock_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(TranslateTabHelper);
|
| };
|
|
|
|
|