Index: components/translate/content/renderer/renderer_cld_data_provider.h |
diff --git a/components/translate/content/renderer/renderer_cld_data_provider.h b/components/translate/content/renderer/renderer_cld_data_provider.h |
index 4da053a8a7e98e4e4d7f15c8241325673551c7bd..367da49f740a79b4e1aa9ce45b9275a1aaf9defd 100644 |
--- a/components/translate/content/renderer/renderer_cld_data_provider.h |
+++ b/components/translate/content/renderer/renderer_cld_data_provider.h |
@@ -12,10 +12,6 @@ namespace IPC { |
class Message; |
} |
-namespace content { |
-class RenderViewObserver; |
-} |
- |
namespace translate { |
// Renderer-side interface responsible for providing CLD data. |
@@ -29,6 +25,7 @@ namespace translate { |
// constant from ipc_message_start.h |
class RendererCldDataProvider : public IPC::Listener { |
public: |
+ RendererCldDataProvider(); |
virtual ~RendererCldDataProvider() {} |
// (Inherited from IPC::Listener) |
@@ -39,33 +36,44 @@ class RendererCldDataProvider : public IPC::Listener { |
// loop thread. |
// This method is defined as virtual in order to force the implementation to |
// define the specific IPC message(s) that it handles. |
- virtual bool OnMessageReceived(const IPC::Message&) = 0; |
+ virtual bool OnMessageReceived(const IPC::Message&) OVERRIDE; |
// Invoked by the renderer process to request that CLD data be obtained and |
// that CLD be initialized with it. The implementation is expected to |
// communicate with the paired BrowserCldDataProvider implementation on the |
// browser side. |
// This method must be invoked on the message loop thread. |
- virtual void SendCldDataRequest() = 0; |
+ virtual void SendCldDataRequest(); |
Andrew Hayden (chromium.org)
2014/09/26 10:22:49
Document the default behavior of all the functions
Andrew Hayden (chromium.org)
2014/10/28 15:18:39
Done.
|
// Convenience method that tracks whether or not CLD data is available. |
// This method can be used in the absence of a callback (i.e., if the caller |
// wants a simple way to check the state of CLD data availability without |
// keeping a separate boolean flag tripped by a callback). |
- virtual bool IsCldDataAvailable() = 0; |
+ virtual bool IsCldDataAvailable(); |
// Sets a callback that will be invoked when CLD data is successfully |
// obtained from the paired BrowserCldDataProvider implementation on the |
// browser side, after CLD has been successfully initialized. |
// Both the initialization of CLD2 as well as the invocation of the callback |
// must happen on the message loop thread. |
- virtual void SetCldAvailableCallback(base::Callback<void(void)>) = 0; |
-}; |
+ virtual void SetCldAvailableCallback(base::Callback<void(void)>); |
-// Static factory function defined by the implementation that produces a new |
-// provider for the specified render view host. |
-RendererCldDataProvider* CreateRendererCldDataProviderFor( |
- content::RenderViewObserver*); |
+ // Sets the instance of the provider used by this process, optionally |
+ // overwriting the previous value. Embedders and narrow use-cases (such as |
+ // shells and test code) should use the overwrite capability, while generic |
+ // code should not. |
+ // If another instance is already set, it is immediately destroyed prior to |
+ // updating the global pointer to point to the specified instance. |
+ static void Set(RendererCldDataProvider* instance, bool overwrite); |
+ |
+ // Returns true if and only if the current instance for this process is not |
+ // NULL. |
+ static bool IsInitialized(); |
+ |
+ // Returns the instance of the provider previously set by Set(...). |
+ // If no instance has been set, a default no-op provider will be returned. |
+ static RendererCldDataProvider* Get(); |
+}; |
} // namespace translate |