Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: components/translate/content/renderer/data_file_renderer_cld_data_provider.cc

Issue 430583005: Make VEA test support videos with different coded size and visible size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use scope_ptr for MemoryMappedFile object Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 if (IsCldDataAvailable()) 92 if (IsCldDataAvailable())
93 return; 93 return;
94 94
95 if (!file.IsValid()) { 95 if (!file.IsValid()) {
96 LOG(ERROR) << "Can't find the CLD data file."; 96 LOG(ERROR) << "Can't find the CLD data file.";
97 return; 97 return;
98 } 98 }
99 99
100 // mmap the file 100 // mmap the file
101 g_cld_mmap.Get().value = new base::MemoryMappedFile(); 101 g_cld_mmap.Get().value = new base::MemoryMappedFile();
102 bool initialized = g_cld_mmap.Get().value->Initialize(file.Pass()); 102 bool initialized = g_cld_mmap.Get().value->Initialize(file.Pass(), false);
103 if (!initialized) { 103 if (!initialized) {
104 LOG(ERROR) << "mmap initialization failed"; 104 LOG(ERROR) << "mmap initialization failed";
105 delete g_cld_mmap.Get().value; 105 delete g_cld_mmap.Get().value;
106 g_cld_mmap.Get().value = NULL; 106 g_cld_mmap.Get().value = NULL;
107 return; 107 return;
108 } 108 }
109 109
110 // Sanity checks 110 // Sanity checks
111 uint64 max_int32 = std::numeric_limits<int32>::max(); 111 uint64 max_int32 = std::numeric_limits<int32>::max();
112 if (data_length + data_offset > g_cld_mmap.Get().value->length() || 112 if (data_length + data_offset > g_cld_mmap.Get().value->length() ||
113 data_length > max_int32) { // max signed 32 bit integer 113 data_length > max_int32) { // max signed 32 bit integer
114 LOG(ERROR) << "Illegal mmap config: data_offset=" << data_offset 114 LOG(ERROR) << "Illegal mmap config: data_offset=" << data_offset
115 << ", data_length=" << data_length 115 << ", data_length=" << data_length
116 << ", mmap->length()=" << g_cld_mmap.Get().value->length(); 116 << ", mmap->length()=" << g_cld_mmap.Get().value->length();
117 delete g_cld_mmap.Get().value; 117 delete g_cld_mmap.Get().value;
118 g_cld_mmap.Get().value = NULL; 118 g_cld_mmap.Get().value = NULL;
119 return; 119 return;
120 } 120 }
121 121
122 // Initialize the CLD subsystem... and it's all done! 122 // Initialize the CLD subsystem... and it's all done!
123 const uint8* data_ptr = g_cld_mmap.Get().value->data() + data_offset; 123 const uint8* data_ptr = g_cld_mmap.Get().value->data() + data_offset;
124 CLD2::loadDataFromRawAddress(data_ptr, data_length); 124 CLD2::loadDataFromRawAddress(data_ptr, data_length);
125 DCHECK(CLD2::isDataLoaded()) << "Failed to load CLD data from mmap"; 125 DCHECK(CLD2::isDataLoaded()) << "Failed to load CLD data from mmap";
126 if (!cld_available_callback_.is_null()) { 126 if (!cld_available_callback_.is_null()) {
127 cld_available_callback_.Run(); 127 cld_available_callback_.Run();
128 } 128 }
129 } 129 }
130 130
131 } // namespace translate 131 } // namespace translate
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698