diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-14 00:39:01 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-14 00:39:01 +0000 |
commit | 4699e7bb9e5ef3c35009442c9954dd2b7489e191 (patch) | |
tree | d0d239f875583014aa6e505381f97000c5a0569a /ui/base/resource/data_pack.cc | |
parent | b09f128a727d89bff77438377176510c16774b69 (diff) | |
download | chromium_src-4699e7bb9e5ef3c35009442c9954dd2b7489e191.zip chromium_src-4699e7bb9e5ef3c35009442c9954dd2b7489e191.tar.gz chromium_src-4699e7bb9e5ef3c35009442c9954dd2b7489e191.tar.bz2 |
Revert 100973 - Updated *.pak file format to support both UTF8 and UTF16
Chromeframe tests started failing with this, see:
http://build.chromium.org/p/chromium/builders/Chrome%20Frame%20Tests%20%28ie6%29/builds/14472/steps/chrome_frame_tests/logs/stdio
http://build.chromium.org/p/chromium/builders/Chrome%20Frame%20Tests%20%28ie7%29/builds/14446/steps/chrome_frame_tests/logs/stdio
http://build.chromium.org/p/chromium/builders/Chrome%20Frame%20Tests%20%28ie8%29/builds/14187/steps/chrome_frame_tests/logs/stdio
FullTabDownloadTest.TopLevelPostReissueFromChromeFramePage:
Did not complete.
[----------] 2 tests from FullTabDownloadTest
[ RUN ] FullTabDownloadTest.CF_DownloadFileFromPost
[ OK ] FullTabDownloadTest.CF_DownloadFileFromPost (16 ms)
[ RUN ] FullTabDownloadTest.TopLevelPostReissueFromChromeFramePage
[712:3268:0913/153614:1242640:INFO:chrome_frame_test_utils.h(89)] chrome_frame_test::HungCOMCallDetector::~HungCOMCallDetector
[712:3268:0913/153614:1242640:INFO:navigation_test.cc(753)] Not running test on Vista with IE7
[712:3268:0913/153614:1242656:INFO:chrome_frame_test_utils.h(85)] chrome_frame_test::HungCOMCallDetector::HungCOMCallDetector
Inserted a new field in the header that specifies which encoding is to be used for the text resources.
I also upped file format to version 4.
BUG=76281
TEST=unit_tests
Review URL: http://codereview.chromium.org/7744017
TBR=adriansc@chromium.org
Review URL: http://codereview.chromium.org/7891028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101004 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/resource/data_pack.cc')
-rw-r--r-- | ui/base/resource/data_pack.cc | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/ui/base/resource/data_pack.cc b/ui/base/resource/data_pack.cc index 5a0dcf1..c4b1594 100644 --- a/ui/base/resource/data_pack.cc +++ b/ui/base/resource/data_pack.cc @@ -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 @@ enum LoadErrors { 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 @@ bool DataPack::Load(const FilePath& path) { } // 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 @@ bool DataPack::Load(const FilePath& path) { } 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 @@ RefCountedStaticMemory* DataPack::GetStaticMemory(uint16 resource_id) const { // 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 @@ bool DataPack::WritePack(const FilePath& path, 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); |