OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ | 5 #ifndef CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ |
6 #define CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ | 6 #define CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #if defined(CLD2_DYNAMIC_MODE) | |
11 #include "base/files/memory_mapped_file.h" | |
12 #endif | |
13 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
14 #if defined(CLD2_DYNAMIC_MODE) | |
15 #include "base/lazy_instance.h" | |
16 #endif | |
17 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
18 #include "base/time/time.h" | 12 #include "base/time/time.h" |
19 #include "components/translate/core/common/translate_errors.h" | 13 #include "components/translate/core/common/translate_errors.h" |
20 #include "content/public/renderer/render_view_observer.h" | 14 #include "content/public/renderer/render_view_observer.h" |
| 15 |
21 #if defined(CLD2_DYNAMIC_MODE) | 16 #if defined(CLD2_DYNAMIC_MODE) |
| 17 #include "base/files/file.h" |
| 18 #include "base/files/memory_mapped_file.h" |
| 19 #include "base/lazy_instance.h" |
22 #include "ipc/ipc_platform_file.h" | 20 #include "ipc/ipc_platform_file.h" |
23 #include "url/gurl.h" | 21 #include "url/gurl.h" |
24 #endif | 22 #endif |
25 | 23 |
26 namespace blink { | 24 namespace blink { |
27 class WebDocument; | 25 class WebDocument; |
28 class WebFrame; | 26 class WebFrame; |
29 } | 27 } |
30 | 28 |
31 // This class deals with page translation. | 29 // This class deals with page translation. |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // Invoked when a ChromeViewMsg_CLDDataAvailable message is received from | 186 // Invoked when a ChromeViewMsg_CLDDataAvailable message is received from |
189 // the browser process, providing a file handle for the CLD data file. If a | 187 // the browser process, providing a file handle for the CLD data file. If a |
190 // PageCaptured request was previously deferred with DeferPageCaptured and | 188 // PageCaptured request was previously deferred with DeferPageCaptured and |
191 // the page ID has not yet changed, the PageCaptured is reinvoked to | 189 // the page ID has not yet changed, the PageCaptured is reinvoked to |
192 // "resurrect" the language detection pathway. | 190 // "resurrect" the language detection pathway. |
193 void OnCLDDataAvailable(const IPC::PlatformFileForTransit ipc_file_handle, | 191 void OnCLDDataAvailable(const IPC::PlatformFileForTransit ipc_file_handle, |
194 const uint64 data_offset, | 192 const uint64 data_offset, |
195 const uint64 data_length); | 193 const uint64 data_length); |
196 | 194 |
197 // After receiving data in OnCLDDataAvailable, loads the data into CLD2. | 195 // After receiving data in OnCLDDataAvailable, loads the data into CLD2. |
198 void LoadCLDDData(const IPC::PlatformFileForTransit ipc_file_handle, | 196 void LoadCLDDData(base::File file, |
199 const uint64 data_offset, | 197 const uint64 data_offset, |
200 const uint64 data_length); | 198 const uint64 data_length); |
201 | 199 |
202 // A struct that contains the pointer to the CLD mmap. Used so that we can | 200 // A struct that contains the pointer to the CLD mmap. Used so that we can |
203 // leverage LazyInstance:Leaky to properly scope the lifetime of the mmap. | 201 // leverage LazyInstance:Leaky to properly scope the lifetime of the mmap. |
204 struct CLDMmapWrapper { | 202 struct CLDMmapWrapper { |
205 CLDMmapWrapper() { | 203 CLDMmapWrapper() { |
206 value = NULL; | 204 value = NULL; |
207 } | 205 } |
208 base::MemoryMappedFile* value; | 206 base::MemoryMappedFile* value; |
(...skipping 18 matching lines...) Expand all Loading... |
227 // The contents of the page most recently reported to PageCaptured if | 225 // The contents of the page most recently reported to PageCaptured if |
228 // deferred_page_capture_ is true. | 226 // deferred_page_capture_ is true. |
229 base::string16 deferred_contents_; | 227 base::string16 deferred_contents_; |
230 | 228 |
231 #endif | 229 #endif |
232 | 230 |
233 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); | 231 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); |
234 }; | 232 }; |
235 | 233 |
236 #endif // CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ | 234 #endif // CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ |
OLD | NEW |