Chromium Code Reviews| Index: components/translate/content/browser/browser_cld_data_provider.h | 
| diff --git a/components/translate/content/browser/browser_cld_data_provider.h b/components/translate/content/browser/browser_cld_data_provider.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..1f7dd25b046e85cf4018f49ecd8ee85aee196767 | 
| --- /dev/null | 
| +++ b/components/translate/content/browser/browser_cld_data_provider.h | 
| @@ -0,0 +1,56 @@ | 
| +// 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 CONTENT_PUBLIC_BROWSER_BROWSER_CLD_DATA_PROVIDER_H_ | 
| 
 
Takashi Toyoshima
2014/06/19 10:20:34
These macro names should be updated to follow the
 
Andrew Hayden (chromium.org)
2014/06/19 13:40:19
Done.
 
 | 
| +#define CONTENT_PUBLIC_BROWSER_BROWSER_CLD_DATA_PROVIDER_H_ | 
| + | 
| +#include "content/public/browser/render_view_host.h" | 
| 
 
Takashi Toyoshima
2014/06/19 10:20:34
Forward declaration is enough for content::RenderV
 
Andrew Hayden (chromium.org)
2014/06/19 13:40:19
Done.
 
 | 
| +#include "ipc/ipc_listener.h" | 
| +#include "ipc/ipc_message.h" | 
| 
 
Takashi Toyoshima
2014/06/19 10:20:34
Forward declaration is enough for IPC::Message.
 
Andrew Hayden (chromium.org)
2014/06/19 13:40:20
Done.
 
 | 
| + | 
| +namespace content { | 
| + | 
| +// Browser-side interface responsible for providing CLD data. | 
| +// The implementation must be paired with a renderer-side implementation of | 
| +// the RendererCldDataProvider class: | 
| +// | 
| +// content/public/renderer/renderer_cld_data_provider.h | 
| +// | 
| +// ... and the glue between them is typically a pair of request/response IPC | 
| +// messages using the CldDataProviderMsgStart IPCMessageStart enumerated | 
| +// constant from ipc_message_start.h | 
| +class BrowserCldDataProvider : public IPC::Listener { | 
| + public: | 
| + // (Inherited from IPC::Listener) | 
| 
 
Takashi Toyoshima
2014/06/19 10:20:34
'<class name> implementation:' is a common style f
 
Andrew Hayden (chromium.org)
2014/06/19 13:40:19
Done.
 
 | 
| + // If the specified message is a request for CLD data, invokes | 
| + // OnCldDataRequest() and returns true. In all other cases, this method does | 
| + // nothing. 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&); | 
| 
 
Takashi Toyoshima
2014/06/19 10:20:34
OVERRIDE
 
Andrew Hayden (chromium.org)
2014/06/19 13:40:20
Done.
 
 | 
| + | 
| + // Called when the browser process receives an appropriate message in | 
| + // OnMessageReceived, above. The implementation should attempt to locate | 
| + // the CLD data, cache any metadata required for accessing that data, and | 
| + // ultimately trigger a response by invoking SendCldDataResponse. | 
| + // | 
| + // The renderer process may poll for data, in which case this method may be | 
| + // repeatedly invoked. The implementation must be safe to call any number | 
| + // of times. | 
| + virtual void OnCldDataRequest(); | 
| + | 
| + // Invoked when OnCldDataRequest, above, results in a successful lookup or | 
| + // the data is already cached and ready to respond to. The implementation | 
| + // should take whatever action is appropriate for responding to the paired | 
| + // RendererCldDataProvider, typically by sending an IPC response. | 
| + virtual void SendCldDataResponse(); | 
| +}; | 
| + | 
| +// Static factory function defined by the implementation that produces a new | 
| 
 
Takashi Toyoshima
2014/06/19 10:20:34
Did you build your CL with GYP_DEFINES+="component
 
Andrew Hayden (chromium.org)
2014/06/19 13:40:19
No, I was just building for my local vanilla Andro
 
 | 
| +// provider for the specified render view host. | 
| +BrowserCldDataProvider* BrowserCldDataProviderFor( | 
| 
 
Takashi Toyoshima
2014/06/19 10:20:34
CreateBrowser...() is better name since it starts
 
Andrew Hayden (chromium.org)
2014/06/19 13:40:20
Done.
 
 | 
| + content::RenderViewHost*); | 
| + | 
| +} // namespace content | 
| + | 
| +#endif // CONTENT_PUBLIC_BROWSER_BROWSER_CLD_DATAP_PROVIDER_H_ |