summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-04 20:32:52 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-04 20:32:52 +0000
commitca39c1c2d84c152e7365ab5f2e5fcb1bb6056b55 (patch)
tree1f71fdc61b39b4728dbf5d774f1306c0a34bb96b /ui
parent8acfa0427d4a27763b8cf63a846e55b75e9073d9 (diff)
downloadchromium_src-ca39c1c2d84c152e7365ab5f2e5fcb1bb6056b55.zip
chromium_src-ca39c1c2d84c152e7365ab5f2e5fcb1bb6056b55.tar.gz
chromium_src-ca39c1c2d84c152e7365ab5f2e5fcb1bb6056b55.tar.bz2
Abstract fullscreen exit bubble logic to bring Linux's behaviour in line with
Windows. BUG=30743 TEST= Review URL: http://codereview.chromium.org/7549005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95480 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-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.pakbin80 -> 72 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 d6e4e7b..18fee46 100644
--- a/ui/base/resource/data_pack.cc
+++ b/ui/base/resource/data_pack.cc
@@ -17,20 +17,18 @@
namespace {
-// A word is four bytes.
-static const size_t kWord = 4;
-
-static const uint32 kFileFormatVersion = 1;
+static const uint32 kFileFormatVersion = 2;
// Length of file header: version and entry count.
static const size_t kHeaderLength = 2 * sizeof(uint32);
+#pragma pack(push,2)
struct DataPackEntry {
- uint32 resource_id;
+ uint16 resource_id;
uint32 file_offset;
uint32 length;
static int CompareById(const void* void_key, const void* void_entry) {
- uint32 key = *reinterpret_cast<const uint32*>(void_key);
+ uint16 key = *reinterpret_cast<const uint16*>(void_key);
const DataPackEntry* entry =
reinterpret_cast<const DataPackEntry*>(void_entry);
if (key < entry->resource_id) {
@@ -42,8 +40,9 @@ struct DataPackEntry {
}
}
};
+#pragma pack(pop)
-COMPILE_ASSERT(sizeof(DataPackEntry) == 12, size_of_header_must_be_twelve);
+COMPILE_ASSERT(sizeof(DataPackEntry) == 10, size_of_header_must_be_ten);
// We're crashing when trying to load a pak file on Windows. Add some error
// codes for logging.
@@ -119,7 +118,7 @@ bool DataPack::Load(const FilePath& path) {
return true;
}
-bool DataPack::GetStringPiece(uint32 resource_id,
+bool DataPack::GetStringPiece(uint16 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.
@@ -143,7 +142,7 @@ bool DataPack::GetStringPiece(uint32 resource_id,
return true;
}
-RefCountedStaticMemory* DataPack::GetStaticMemory(uint32 resource_id) const {
+RefCountedStaticMemory* DataPack::GetStaticMemory(uint16 resource_id) const {
base::StringPiece piece;
if (!GetStringPiece(resource_id, &piece))
return NULL;
@@ -154,12 +153,12 @@ RefCountedStaticMemory* DataPack::GetStaticMemory(uint32 resource_id) const {
// static
bool DataPack::WritePack(const FilePath& path,
- const std::map<uint32, base::StringPiece>& resources) {
+ const std::map<uint16, base::StringPiece>& resources) {
FILE* file = file_util::OpenFile(path, "wb");
if (!file)
return false;
- if (fwrite(&kFileFormatVersion, 1, kWord, file) != kWord) {
+ if (fwrite(&kFileFormatVersion, sizeof(kFileFormatVersion), 1, file) != 1) {
LOG(ERROR) << "Failed to write file version";
file_util::CloseFile(file);
return false;
@@ -168,33 +167,34 @@ 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, 1, kWord, file) != kWord) {
+ if (fwrite(&entry_count, sizeof(entry_count), 1, file) != 1) {
LOG(ERROR) << "Failed to write entry count";
file_util::CloseFile(file);
return false;
}
- // Each entry is 3 uint32s.
- uint32 index_length = entry_count * 3 * kWord;
+ // Each entry is 1 uint16 + 2 uint32s.
+ uint32 index_length = entry_count * sizeof(DataPackEntry);
uint32 data_offset = kHeaderLength + index_length;
- for (std::map<uint32, base::StringPiece>::const_iterator it =
+ for (std::map<uint16, base::StringPiece>::const_iterator it =
resources.begin();
it != resources.end(); ++it) {
- if (fwrite(&it->first, 1, kWord, file) != kWord) {
- LOG(ERROR) << "Failed to write id for " << it->first;
+ uint16 resource_id = it->first;
+ if (fwrite(&resource_id, sizeof(resource_id), 1, file) != 1) {
+ LOG(ERROR) << "Failed to write id for " << resource_id;
file_util::CloseFile(file);
return false;
}
- if (fwrite(&data_offset, 1, kWord, file) != kWord) {
- LOG(ERROR) << "Failed to write offset for " << it->first;
+ if (fwrite(&data_offset, sizeof(data_offset), 1, file) != 1) {
+ LOG(ERROR) << "Failed to write offset for " << resource_id;
file_util::CloseFile(file);
return false;
}
uint32 len = it->second.length();
- if (fwrite(&len, 1, kWord, file) != kWord) {
- LOG(ERROR) << "Failed to write length for " << it->first;
+ if (fwrite(&len, sizeof(len), 1, file) != 1) {
+ LOG(ERROR) << "Failed to write length for " << resource_id;
file_util::CloseFile(file);
return false;
}
@@ -202,7 +202,7 @@ bool DataPack::WritePack(const FilePath& path,
data_offset += len;
}
- for (std::map<uint32, base::StringPiece>::const_iterator it =
+ for (std::map<uint16, 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 001ed0e..f8d2e19 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(uint32 resource_id, base::StringPiece* data) const;
+ bool GetStringPiece(uint16 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(uint32 resource_id) const;
+ RefCountedStaticMemory* GetStaticMemory(uint16 resource_id) const;
// Writes a pack file containing |resources| to |path|.
static bool WritePack(const FilePath& path,
- const std::map<uint32, base::StringPiece>& resources);
+ const std::map<uint16, 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 9205fdf..0f48097 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<uint32, base::StringPiece> resources;
+ std::map<uint16, 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 fdbe2b5..b172097 100644
--- a/ui/base/test/data/data_pack_unittest/sample.pak
+++ b/ui/base/test/data/data_pack_unittest/sample.pak
Binary files differ