OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // NOT DEAD CODE! | 5 // NOT DEAD CODE! |
6 // This code isn't dead, even if it isn't currently being used. Please refer to: | 6 // This code isn't dead, even if it isn't currently being used. Please refer to: |
7 // https://www.chromium.org/developers/how-tos/compact-language-detector-cld-dat
a-source-configuration | 7 // https://www.chromium.org/developers/how-tos/compact-language-detector-cld-dat
a-source-configuration |
8 | 8 |
9 #ifndef COMPONENTS_TRANSLATE_CONTENT_RENDERER_DATA_FILE_RENDERER_CLD_DATA_PROVID
ER_H_ | 9 #ifndef COMPONENTS_TRANSLATE_CONTENT_RENDERER_DATA_FILE_RENDERER_CLD_DATA_PROVID
ER_H_ |
10 #define COMPONENTS_TRANSLATE_CONTENT_RENDERER_DATA_FILE_RENDERER_CLD_DATA_PROVID
ER_H_ | 10 #define COMPONENTS_TRANSLATE_CONTENT_RENDERER_DATA_FILE_RENDERER_CLD_DATA_PROVID
ER_H_ |
11 | 11 |
| 12 #include <stdint.h> |
| 13 |
12 #include "base/files/file.h" | 14 #include "base/files/file.h" |
13 #include "base/macros.h" | 15 #include "base/macros.h" |
14 #include "components/translate/content/renderer/renderer_cld_data_provider.h" | 16 #include "components/translate/content/renderer/renderer_cld_data_provider.h" |
15 #include "ipc/ipc_platform_file.h" | 17 #include "ipc/ipc_platform_file.h" |
16 | 18 |
17 namespace content { | 19 namespace content { |
18 class RenderFrameObserver; | 20 class RenderFrameObserver; |
19 } | 21 } |
20 | 22 |
21 namespace translate { | 23 namespace translate { |
22 | 24 |
23 class DataFileRendererCldDataProvider : public RendererCldDataProvider { | 25 class DataFileRendererCldDataProvider : public RendererCldDataProvider { |
24 public: | 26 public: |
25 explicit DataFileRendererCldDataProvider(content::RenderFrameObserver*); | 27 explicit DataFileRendererCldDataProvider(content::RenderFrameObserver*); |
26 ~DataFileRendererCldDataProvider() override; | 28 ~DataFileRendererCldDataProvider() override; |
27 | 29 |
28 // Load the CLD data from the specified file, starting at the specified byte | 30 // Load the CLD data from the specified file, starting at the specified byte |
29 // offset and having the specified length (also in bytes). Nominally, the | 31 // offset and having the specified length (also in bytes). Nominally, the |
30 // implementation will mmap the file in read-only mode and hand the data off | 32 // implementation will mmap the file in read-only mode and hand the data off |
31 // to CLD2::loadDataFromRawAddress(...). See the module | 33 // to CLD2::loadDataFromRawAddress(...). See the module |
32 // third_party/cld_2/src/internal/compact_lang_det.h for more information on | 34 // third_party/cld_2/src/internal/compact_lang_det.h for more information on |
33 // the dynamic data loading process. | 35 // the dynamic data loading process. |
34 void LoadCldData(base::File file, | 36 void LoadCldData(base::File file, |
35 const uint64 data_offset, | 37 const uint64_t data_offset, |
36 const uint64 data_length); | 38 const uint64_t data_length); |
37 | 39 |
38 // RendererCldDataProvider implementations: | 40 // RendererCldDataProvider implementations: |
39 bool OnMessageReceived(const IPC::Message&) override; | 41 bool OnMessageReceived(const IPC::Message&) override; |
40 void SendCldDataRequest() override; | 42 void SendCldDataRequest() override; |
41 void SetCldAvailableCallback(base::Callback<void(void)>) override; | 43 void SetCldAvailableCallback(base::Callback<void(void)>) override; |
42 bool IsCldDataAvailable() override; | 44 bool IsCldDataAvailable() override; |
43 | 45 |
44 private: | 46 private: |
45 void OnCldDataAvailable(const IPC::PlatformFileForTransit ipc_file_handle, | 47 void OnCldDataAvailable(const IPC::PlatformFileForTransit ipc_file_handle, |
46 const uint64 data_offset, | 48 const uint64_t data_offset, |
47 const uint64 data_length); | 49 const uint64_t data_length); |
48 content::RenderFrameObserver* render_frame_observer_; | 50 content::RenderFrameObserver* render_frame_observer_; |
49 base::Callback<void(void)> cld_available_callback_; | 51 base::Callback<void(void)> cld_available_callback_; |
50 | 52 |
51 DISALLOW_COPY_AND_ASSIGN(DataFileRendererCldDataProvider); | 53 DISALLOW_COPY_AND_ASSIGN(DataFileRendererCldDataProvider); |
52 }; | 54 }; |
53 | 55 |
54 } // namespace translate | 56 } // namespace translate |
55 | 57 |
56 #endif // COMPONENTS_TRANSLATE_CONTENT_RENDERER_DATA_FILE_RENDERER_CLD_DATA_PRO
VIDER_H_ | 58 #endif // COMPONENTS_TRANSLATE_CONTENT_RENDERER_DATA_FILE_RENDERER_CLD_DATA_PRO
VIDER_H_ |
OLD | NEW |