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

Unified Diff: chrome/renderer/translate/translate_helper.h

Issue 333603002: Modularize Compact Language Detector 2 (CLD2) data sources (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use base/memory/scoped_ptr.h, not base/scoped_ptr.h 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
Index: chrome/renderer/translate/translate_helper.h
diff --git a/chrome/renderer/translate/translate_helper.h b/chrome/renderer/translate/translate_helper.h
index febf6af2f834756bf54af0ea23693d1426917603..f66f9fc2b48cc658adf27229338ac4683e7c3fc1 100644
--- a/chrome/renderer/translate/translate_helper.h
+++ b/chrome/renderer/translate/translate_helper.h
@@ -8,25 +8,24 @@
#include <string>
#include "base/gtest_prod_util.h"
+#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "base/time/time.h"
+#include "components/translate/content/renderer/renderer_cld_data_provider.h"
#include "components/translate/core/common/translate_errors.h"
#include "content/public/renderer/render_view_observer.h"
-
-#if defined(CLD2_DYNAMIC_MODE)
-#include "base/files/file.h"
-#include "base/files/memory_mapped_file.h"
-#include "base/lazy_instance.h"
-#include "ipc/ipc_platform_file.h"
#include "url/gurl.h"
-#endif
namespace blink {
class WebDocument;
class WebFrame;
}
+namespace content {
+class RendererCldDataProvider;
+}
+
// This class deals with page translation.
// There is one TranslateHelper per RenderView.
@@ -162,57 +161,34 @@ class TranslateHelper : public content::RenderViewObserver {
// Method factory used to make calls to TranslatePageImpl.
base::WeakPtrFactory<TranslateHelper> weak_method_factory_;
-#if defined(CLD2_DYNAMIC_MODE)
// Do not ask for CLD data any more.
Takashi Toyoshima 2014/06/23 08:50:01 Now that following methods and members are free fr
Andrew Hayden (chromium.org) 2014/06/23 13:20:36 Yes, good catch. Done. Die, ifdefs, die!
- void CancelCLD2DataFilePolling();
+ void CancelCldDataPolling();
// Invoked when PageCaptured is called prior to obtaining CLD data. This
// method stores the page ID into deferred_page_id_ and COPIES the contents
// of the page, then sets deferred_page_capture_ to true. When CLD data is
- // eventually received (in OnCLDDataAvailable), any deferred request will be
+ // eventually received (in OnCldDataAvailable), any deferred request will be
// "resurrected" and allowed to proceed automatically, assuming that the
// page ID has not changed.
void DeferPageCaptured(const int page_id, const base::string16& contents);
- // Immediately send an IPC request to the browser process to get the CLD
- // data file. In most cases, the file will already exist and we will only
- // poll once; but since the file might need to be downloaded first, poll
- // indefinitely until a ChromeViewMsg_CLDDataAvailable message is received
- // from the browser process.
+ // Start polling for CLD data.
// Polling will automatically halt as soon as the renderer obtains a
// reference to the data file.
- void SendCLD2DataFileRequest(const int delay_millis,
- const int next_delay_millis);
-
- // Invoked when a ChromeViewMsg_CLDDataAvailable message is received from
- // the browser process, providing a file handle for the CLD data file. If a
- // PageCaptured request was previously deferred with DeferPageCaptured and
- // the page ID has not yet changed, the PageCaptured is reinvoked to
- // "resurrect" the language detection pathway.
- void OnCLDDataAvailable(const IPC::PlatformFileForTransit ipc_file_handle,
- const uint64 data_offset,
- const uint64 data_length);
-
- // After receiving data in OnCLDDataAvailable, loads the data into CLD2.
- void LoadCLDDData(base::File file,
- const uint64 data_offset,
- const uint64 data_length);
-
- // A struct that contains the pointer to the CLD mmap. Used so that we can
- // leverage LazyInstance:Leaky to properly scope the lifetime of the mmap.
- struct CLDMmapWrapper {
- CLDMmapWrapper() {
- value = NULL;
- }
- base::MemoryMappedFile* value;
- };
- static base::LazyInstance<CLDMmapWrapper>::Leaky s_cld_mmap_;
+ void SendCldDataRequest(const int delay_millis,
+ const int next_delay_millis);
+
+ // Callback triggered when CLD data becomes available.
+ void OnCldDataAvailable();
+
+ // Provides CLD data for this process.
+ scoped_ptr<translate::RendererCldDataProvider> cld_data_provider_;
// Whether or not polling for CLD2 data has started.
- bool cld2_data_file_polling_started_;
+ bool cld_data_polling_started_;
- // Whether or not CancelCLD2DataFilePolling has been called.
- bool cld2_data_file_polling_canceled_;
+ // Whether or not CancelCldDataPolling has been called.
+ bool cld_data_polling_canceled_;
// Whether or not a PageCaptured event arrived prior to CLD data becoming
// available. If true, deferred_page_id_ contains the most recent page ID
@@ -227,8 +203,6 @@ class TranslateHelper : public content::RenderViewObserver {
// deferred_page_capture_ is true.
base::string16 deferred_contents_;
-#endif
-
DISALLOW_COPY_AND_ASSIGN(TranslateHelper);
};

Powered by Google App Engine
This is Rietveld 408576698