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..e248f87525b813c2ccbe29be63048bb9b20a8a59 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,6 +96,36 @@ class TranslateTabHelper |
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. |
+ 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_; |
+ |
+ // 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_; |
bulach
2014/03/14 15:30:58
statics can only be used for PODs, this need to be
Andrew Hayden (chromium.org)
2014/03/20 16:12:53
Done.
|
+#endif |
+ |
// Shows the translate bubble. |
void ShowBubble(TranslateStep step, TranslateErrors::Type error_type); |