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

Unified Diff: ui/base/resource/data_pack.cc

Issue 7890060: This broke lots of layout tests on OSX. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/resource/data_pack.h ('k') | ui/base/resource/data_pack_literal.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/resource/data_pack.cc
===================================================================
--- ui/base/resource/data_pack.cc (revision 101223)
+++ ui/base/resource/data_pack.cc (working copy)
@@ -17,9 +17,9 @@
namespace {
-static const uint32 kFileFormatVersion = 4;
-// Length of file header: version, entry count and text encoding type.
-static const size_t kHeaderLength = 2 * sizeof(uint32) + sizeof(uint8);
+static const uint32 kFileFormatVersion = 3;
+// Length of file header: version and entry count.
+static const size_t kHeaderLength = 2 * sizeof(uint32);
#pragma pack(push,2)
struct DataPackEntry {
@@ -60,7 +60,7 @@
namespace ui {
// In .cc for MemoryMappedFile dtor.
-DataPack::DataPack() : resource_count_(0), text_encoding_type_(BINARY) {
+DataPack::DataPack() : resource_count_(0) {
}
DataPack::~DataPack() {
}
@@ -83,7 +83,7 @@
}
// Parse the header of the file.
- // First uint32: version; second: resource count;
+ // First uint32: version; second: resource count.
const uint32* ptr = reinterpret_cast<const uint32*>(mmap_->data());
uint32 version = ptr[0];
if (version != kFileFormatVersion) {
@@ -96,17 +96,6 @@
}
resource_count_ = ptr[1];
- // third: text encoding.
- const uint8* ptr_encoding = reinterpret_cast<const uint8*>(ptr + 2);
- text_encoding_type_ = static_cast<TextEncodingType>(*ptr_encoding);
- if (text_encoding_type_ != UTF8 && text_encoding_type_ != UTF16 &&
- text_encoding_type_ != BINARY) {
- LOG(ERROR) << "Bad data pack text encoding: got " << text_encoding_type_
- << ", expected between " << BINARY << " and " << UTF16;
- mmap_.reset();
- return false;
- }
-
// Sanity check the file.
// 1) Check we have enough entries.
if (kHeaderLength + resource_count_ * sizeof(DataPackEntry) >
@@ -174,8 +163,7 @@
// static
bool DataPack::WritePack(const FilePath& path,
- const std::map<uint16, base::StringPiece>& resources,
- TextEncodingType textEncodingType) {
+ const std::map<uint16, base::StringPiece>& resources) {
FILE* file = file_util::OpenFile(path, "wb");
if (!file)
return false;
@@ -195,21 +183,6 @@
return false;
}
- if (textEncodingType != UTF8 && textEncodingType != UTF16 &&
- textEncodingType != BINARY) {
- LOG(ERROR) << "Invalid text encoding type, got " << textEncodingType
- << ", expected between " << BINARY << " and " << UTF16;
- file_util::CloseFile(file);
- return false;
- }
-
- uint8 write_buffer = textEncodingType;
- if (fwrite(&write_buffer, sizeof(uint8), 1, file) != 1) {
- LOG(ERROR) << "Failed to write file text resources encoding";
- file_util::CloseFile(file);
- return false;
- }
-
// Each entry is a uint16 + a uint32. We have an extra entry after the last
// item so we can compute the size of the list item.
uint32 index_length = (entry_count + 1) * sizeof(DataPackEntry);
« no previous file with comments | « ui/base/resource/data_pack.h ('k') | ui/base/resource/data_pack_literal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698