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_RENDERER_RENDERER_CLD_DATA_PROVIDER_H_ | |
6 #define COMPONENTS_TRANSLATE_CONTENT_RENDERER_RENDERER_CLD_DATA_PROVIDER_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "ipc/ipc_listener.h" | |
10 | |
11 namespace IPC { | |
12 class Message; | |
droger
2014/06/19 16:13:19
no leading whitespace
Andrew Hayden (chromium.org)
2014/06/19 19:49:30
Done.
| |
13 } | |
14 | |
15 namespace content { | |
16 | |
17 class RenderViewObserver; | |
18 | |
19 // Renderer-side interface responsible for providing CLD data. | |
20 // The implementation must be paired with a browser-side implementation of | |
21 // the BrowserCldDataProvider class: | |
22 // | |
23 // content/public/browser/browser_cld_data_provider.h | |
droger
2014/06/19 16:13:19
update the comment.
Andrew Hayden (chromium.org)
2014/06/19 19:49:30
Done.
| |
24 // | |
25 // ... and the glue between them is typically a pair of request/response IPC | |
26 // messages using the CldDataProviderMsgStart IPCMessageStart enumerated | |
27 // constant from ipc_message_start.h | |
28 class RendererCldDataProvider : public IPC::Listener { | |
29 public: | |
30 virtual ~RendererCldDataProvider() {} | |
31 | |
32 // (Inherited from IPC::Listener) | |
33 // If the specified message is a response for CLD data, attempts to | |
34 // initialize CLD2 and returns true in all cases. If initialization is | |
35 // successful and a callback has been configured via | |
36 // SetCldAvailableCallback(...), that callback is invoked from the message | |
37 // loop thread. | |
38 // This method is defined as virtual in order to force the implementation to | |
39 // define the specific IPC message(s) that it handles. | |
40 virtual bool OnMessageReceived(const IPC::Message&) OVERRIDE; | |
41 | |
42 // Invoked by the renderer process to request that CLD data be obtained and | |
43 // that CLD be initialized with it. The implementation is expected to | |
44 // communicate with the paired BrowserCldDataProvider implementation on the | |
45 // browser side. | |
46 // This method must be invoked on the message loop thread. | |
47 virtual void SendCldDataRequest() = 0; | |
48 | |
49 // Convenience method that tracks whether or not CLD data is available. | |
50 // This method can be used in the absence of a callback (i.e., if the caller | |
51 // wants a simple way to check the state of CLD data availability without | |
52 // keeping a separate boolean flag tripped by a callback). | |
53 virtual bool IsCldDataAvailable() = 0; | |
54 | |
55 // Sets a callback that will be invoked when CLD data is successfully | |
56 // obtained from the paired BrowserCldDataProvider implementation on the | |
57 // browser side, after CLD has been successfully initialized. | |
58 // Both the initialization of CLD2 as well as the invocation of the callback | |
59 // must happen on the message loop thread. | |
60 virtual void SetCldAvailableCallback(base::Callback<void(void)>) = 0; | |
61 }; | |
62 | |
63 // Static factory function defined by the implementation that produces a new | |
64 // provider for the specified render view host. | |
65 RendererCldDataProvider* CreateRendererCldDataProviderFor( | |
66 content::RenderViewObserver*); | |
67 | |
68 } // namespace content | |
69 | |
70 #endif // COMPONENTS_TRANSLATE_CONTENT_RENDERER_RENDERER_CLD_DATAP_PROVIDER_H_ | |
OLD | NEW |