| Index: chrome/browser/media_galleries/fileapi/picasa/pmp_column_reader.cc
|
| diff --git a/chrome/browser/media_galleries/fileapi/picasa/pmp_column_reader.cc b/chrome/browser/media_galleries/fileapi/picasa/pmp_column_reader.cc
|
| index cf799d41539451f9ee3c636c15c1fbd95caef9bc..6e3201c2776f32d32951e45485a95741391779c3 100644
|
| --- a/chrome/browser/media_galleries/fileapi/picasa/pmp_column_reader.cc
|
| +++ b/chrome/browser/media_galleries/fileapi/picasa/pmp_column_reader.cc
|
| @@ -7,7 +7,6 @@
|
| #include <cstring>
|
|
|
| #include "base/file_util.h"
|
| -#include "base/files/file_path.h"
|
| #include "base/logging.h"
|
| #include "base/threading/thread_restrictions.h"
|
|
|
| @@ -15,6 +14,7 @@ namespace picasa {
|
|
|
| namespace {
|
|
|
| +COMPILE_ASSERT(sizeof(double) == 8, double_must_be_8_bytes_long);
|
| const int64 kPmpMaxFilesize = 50*1024*1024; // Arbitrary maximum of 50 MB.
|
|
|
| } // namespace
|
| @@ -26,15 +26,20 @@ PmpColumnReader::PmpColumnReader()
|
|
|
| PmpColumnReader::~PmpColumnReader() {}
|
|
|
| -bool PmpColumnReader::Init(const base::FilePath& filepath,
|
| - const PmpFieldType expected_type,
|
| - uint32* rows_read) {
|
| +bool PmpColumnReader::Init(const base::PlatformFile& file,
|
| + const PmpFieldType expected_type) {
|
| DCHECK(!data_.get());
|
| base::ThreadRestrictions::AssertIOAllowed();
|
|
|
| - if (!file_util::GetFileSize(filepath, &length_))
|
| + if (file == base::kInvalidPlatformFileValue)
|
| return false;
|
|
|
| + base::PlatformFileInfo info;
|
| + if (!base::GetPlatformFileInfo(file, &info))
|
| + return false;
|
| +
|
| + length_ = info.size;
|
| +
|
| if (length_ < kPmpHeaderSize || length_ > kPmpMaxFilesize)
|
| return false;
|
|
|
| @@ -44,8 +49,8 @@ bool PmpColumnReader::Init(const base::FilePath& filepath,
|
|
|
| DCHECK(length_ < kint32max); // ReadFile expects an int.
|
|
|
| - bool success = file_util::ReadFile(filepath, data_begin, length_) &&
|
| - ParseData(expected_type, rows_read);
|
| + bool success = base::ReadPlatformFile(file, 0, data_begin, length_) &&
|
| + ParseData(expected_type);
|
|
|
| if (!success)
|
| rows_ = 0; // If any of the reading or parsing fails, prevent Read* calls.
|
| @@ -104,8 +109,12 @@ bool PmpColumnReader::ReadUInt64(const uint32 row, uint64* result) const {
|
| return true;
|
| }
|
|
|
| -bool PmpColumnReader::ParseData(const PmpFieldType expected_type,
|
| - uint32* rows_read) {
|
| +uint32 PmpColumnReader::rows() const {
|
| + DCHECK(data_.get() != NULL);
|
| + return rows_;
|
| +}
|
| +
|
| +bool PmpColumnReader::ParseData(const PmpFieldType expected_type) {
|
| DCHECK(data_.get() != NULL);
|
| DCHECK_GE(length_, kPmpHeaderSize);
|
|
|
| @@ -161,8 +170,6 @@ bool PmpColumnReader::ParseData(const PmpFieldType expected_type,
|
| break;
|
| }
|
|
|
| - if (body_length == expected_body_length && rows_read)
|
| - *rows_read = rows_;
|
| return body_length == expected_body_length;
|
| }
|
|
|
|
|