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

Unified Diff: webkit/fileapi/media/picasa/pmp_test_helper.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: Missing include. 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_test_helper.cc
diff --git a/webkit/fileapi/media/picasa/pmp_test_helper.cc b/webkit/fileapi/media/picasa/pmp_test_helper.cc
index 955efc66403d17272d065f9e211e01a3ace6ff39..c3f31fc3788a31fa85be0227ca8da96ccce47f9d 100644
--- a/webkit/fileapi/media/picasa/pmp_test_helper.cc
+++ b/webkit/fileapi/media/picasa/pmp_test_helper.cc
@@ -10,7 +10,6 @@
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "webkit/fileapi/media/picasa/pmp_column_reader.h"
-#include "webkit/fileapi/media/picasa/pmp_constants.h"
namespace picasaimport {
@@ -59,7 +58,7 @@ std::vector<uint8> CombinedVectors(const std::vector<uint8>& a,
} // namespace
-PmpTestHelper::PmpTestHelper() { }
+PmpTestHelper::PmpTestHelper() {}
bool PmpTestHelper::Init() {
return temp_dir_.CreateUniqueTempDir();
@@ -72,8 +71,8 @@ base::FilePath PmpTestHelper::GetTempDirPath() {
template<class T>
bool PmpTestHelper::WriteColumnFileFromVector(
- std::string table_name, std::string column_name, const uint16 field_type,
- std::vector<T> elements_vector) {
+ std::string table_name, std::string column_name,
+ const PmpFieldType field_type, std::vector<T> elements_vector) {
DCHECK(temp_dir_.IsValid());
std::string file_name = table_name + "_" + column_name + "." + kPmpExtension;
@@ -92,18 +91,19 @@ bool PmpTestHelper::WriteColumnFileFromVector(
// Explicit Instantiation for all the valid types.
template bool PmpTestHelper::WriteColumnFileFromVector<std::string>(
- std::string, std::string, const uint16, std::vector<std::string>);
+ std::string, std::string, const PmpFieldType, std::vector<std::string>);
template bool PmpTestHelper::WriteColumnFileFromVector<uint32>(
- std::string, std::string, const uint16, std::vector<uint32>);
+ std::string, std::string, const PmpFieldType, std::vector<uint32>);
template bool PmpTestHelper::WriteColumnFileFromVector<double>(
- std::string, std::string, const uint16, std::vector<double>);
+ std::string, std::string, const PmpFieldType, std::vector<double>);
template bool PmpTestHelper::WriteColumnFileFromVector<uint8>(
- std::string, std::string, const uint16, std::vector<uint8>);
+ std::string, std::string, const PmpFieldType, std::vector<uint8>);
template bool PmpTestHelper::WriteColumnFileFromVector<uint64>(
- std::string, std::string, const uint16, std::vector<uint64>);
+ std::string, std::string, const PmpFieldType, std::vector<uint64>);
bool PmpTestHelper::InitColumnReaderFromBytes(
- PmpColumnReader* const reader, std::vector<uint8> data, uint32* rows_read) {
+ PmpColumnReader* const reader, std::vector<uint8> data,
+ const PmpFieldType expected_type, uint32* rows_read) {
DCHECK(temp_dir_.IsValid());
base::FilePath temp_path;
@@ -113,7 +113,7 @@ bool PmpTestHelper::InitColumnReaderFromBytes(
return false;
}
- bool success = reader->Init(temp_path, rows_read);
+ bool success = reader->Init(temp_path, expected_type, rows_read);
file_util::Delete(temp_path, true);
@@ -122,7 +122,7 @@ bool PmpTestHelper::InitColumnReaderFromBytes(
}
// Return a vector so we don't have to worry about memory management.
-std::vector<uint8> PmpTestHelper::MakeHeader(const uint16 field_type,
+std::vector<uint8> PmpTestHelper::MakeHeader(const PmpFieldType field_type,
const uint32 row_count) {
std::vector<uint8> header(picasaimport::kPmpHeaderSize);
@@ -137,18 +137,21 @@ std::vector<uint8> PmpTestHelper::MakeHeader(const uint16 field_type,
sizeof(picasaimport::kPmpMagic4));
// Copy in field type.
- memcpy(&header[picasaimport::kPmpFieldType1Offset], &field_type, 2);
- memcpy(&header[picasaimport::kPmpFieldType2Offset], &field_type, 2);
+ uint16 field_type_short = static_cast<uint16>(field_type);
+ memcpy(&header[picasaimport::kPmpFieldType1Offset], &field_type_short,
+ sizeof(uint16));
+ memcpy(&header[picasaimport::kPmpFieldType2Offset], &field_type_short,
+ sizeof(uint16));
// Copy in row count.
- memcpy(&header[picasaimport::kPmpRowCountOffset], &row_count, 4);
+ memcpy(&header[picasaimport::kPmpRowCountOffset], &row_count, sizeof(uint32));
return header;
}
template<class T>
std::vector<uint8> PmpTestHelper::MakeHeaderAndBody(
- const uint16 field_type, const uint32 row_count,
+ const PmpFieldType field_type, const uint32 row_count,
const std::vector<T>& elems) {
return CombinedVectors(PmpTestHelper::MakeHeader(field_type, row_count),
Flatten(elems));
@@ -156,14 +159,14 @@ std::vector<uint8> PmpTestHelper::MakeHeaderAndBody(
// Explicit Instantiation for all the valid types.
template std::vector<uint8> PmpTestHelper::MakeHeaderAndBody<std::string>(
- const uint16, const uint32, const std::vector<std::string>&);
+ const PmpFieldType, const uint32, const std::vector<std::string>&);
template std::vector<uint8> PmpTestHelper::MakeHeaderAndBody<uint32>(
- const uint16, const uint32, const std::vector<uint32>&);
+ const PmpFieldType, const uint32, const std::vector<uint32>&);
template std::vector<uint8> PmpTestHelper::MakeHeaderAndBody<double>(
- const uint16, const uint32, const std::vector<double>&);
+ const PmpFieldType, const uint32, const std::vector<double>&);
template std::vector<uint8> PmpTestHelper::MakeHeaderAndBody<uint8>(
- const uint16, const uint32, const std::vector<uint8>&);
+ const PmpFieldType, const uint32, const std::vector<uint8>&);
template std::vector<uint8> PmpTestHelper::MakeHeaderAndBody<uint64>(
- const uint16, const uint32, const std::vector<uint64>&);
+ const PmpFieldType, const uint32, const std::vector<uint64>&);
} // namespace picasaimport

Powered by Google App Engine
This is Rietveld 408576698