| 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 3f6bcc480f7a361928fdddbd1cd8d7b2d2c18c42..a92b4b3fe92a106c7c5022dd6a5ea3e10a2aae9b 100644
|
| --- a/webkit/fileapi/media/picasa/pmp_column_reader.cc
|
| +++ b/webkit/fileapi/media/picasa/pmp_column_reader.cc
|
| @@ -19,14 +19,17 @@ const size_t kPmpMaxFilesize = 50*1024*1024; // Maximum of 50 MB.
|
|
|
| } // namespace
|
|
|
| -PmpColumnReader::PmpColumnReader()
|
| - : length_(0),
|
| +PmpColumnReader::PmpColumnReader(const std::string& column_name)
|
| + : column_name_(column_name),
|
| + length_(0),
|
| field_type_(PMP_TYPE_INVALID),
|
| - rows_(0) { }
|
| + rows_(0) {}
|
|
|
| -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 +47,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 +105,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 +129,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;
|
|
|