Chromium Code Reviews| 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 CHROME_RENDERER_TRANSLATE_DATA_FILE_RENDERER_CLD_DATA_PROVIDER_H_ | |
|
Takashi Toyoshima
2014/06/19 10:20:35
macro name
Andrew Hayden (chromium.org)
2014/06/19 13:40:20
Done.
| |
| 6 #define CHROME_RENDERER_TRANSLATE_DATA_FILE_RENDERER_CLD_DATA_PROVIDER_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/memory/weak_ptr.h" | |
| 12 #include "components/translate/content/renderer/renderer_cld_data_provider.h" | |
| 13 #include "content/public/renderer/render_view_observer.h" | |
| 14 #include "ipc/ipc_message.h" | |
| 15 #include "ipc/ipc_platform_file.h" | |
| 16 | |
| 17 namespace content { | |
| 18 | |
| 19 class DataFileRendererCldDataProvider : public RendererCldDataProvider { | |
| 20 public: | |
| 21 DataFileRendererCldDataProvider(content::RenderViewObserver*); | |
|
Takashi Toyoshima
2014/06/19 10:20:35
explicit
Andrew Hayden (chromium.org)
2014/06/19 13:40:20
Done.
| |
| 22 bool OnMessageReceived(const IPC::Message&); | |
| 23 void SendCldDataRequest(); | |
| 24 void SetCldAvailableCallback(base::Callback<void(void)>); | |
| 25 bool IsCldDataAvailable(); | |
| 26 private: | |
| 27 void OnCldDataAvailable(const IPC::PlatformFileForTransit ipc_file_handle, | |
| 28 const uint64 data_offset, | |
| 29 const uint64 data_length); | |
| 30 void LoadCldData(base::File file, | |
| 31 const uint64 data_offset, | |
| 32 const uint64 data_length); | |
| 33 content::RenderViewObserver* render_view_observer; | |
| 34 base::Callback<void(void)> cld_available_callback; | |
| 35 // A struct that contains the pointer to the CLD mmap. Used so that we can | |
| 36 // leverage LazyInstance:Leaky to properly scope the lifetime of the mmap. | |
| 37 struct CLDMmapWrapper { | |
| 38 CLDMmapWrapper() { | |
| 39 value = NULL; | |
| 40 } | |
| 41 base::MemoryMappedFile* value; | |
| 42 }; | |
| 43 static base::LazyInstance<CLDMmapWrapper>::Leaky s_cld_mmap_; | |
|
Takashi Toyoshima
2014/06/19 10:20:35
DISALLOW_COPY_AND_ASSIGN
Andrew Hayden (chromium.org)
2014/06/19 13:40:20
Done.
| |
| 44 }; | |
| 45 | |
| 46 // Implementation of the static factory method from BrowserCldDataProvider, | |
| 47 // hooking up this specific implementation for all of Chromium. | |
| 48 RendererCldDataProvider* RendererCldDataProviderFor( | |
|
Takashi Toyoshima
2014/06/19 10:20:35
ditto, any reason to implement this in a header?
Andrew Hayden (chromium.org)
2014/06/19 13:40:20
Same response, moved to .cc file.
| |
| 49 content::RenderViewObserver* render_view_observer) { | |
| 50 return new DataFileRendererCldDataProvider(render_view_observer); | |
| 51 } | |
| 52 | |
| 53 } // namespace content | |
| 54 | |
| 55 #endif // CHROME_RENDERER_TRANSLATE_DATA_FILE_RENDERER_CLD_DATA_PROVIDER_H_ | |
| OLD | NEW |