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

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

Issue 187393005: Make it possible to read CLD data from a file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Marcus' and Jochen's comments Created 6 years, 9 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 88dd518cf69ab98019089428ef253b0121894002..0737312945f3d7e67d0cb071f67be55037e00ab7 100644
--- a/chrome/renderer/translate/translate_helper.h
+++ b/chrome/renderer/translate/translate_helper.h
@@ -12,6 +12,8 @@
#include "base/time/time.h"
#include "components/translate/core/common/translate_errors.h"
#include "content/public/renderer/render_view_observer.h"
+#include "ipc/ipc_platform_file.h"
+#include "url/gurl.h"
namespace blink {
class WebDocument;
@@ -29,6 +31,11 @@ class TranslateHelper : public content::RenderViewObserver {
// Informs us that the page's text has been extracted.
void PageCaptured(int page_id, const base::string16& contents);
+ // Lets the translation system know that we are preparing to navigate to
+ // the specified URL. If there is anything that can or should be done before
+ // this URL loads, this is the time to prepare for it.
+ void PrepareForUrl(const GURL& url);
+
protected:
// The following methods are protected so they can be overridden in
// unit-tests.
@@ -148,6 +155,56 @@ class TranslateHelper : public content::RenderViewObserver {
// Method factory used to make calls to TranslatePageImpl.
base::WeakPtrFactory<TranslateHelper> weak_method_factory_;
+#if defined(CLD2_DYNAMIC_MODE)
palmer 2014/03/13 17:59:50 The IPC declaration and handlers should also be be
Andrew Hayden (chromium.org) 2014/03/13 23:20:21 Done.
+ // Do not ask for CLD data any more.
+ void CancelCLD2DataFilePolling();
+
+ // Whether or not we have started polling for CLD2 data
+ bool cld2_data_file_polling_started;
+
+ // Whether or not CancelCLD2DataFilePolling has been called
+ bool cld2_data_file_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
+ // and deferred_contents_ contains the most recent contents.
+ bool deferred_page_capture_;
+
+ // The ID of the page most recently reported to PageCaptured if
+ // deferred_page_capture_ is true.
+ int deferred_page_id_;
+
+ // The contents of the page most recently reported to PageCaptured if
+ // deferred_page_capture_ is true.
+ base::string16 deferred_contents_;
+
+ // 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, and sets deferred_page_capture_ to true. When CLD data is
+ // 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, we must
+ // poll indefinitely until a ChromeViewMsg_CLDDataAvailable message is
+ // received from the browser process.
+ // Polling will automatically halt as soon as the renderer obtains a
+ // reference to the data file.
+ void SendCLD2DataFileRequest(int delay_millis, int next_delay_millis);
+
+ // Invoked when a ChromeViewMsg_CLDDataAvailable message is received from
+ // the browser process, providing us with 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(IPC::PlatformFileForTransit ipc_file_handle);
+
+ // After receiving data in OnCLDDataAvailable, loads the data into CLD2.
+ void LoadCLDDData(IPC::PlatformFileForTransit ipc_file_handle);
+#endif
DISALLOW_COPY_AND_ASSIGN(TranslateHelper);
};

Powered by Google App Engine
This is Rietveld 408576698