OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_H_ |
| 6 #define COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_H_ |
| 7 |
| 8 #include "ipc/ipc_listener.h" |
| 9 |
| 10 namespace IPC { |
| 11 class Message; |
| 12 } |
| 13 |
| 14 namespace content { |
| 15 class RenderViewHost; |
| 16 } |
| 17 |
| 18 namespace translate { |
| 19 |
| 20 // Browser-side interface responsible for providing CLD data. |
| 21 // The implementation must be paired with a renderer-side implementation of |
| 22 // the RendererCldDataProvider class: |
| 23 // |
| 24 // components/translate/content/renderer/renderer_cld_data_provider.h |
| 25 // |
| 26 // ... and the glue between them is typically a pair of request/response IPC |
| 27 // messages using the CldDataProviderMsgStart IPCMessageStart enumerated |
| 28 // constant from ipc_message_start.h |
| 29 class BrowserCldDataProvider : public IPC::Listener { |
| 30 public: |
| 31 virtual ~BrowserCldDataProvider() {} |
| 32 |
| 33 // IPC::Listener implementation: |
| 34 // If the specified message is a request for CLD data, invokes |
| 35 // OnCldDataRequest() and returns true. In all other cases, this method does |
| 36 // nothing. This method is defined as virtual in order to force the |
| 37 // implementation to define the specific IPC message(s) that it handles. |
| 38 virtual bool OnMessageReceived(const IPC::Message&) = 0; |
| 39 |
| 40 // Called when the browser process receives an appropriate message in |
| 41 // OnMessageReceived, above. The implementation should attempt to locate |
| 42 // the CLD data, cache any metadata required for accessing that data, and |
| 43 // ultimately trigger a response by invoking SendCldDataResponse. |
| 44 // |
| 45 // The renderer process may poll for data, in which case this method may be |
| 46 // repeatedly invoked. The implementation must be safe to call any number |
| 47 // of times. |
| 48 virtual void OnCldDataRequest() = 0; |
| 49 |
| 50 // Invoked when OnCldDataRequest, above, results in a successful lookup or |
| 51 // the data is already cached and ready to respond to. The implementation |
| 52 // should take whatever action is appropriate for responding to the paired |
| 53 // RendererCldDataProvider, typically by sending an IPC response. |
| 54 virtual void SendCldDataResponse() = 0; |
| 55 }; |
| 56 |
| 57 // Static factory function defined by the implementation that produces a new |
| 58 // provider for the specified render view host. |
| 59 BrowserCldDataProvider* CreateBrowserCldDataProviderFor( |
| 60 content::RenderViewHost*); |
| 61 |
| 62 } // namespace translate |
| 63 |
| 64 #endif // COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATAP_PROVIDER_H_ |
OLD | NEW |