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

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

Issue 461633002: Refactor language detection logic to allow non-static CLD data sources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix linux/mac/windows compile issues Created 6 years, 2 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/browser/translate/cld_data_harness_factory.h
diff --git a/chrome/browser/translate/cld_data_harness_factory.h b/chrome/browser/translate/cld_data_harness_factory.h
new file mode 100644
index 0000000000000000000000000000000000000000..29d19718f06ceda4953f16c8b1d0e67e95400cfa
--- /dev/null
+++ b/chrome/browser/translate/cld_data_harness_factory.h
@@ -0,0 +1,52 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_TRANSLATE_CLD_DATA_HARNESS_FACTORY_H_
+#define CHROME_BROWSER_TRANSLATE_CLD_DATA_HARNESS_FACTORY_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/translate/cld_data_harness.h"
+
+namespace test {
+
+// Testing class that allows embedders to inject an arbitrary CldDataHarness
+// into the runtime by definining a subclass of CldDataHarnessFactory and
+// setting the global instance of it with Set(CldDataHarnessFactory*).
+// Chromium code should use the factory instance returned by Get() to obtain
+// CldDataHarness instances.
+class CldDataHarnessFactory {
+ public:
+ CldDataHarnessFactory() {}
+ virtual ~CldDataHarnessFactory() {}
+
+ // Create a new CldDataHarness.
+ // The default implementation returns a simple CldDataHarness, which is
+ // likely to be incorrect for most non-static CLD use cases.
+ virtual scoped_ptr<CldDataHarness> CreateCldDataHarness();
Takashi Toyoshima 2014/11/06 14:34:29 I feel Create() is enough good name for this since
Andrew Hayden (chromium.org) 2014/11/10 14:06:35 Please see my comments in browser_cld_data_provide
Takashi Toyoshima 2014/11/11 07:16:36 I see.
+
+ // Sets the CldDataHarnessFactory instance for the process.
+ static void Set(CldDataHarnessFactory* instance);
+
+ // Returns the CldDataHarnessFactory instance previously set for the process.
+ static CldDataHarnessFactory* Get();
+
+ // Fetch the global instance of the "static" factory that produces a harness
+ // suitable for use with the "static" CLD data source.
+ static CldDataHarnessFactory* GetStaticDataHarnessFactory();
+
+ // Fetch the global instance of the "standalone" factory that produces a
+ // harness suitable for use with the "standalone" CLD data source.
+ static CldDataHarnessFactory* GetStandaloneDataHarnessFactory();
+
+ // Fetch the global instance of the "component" factory that produces a
+ // harness suitable for use with the "component" CLD data source.
+ static CldDataHarnessFactory* GetComponentDataHarnessFactory();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CldDataHarnessFactory);
+};
+} // namespace test
+
+#endif // CHROME_BROWSER_TRANSLATE_CLD_DATA_HARNESS_FACTORY_H_

Powered by Google App Engine
This is Rietveld 408576698