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 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 content { | |
|
droger
2014/06/19 16:13:19
namespace translate
Andrew Hayden (chromium.org)
2014/06/19 19:49:30
Done.
| |
| 17 | |
| 18 class DataFileRendererCldDataProvider : public RendererCldDataProvider { | |
| 19 public: | |
| 20 explicit DataFileRendererCldDataProvider(content::RenderViewObserver*); | |
| 21 ~DataFileRendererCldDataProvider(); | |
| 22 // RendererCldDataProvider implementations: | |
| 23 bool OnMessageReceived(const IPC::Message&); | |
|
droger
2014/06/19 16:13:19
virtual and OVERRIDE?
Andrew Hayden (chromium.org)
2014/06/19 19:49:30
As above, leaving virtual out but OVERRIDE is in.
| |
| 24 void SendCldDataRequest(); | |
| 25 void SetCldAvailableCallback(base::Callback<void(void)>); | |
| 26 bool IsCldDataAvailable(); | |
| 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, | |
| 34 const uint64 data_length); | |
| 35 content::RenderViewObserver* render_view_observer; | |
| 36 base::Callback<void(void)> cld_available_callback; | |
| 37 // A struct that contains the pointer to the CLD mmap. Used so that we can | |
| 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 content | |
| 51 | |
| 52 #endif // COMPONENTS_TRANSLATE_CONTENT_RENDERER_DATA_FILE_RENDERER_CLD_DATA_PRO VIDER_H_ | |
| OLD | NEW |