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

Unified Diff: chrome/browser/media_galleries/fileapi/picasa/pmp_column_reader.cc

Issue 17101030: Media Galleries API - Picasa: Change PMP Parsing to deal with PlatformFile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 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: 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..35e48a970da0aa498ce64476df63cc0133804b93 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,19 @@ 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 +48,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 +108,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 +169,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;
}

Powered by Google App Engine
This is Rietveld 408576698