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

Unified Diff: webkit/fileapi/media/picasa/pmp_column_reader.cc

Issue 13529028: PicasaAlbumTableReader for Media Galleries API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0005-picasa-import-pmp-reader
Patch Set: Formatting fixes. Created 7 years, 8 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
Index: webkit/fileapi/media/picasa/pmp_column_reader.cc
diff --git a/webkit/fileapi/media/picasa/pmp_column_reader.cc b/webkit/fileapi/media/picasa/pmp_column_reader.cc
index 2e6777ae0a0ecb0f04d32af14805d972bf5ded54..567a7519a65559372979b8d8e11095f4f5846813 100644
--- a/webkit/fileapi/media/picasa/pmp_column_reader.cc
+++ b/webkit/fileapi/media/picasa/pmp_column_reader.cc
@@ -26,7 +26,9 @@ PmpColumnReader::PmpColumnReader()
PmpColumnReader::~PmpColumnReader() { }
-bool PmpColumnReader::Init(const base::FilePath& filepath, uint32* rows_read) {
+bool PmpColumnReader::Init(const base::FilePath& filepath,
+ const PmpFieldType expected_type,
+ uint32* rows_read) {
DCHECK(!data_.get());
base::ThreadRestrictions::AssertIOAllowed();
@@ -44,7 +46,7 @@ bool PmpColumnReader::Init(const base::FilePath& filepath, uint32* rows_read) {
char* data_begin = reinterpret_cast<char*>(data_.get());
return file_util::ReadFile(filepath, data_begin, length_) &&
- ParseData(rows_read);
+ ParseData(expected_type, rows_read);
}
bool PmpColumnReader::ReadString(const uint32 row, std::string* result) const {
@@ -102,7 +104,8 @@ bool PmpColumnReader::ReadUInt64(const uint32 row, uint64* result) const {
return true;
}
-bool PmpColumnReader::ParseData(uint32* rows_read) {
+bool PmpColumnReader::ParseData(const PmpFieldType expected_type,
+ uint32* rows_read) {
DCHECK(data_.get() != NULL);
DCHECK_GE(length_, kPmpHeaderSize);
@@ -125,6 +128,9 @@ bool PmpColumnReader::ParseData(uint32* rows_read) {
field_type_ = static_cast<PmpFieldType>(field_type_data);
+ if (field_type_ != expected_type)
+ return false;
+
rows_ = *(reinterpret_cast<uint32*>(&data_[kPmpRowCountOffset]));
size_t body_length = length_ - kPmpHeaderSize;

Powered by Google App Engine
This is Rietveld 408576698