Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / components / translate / content / renderer / data_file_renderer_cld_data_provider.h
blob01266960dfd6f229551bece7039b03660158c977
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.
5 #ifndef COMPONENTS_TRANSLATE_CONTENT_RENDERER_DATA_FILE_RENDERER_CLD_DATA_PROVIDER_H_
6 #define COMPONENTS_TRANSLATE_CONTENT_RENDERER_DATA_FILE_RENDERER_CLD_DATA_PROVIDER_H_
8 #include "base/files/file.h"
9 #include "base/macros.h"
10 #include "components/translate/content/renderer/renderer_cld_data_provider.h"
11 #include "ipc/ipc_platform_file.h"
13 namespace content {
14 class RenderViewObserver;
17 namespace translate {
19 class DataFileRendererCldDataProvider : public RendererCldDataProvider {
20 public:
21 explicit DataFileRendererCldDataProvider(content::RenderViewObserver*);
22 ~DataFileRendererCldDataProvider() override;
24 // Load the CLD data from the specified file, starting at the specified byte
25 // offset and having the specified length (also in bytes). Nominally, the
26 // implementation will mmap the file in read-only mode and hand the data off
27 // to CLD2::loadDataFromRawAddress(...). See the module
28 // third_party/cld_2/src/internal/compact_lang_det.h for more information on
29 // the dynamic data loading process.
30 void LoadCldData(base::File file,
31 const uint64 data_offset,
32 const uint64 data_length);
34 // RendererCldDataProvider implementations:
35 bool OnMessageReceived(const IPC::Message&) override;
36 void SendCldDataRequest() override;
37 void SetCldAvailableCallback(base::Callback<void(void)>) override;
38 bool IsCldDataAvailable() override;
40 private:
41 void OnCldDataAvailable(const IPC::PlatformFileForTransit ipc_file_handle,
42 const uint64 data_offset,
43 const uint64 data_length);
44 content::RenderViewObserver* render_view_observer_;
45 base::Callback<void(void)> cld_available_callback_;
47 DISALLOW_COPY_AND_ASSIGN(DataFileRendererCldDataProvider);
50 } // namespace translate
52 #endif // COMPONENTS_TRANSLATE_CONTENT_RENDERER_DATA_FILE_RENDERER_CLD_DATA_PROVIDER_H_