OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/base/resource/data_pack.h" | 5 #include "ui/base/resource/data_pack.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/memory_mapped_file.h" | 10 #include "base/files/memory_mapped_file.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 const DataPackEntry* target = reinterpret_cast<const DataPackEntry*>( | 183 const DataPackEntry* target = reinterpret_cast<const DataPackEntry*>( |
184 bsearch(&resource_id, mmap_->data() + kHeaderLength, resource_count_, | 184 bsearch(&resource_id, mmap_->data() + kHeaderLength, resource_count_, |
185 sizeof(DataPackEntry), DataPackEntry::CompareById)); | 185 sizeof(DataPackEntry), DataPackEntry::CompareById)); |
186 if (!target) { | 186 if (!target) { |
187 return false; | 187 return false; |
188 } | 188 } |
189 | 189 |
190 const DataPackEntry* next_entry = target + 1; | 190 const DataPackEntry* next_entry = target + 1; |
191 size_t length = next_entry->file_offset - target->file_offset; | 191 size_t length = next_entry->file_offset - target->file_offset; |
192 | 192 |
193 data->set(mmap_->data() + target->file_offset, length); | 193 data->set(reinterpret_cast<const char*>(mmap_->data() + target->file_offset), |
| 194 length); |
194 return true; | 195 return true; |
195 } | 196 } |
196 | 197 |
197 base::RefCountedStaticMemory* DataPack::GetStaticMemory( | 198 base::RefCountedStaticMemory* DataPack::GetStaticMemory( |
198 uint16 resource_id) const { | 199 uint16 resource_id) const { |
199 base::StringPiece piece; | 200 base::StringPiece piece; |
200 if (!GetStringPiece(resource_id, &piece)) | 201 if (!GetStringPiece(resource_id, &piece)) |
201 return NULL; | 202 return NULL; |
202 | 203 |
203 return new base::RefCountedStaticMemory(piece.data(), piece.length()); | 204 return new base::RefCountedStaticMemory(piece.data(), piece.length()); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 return false; | 297 return false; |
297 } | 298 } |
298 } | 299 } |
299 | 300 |
300 base::CloseFile(file); | 301 base::CloseFile(file); |
301 | 302 |
302 return true; | 303 return true; |
303 } | 304 } |
304 | 305 |
305 } // namespace ui | 306 } // namespace ui |
OLD | NEW |