summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-04 20:45:13 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-04 20:45:13 +0000
commite6f68a67a2e15d9311b9d1e9cc81bf1b38489ad7 (patch)
treed5d466b7f318f0eaeac16cce9c49f774232811e7 /ui/base
parentc45f97548e30a2fb1382a3cb27759130e209ea26 (diff)
downloadchromium_src-e6f68a67a2e15d9311b9d1e9cc81bf1b38489ad7.zip
chromium_src-e6f68a67a2e15d9311b9d1e9cc81bf1b38489ad7.tar.gz
chromium_src-e6f68a67a2e15d9311b9d1e9cc81bf1b38489ad7.tar.bz2
Revert 95480 - Abstract fullscreen exit bubble logic to bring Linux's behaviour in line with
Windows. I committed with the wrong change description-- This has nothing to do will fullscreen exit bubble, it has to do with data pak files). Review URL: http://codereview.chromium.org/7549005 TBR=tony@chromium.org Review URL: http://codereview.chromium.org/7575017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95482 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/resource/data_pack.cc44
-rw-r--r--ui/base/resource/data_pack.h6
-rw-r--r--ui/base/resource/data_pack_unittest.cc2
-rw-r--r--ui/base/test/data/data_pack_unittest/sample.pakbin72 -> 80 bytes
4 files changed, 26 insertions, 26 deletions
diff --git a/ui/base/resource/data_pack.cc b/ui/base/resource/data_pack.cc
index 18fee46..d6e4e7b 100644
--- a/ui/base/resource/data_pack.cc
+++ b/ui/base/resource/data_pack.cc
@@ -17,18 +17,20 @@
namespace {
-static const uint32 kFileFormatVersion = 2;
+// A word is four bytes.
+static const size_t kWord = 4;
+
+static const uint32 kFileFormatVersion = 1;
// Length of file header: version and entry count.
static const size_t kHeaderLength = 2 * sizeof(uint32);
-#pragma pack(push,2)
struct DataPackEntry {
- uint16 resource_id;
+ uint32 resource_id;
uint32 file_offset;
uint32 length;
static int CompareById(const void* void_key, const void* void_entry) {
- uint16 key = *reinterpret_cast<const uint16*>(void_key);
+ uint32 key = *reinterpret_cast<const uint32*>(void_key);
const DataPackEntry* entry =
reinterpret_cast<const DataPackEntry*>(void_entry);
if (key < entry->resource_id) {
@@ -40,9 +42,8 @@ struct DataPackEntry {
}
}
};
-#pragma pack(pop)
-COMPILE_ASSERT(sizeof(DataPackEntry) == 10, size_of_header_must_be_ten);
+COMPILE_ASSERT(sizeof(DataPackEntry) == 12, size_of_header_must_be_twelve);
// We're crashing when trying to load a pak file on Windows. Add some error
// codes for logging.
@@ -118,7 +119,7 @@ bool DataPack::Load(const FilePath& path) {
return true;
}
-bool DataPack::GetStringPiece(uint16 resource_id,
+bool DataPack::GetStringPiece(uint32 resource_id,
base::StringPiece* data) const {
// It won't be hard to make this endian-agnostic, but it's not worth
// bothering to do right now.
@@ -142,7 +143,7 @@ bool DataPack::GetStringPiece(uint16 resource_id,
return true;
}
-RefCountedStaticMemory* DataPack::GetStaticMemory(uint16 resource_id) const {
+RefCountedStaticMemory* DataPack::GetStaticMemory(uint32 resource_id) const {
base::StringPiece piece;
if (!GetStringPiece(resource_id, &piece))
return NULL;
@@ -153,12 +154,12 @@ RefCountedStaticMemory* DataPack::GetStaticMemory(uint16 resource_id) const {
// static
bool DataPack::WritePack(const FilePath& path,
- const std::map<uint16, base::StringPiece>& resources) {
+ const std::map<uint32, base::StringPiece>& resources) {
FILE* file = file_util::OpenFile(path, "wb");
if (!file)
return false;
- if (fwrite(&kFileFormatVersion, sizeof(kFileFormatVersion), 1, file) != 1) {
+ if (fwrite(&kFileFormatVersion, 1, kWord, file) != kWord) {
LOG(ERROR) << "Failed to write file version";
file_util::CloseFile(file);
return false;
@@ -167,34 +168,33 @@ bool DataPack::WritePack(const FilePath& path,
// Note: the python version of this function explicitly sorted keys, but
// std::map is a sorted associative container, we shouldn't have to do that.
uint32 entry_count = resources.size();
- if (fwrite(&entry_count, sizeof(entry_count), 1, file) != 1) {
+ if (fwrite(&entry_count, 1, kWord, file) != kWord) {
LOG(ERROR) << "Failed to write entry count";
file_util::CloseFile(file);
return false;
}
- // Each entry is 1 uint16 + 2 uint32s.
- uint32 index_length = entry_count * sizeof(DataPackEntry);
+ // Each entry is 3 uint32s.
+ uint32 index_length = entry_count * 3 * kWord;
uint32 data_offset = kHeaderLength + index_length;
- for (std::map<uint16, base::StringPiece>::const_iterator it =
+ for (std::map<uint32, base::StringPiece>::const_iterator it =
resources.begin();
it != resources.end(); ++it) {
- uint16 resource_id = it->first;
- if (fwrite(&resource_id, sizeof(resource_id), 1, file) != 1) {
- LOG(ERROR) << "Failed to write id for " << resource_id;
+ if (fwrite(&it->first, 1, kWord, file) != kWord) {
+ LOG(ERROR) << "Failed to write id for " << it->first;
file_util::CloseFile(file);
return false;
}
- if (fwrite(&data_offset, sizeof(data_offset), 1, file) != 1) {
- LOG(ERROR) << "Failed to write offset for " << resource_id;
+ if (fwrite(&data_offset, 1, kWord, file) != kWord) {
+ LOG(ERROR) << "Failed to write offset for " << it->first;
file_util::CloseFile(file);
return false;
}
uint32 len = it->second.length();
- if (fwrite(&len, sizeof(len), 1, file) != 1) {
- LOG(ERROR) << "Failed to write length for " << resource_id;
+ if (fwrite(&len, 1, kWord, file) != kWord) {
+ LOG(ERROR) << "Failed to write length for " << it->first;
file_util::CloseFile(file);
return false;
}
@@ -202,7 +202,7 @@ bool DataPack::WritePack(const FilePath& path,
data_offset += len;
}
- for (std::map<uint16, base::StringPiece>::const_iterator it =
+ for (std::map<uint32, base::StringPiece>::const_iterator it =
resources.begin();
it != resources.end(); ++it) {
if (fwrite(it->second.data(), it->second.length(), 1, file) != 1) {
diff --git a/ui/base/resource/data_pack.h b/ui/base/resource/data_pack.h
index f8d2e19..001ed0e 100644
--- a/ui/base/resource/data_pack.h
+++ b/ui/base/resource/data_pack.h
@@ -40,16 +40,16 @@ class UI_API DataPack {
// Get resource by id |resource_id|, filling in |data|.
// The data is owned by the DataPack object and should not be modified.
// Returns false if the resource id isn't found.
- bool GetStringPiece(uint16 resource_id, base::StringPiece* data) const;
+ bool GetStringPiece(uint32 resource_id, base::StringPiece* data) const;
// Like GetStringPiece(), but returns a reference to memory. This interface
// is used for image data, while the StringPiece interface is usually used
// for localization strings.
- RefCountedStaticMemory* GetStaticMemory(uint16 resource_id) const;
+ RefCountedStaticMemory* GetStaticMemory(uint32 resource_id) const;
// Writes a pack file containing |resources| to |path|.
static bool WritePack(const FilePath& path,
- const std::map<uint16, base::StringPiece>& resources);
+ const std::map<uint32, base::StringPiece>& resources);
private:
// The memory-mapped data.
diff --git a/ui/base/resource/data_pack_unittest.cc b/ui/base/resource/data_pack_unittest.cc
index 0f48097..9205fdf 100644
--- a/ui/base/resource/data_pack_unittest.cc
+++ b/ui/base/resource/data_pack_unittest.cc
@@ -48,7 +48,7 @@ TEST(DataPackTest, Write) {
std::string four("four");
std::string fifteen("fifteen");
- std::map<uint16, base::StringPiece> resources;
+ std::map<uint32, base::StringPiece> resources;
resources.insert(std::make_pair(1, base::StringPiece(one)));
resources.insert(std::make_pair(2, base::StringPiece(two)));
resources.insert(std::make_pair(15, base::StringPiece(fifteen)));
diff --git a/ui/base/test/data/data_pack_unittest/sample.pak b/ui/base/test/data/data_pack_unittest/sample.pak
index b172097..fdbe2b5 100644
--- a/ui/base/test/data/data_pack_unittest/sample.pak
+++ b/ui/base/test/data/data_pack_unittest/sample.pak
Binary files differ