diff options
author | andrewhayden@chromium.org <andrewhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-30 07:13:42 +0000 |
---|---|---|
committer | andrewhayden@chromium.org <andrewhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-30 07:13:42 +0000 |
commit | 4cb546ffe52d9d0da3aeca98ed4f8b3b8c79bf14 (patch) | |
tree | ee7ed6c586efd5f3d4a4d6c9683d7a855cb041b5 /components/translate | |
parent | 479e392d87a50de9a8c6cd78b35e317a4abfe768 (diff) | |
download | chromium_src-4cb546ffe52d9d0da3aeca98ed4f8b3b8c79bf14.zip chromium_src-4cb546ffe52d9d0da3aeca98ed4f8b3b8c79bf14.tar.gz chromium_src-4cb546ffe52d9d0da3aeca98ed4f8b3b8c79bf14.tar.bz2 |
Add a new "Configure" mechanism to CLD browser-side data interfaces.
This allows test code to be included all the time, regardless of whether a
non-static CLD build is in use. It also decouples sources from needing to
include an implementation-specific header to configure CLD, which eliminates
much of the need for the "#if defined" statements in code. Coupled with
the new CldDataSource (see related bug), this will allow a significant
refactoring of the build logic which will make it possible to build
chrome_shell and other targets with target-specific CLD configurations.
BUG=367239
TBR=toyoshim@chromium.org
Review URL: https://codereview.chromium.org/424053002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@286430 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/translate')
4 files changed, 34 insertions, 17 deletions
diff --git a/components/translate/content/browser/browser_cld_data_provider.h b/components/translate/content/browser/browser_cld_data_provider.h index ce6022d..4e8776a 100644 --- a/components/translate/content/browser/browser_cld_data_provider.h +++ b/components/translate/content/browser/browser_cld_data_provider.h @@ -5,6 +5,9 @@ #ifndef COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_H_ #define COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_H_ +#include <string> + +#include "base/files/file_path.h" #include "ipc/ipc_listener.h" namespace IPC { @@ -59,6 +62,21 @@ class BrowserCldDataProvider : public IPC::Listener { BrowserCldDataProvider* CreateBrowserCldDataProviderFor( content::WebContents*); +// For data sources that support a separate CLD data file, configures the path +// of that data file. +// +// The 'component' and 'standalone' data sources need this method to be called +// in order to locate the CLD data on disk. +// If the data source doesn't need or doesn't support such configuration, this +// function should do nothing. This is the case for, e.g., the static data +// source. +void SetCldDataFilePath(const base::FilePath& path); + +// Returns the path most recently set by SetCldDataFilePath. The initial value +// prior to any such call is the empty path. If the data source doesn't support +// a data file, returns the empty path. +base::FilePath GetCldDataFilePath(); + } // namespace translate -#endif // COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATAP_PROVIDER_H_ +#endif // COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_H_ diff --git a/components/translate/content/browser/data_file_browser_cld_data_provider.cc b/components/translate/content/browser/data_file_browser_cld_data_provider.cc index e2eba93..70648e9 100644 --- a/components/translate/content/browser/data_file_browser_cld_data_provider.cc +++ b/components/translate/content/browser/data_file_browser_cld_data_provider.cc @@ -44,8 +44,7 @@ BrowserCldDataProvider* CreateBrowserCldDataProviderFor( return new DataFileBrowserCldDataProvider(web_contents); } -void DataFileBrowserCldDataProvider::SetCldDataFilePath( - const base::FilePath& path) { +void SetCldDataFilePath(const base::FilePath& path) { VLOG(1) << "Setting CLD data file path to: " << path.value(); base::AutoLock lock(g_file_lock_.Get()); if (g_cached_filepath == path) @@ -57,7 +56,7 @@ void DataFileBrowserCldDataProvider::SetCldDataFilePath( g_cached_data_offset = -1; } -base::FilePath DataFileBrowserCldDataProvider::GetCldDataFilePath() { +base::FilePath GetCldDataFilePath() { base::AutoLock lock(g_file_lock_.Get()); return g_cached_filepath; } diff --git a/components/translate/content/browser/data_file_browser_cld_data_provider.h b/components/translate/content/browser/data_file_browser_cld_data_provider.h index 9344bd7..2bfca1d 100644 --- a/components/translate/content/browser/data_file_browser_cld_data_provider.h +++ b/components/translate/content/browser/data_file_browser_cld_data_provider.h @@ -23,19 +23,6 @@ class DataFileBrowserCldDataProvider : public BrowserCldDataProvider { virtual void OnCldDataRequest() OVERRIDE; virtual void SendCldDataResponse() OVERRIDE; - // Sets the data file that this data provider will use to fulfill requests. - // This method does nothing if the specified path is equal to the path that - // is already configured. Otherwise, the specified path is cached and - // subsequent requests for data will attempt to load CLD data from the file - // at the specified path. - // This method is threadsafe. - static void SetCldDataFilePath(const base::FilePath& filePath); - - // Returns the path most recently set by SetDataFilePath. The initial value - // prior to any such call is the empty path. - // This method is threadsafe. - static base::FilePath GetCldDataFilePath(); - private: void SendCldDataResponseInternal(const base::File*, const uint64, diff --git a/components/translate/content/browser/static_browser_cld_data_provider.cc b/components/translate/content/browser/static_browser_cld_data_provider.cc index a5d8a79..675db42 100644 --- a/components/translate/content/browser/static_browser_cld_data_provider.cc +++ b/components/translate/content/browser/static_browser_cld_data_provider.cc @@ -20,6 +20,19 @@ BrowserCldDataProvider* CreateBrowserCldDataProviderFor( return new StaticBrowserCldDataProvider(); } +void SetCldDataFilePath(const base::FilePath& path) { + LOG(WARNING) << "Not supported: SetCldDataFilePath"; + return; +} + +base::FilePath GetCldDataFilePath() { + return base::FilePath(); // empty path +} + +void ConfigureBrowserCldDataProvider(const void* config) { + // No-op: data is statically linked +} + StaticBrowserCldDataProvider::StaticBrowserCldDataProvider() { } |