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_DATA_FILE_RENDERER_CLD_DATA_PROVID ER_H_ | |
6 #define COMPONENTS_TRANSLATE_CONTENT_RENDERER_DATA_FILE_RENDERER_CLD_DATA_PROVID ER_H_ | |
7 | |
8 #include "base/files/file.h" | |
9 #include "base/files/memory_mapped_file.h" | |
10 #include "base/lazy_instance.h" | |
11 #include "base/macros.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "components/translate/content/renderer/renderer_cld_data_provider.h" | |
14 #include "ipc/ipc_platform_file.h" | |
15 | |
16 namespace translate { | |
17 | |
18 class DataFileRendererCldDataProvider : public RendererCldDataProvider { | |
19 public: | |
20 explicit DataFileRendererCldDataProvider(content::RenderViewObserver*); | |
21 virtual ~DataFileRendererCldDataProvider(); | |
22 // RendererCldDataProvider implementations: | |
23 virtual bool OnMessageReceived(const IPC::Message&) OVERRIDE; | |
24 virtual void SendCldDataRequest() OVERRIDE; | |
25 virtual void SetCldAvailableCallback(base::Callback<void(void)>) OVERRIDE; | |
26 virtual bool IsCldDataAvailable() OVERRIDE; | |
27 | |
28 private: | |
29 void OnCldDataAvailable(const IPC::PlatformFileForTransit ipc_file_handle, | |
30 const uint64 data_offset, | |
31 const uint64 data_length); | |
32 void LoadCldData(base::File file, | |
33 const uint64 data_offset, | |
Takashi Toyoshima
2014/06/23 09:22:58
indent nits on line 33 and 34.
Andrew Hayden (chromium.org)
2014/06/23 13:54:43
Done.
| |
34 const uint64 data_length); | |
35 content::RenderViewObserver* render_view_observer; | |
Takashi Toyoshima
2014/06/23 09:22:58
render_view_observer_
Andrew Hayden (chromium.org)
2014/06/23 13:54:43
Done.
| |
36 base::Callback<void(void)> cld_available_callback; | |
Takashi Toyoshima
2014/06/23 09:22:58
cld_available_callback_
Andrew Hayden (chromium.org)
2014/06/23 13:54:43
Done.
| |
37 // A struct that contains the pointer to the CLD mmap. Used so that we can | |
Takashi Toyoshima
2014/06/23 09:22:58
Following definitions can be moved to .cc file in
Andrew Hayden (chromium.org)
2014/06/23 13:54:43
LazyInstance::Leaky is necessary to avoid having t
Takashi Toyoshima
2014/06/24 02:09:47
Ah, I see. Thank you for your explanation!
| |
38 // leverage LazyInstance:Leaky to properly scope the lifetime of the mmap. | |
39 struct CLDMmapWrapper { | |
40 CLDMmapWrapper() { | |
41 value = NULL; | |
42 } | |
43 base::MemoryMappedFile* value; | |
44 }; | |
45 static base::LazyInstance<CLDMmapWrapper>::Leaky s_cld_mmap_; | |
46 | |
47 DISALLOW_COPY_AND_ASSIGN(DataFileRendererCldDataProvider); | |
48 }; | |
49 | |
50 } // namespace translate | |
51 | |
52 #endif // COMPONENTS_TRANSLATE_CONTENT_RENDERER_DATA_FILE_RENDERER_CLD_DATA_PRO VIDER_H_ | |
OLD | NEW |