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 #include "data_file_renderer_cld_data_provider.h" | 5 #include "data_file_renderer_cld_data_provider.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
9 #include "base/files/memory_mapped_file.h" | 9 #include "base/files/memory_mapped_file.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 CLDMmapWrapper() { value = NULL; } | 24 CLDMmapWrapper() { value = NULL; } |
25 base::MemoryMappedFile* value; | 25 base::MemoryMappedFile* value; |
26 }; | 26 }; |
27 base::LazyInstance<CLDMmapWrapper>::Leaky g_cld_mmap = | 27 base::LazyInstance<CLDMmapWrapper>::Leaky g_cld_mmap = |
28 LAZY_INSTANCE_INITIALIZER; | 28 LAZY_INSTANCE_INITIALIZER; |
29 | 29 |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 namespace translate { | 32 namespace translate { |
33 | 33 |
34 // Implementation of the static factory method from RendererCldDataProvider, | |
35 // hooking up this specific implementation for all of Chromium. | |
36 RendererCldDataProvider* CreateRendererCldDataProviderFor( | |
37 content::RenderViewObserver* render_view_observer) { | |
38 // This log line is to help with determining which kind of provider has been | |
39 // configured. See also: chrome://translate-internals | |
40 VLOG(1) << "Creating DataFileRendererCldDataProvider"; | |
41 return new DataFileRendererCldDataProvider(render_view_observer); | |
42 } | |
43 | |
44 DataFileRendererCldDataProvider::DataFileRendererCldDataProvider( | 34 DataFileRendererCldDataProvider::DataFileRendererCldDataProvider( |
45 content::RenderViewObserver* render_view_observer) | 35 content::RenderViewObserver* render_view_observer) |
46 : render_view_observer_(render_view_observer) { | 36 : render_view_observer_(render_view_observer) { |
47 } | 37 } |
48 | 38 |
49 DataFileRendererCldDataProvider::~DataFileRendererCldDataProvider() { | 39 DataFileRendererCldDataProvider::~DataFileRendererCldDataProvider() { |
50 } | 40 } |
51 | 41 |
52 bool DataFileRendererCldDataProvider::OnMessageReceived( | 42 bool DataFileRendererCldDataProvider::OnMessageReceived( |
53 const IPC::Message& message) { | 43 const IPC::Message& message) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // Initialize the CLD subsystem... and it's all done! | 112 // Initialize the CLD subsystem... and it's all done! |
123 const uint8* data_ptr = g_cld_mmap.Get().value->data() + data_offset; | 113 const uint8* data_ptr = g_cld_mmap.Get().value->data() + data_offset; |
124 CLD2::loadDataFromRawAddress(data_ptr, data_length); | 114 CLD2::loadDataFromRawAddress(data_ptr, data_length); |
125 DCHECK(CLD2::isDataLoaded()) << "Failed to load CLD data from mmap"; | 115 DCHECK(CLD2::isDataLoaded()) << "Failed to load CLD data from mmap"; |
126 if (!cld_available_callback_.is_null()) { | 116 if (!cld_available_callback_.is_null()) { |
127 cld_available_callback_.Run(); | 117 cld_available_callback_.Run(); |
128 } | 118 } |
129 } | 119 } |
130 | 120 |
131 } // namespace translate | 121 } // namespace translate |
OLD | NEW |