Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4401)

Unified Diff: chrome/browser/translate/chrome_translate_client.h

Issue 333603002: Modularize Compact Language Detector 2 (CLD2) data sources (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge https://codereview.chromium.org/326383005 Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/policy/policy_browsertest.cc ('k') | chrome/browser/translate/chrome_translate_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1b475cd400c277de85ef68ba5b1b2949bed49da8 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
@@ -108,7 +102,6 @@ class ChromeTranslateClient
private:
explicit ChromeTranslateClient(content::WebContents* web_contents);
friend class content::WebContentsUserData<ChromeTranslateClient>;
- friend class test::ScopedCLDDynamicDataHarness; // For cleaning static state.
// content::WebContentsObserver implementation.
virtual void NavigationEntryCommitted(
@@ -128,41 +121,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 +131,9 @@ class ChromeTranslateClient
ContentTranslateDriver translate_driver_;
scoped_ptr<TranslateManager> translate_manager_;
- // Necessary for binding the callback to HandleCLDDataRequest on the blocking
- // pool and for delaying translation initialization until the page has
- // finished loading on a reload.
+ // Provides CLD data for this process.
+ scoped_ptr<translate::BrowserCldDataProvider> cld_data_provider_;
+
base::WeakPtrFactory<ChromeTranslateClient> weak_pointer_factory_;
DISALLOW_COPY_AND_ASSIGN(ChromeTranslateClient);
« no previous file with comments | « chrome/browser/policy/policy_browsertest.cc ('k') | chrome/browser/translate/chrome_translate_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698