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

Side by Side Diff: webkit/fileapi/media/picasa/pmp_column_reader.h

Issue 13529028: PicasaAlbumTableReader for Media Galleries API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0005-picasa-import-pmp-reader
Patch Set: Fix ifdef guard. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_FILEAPI_MEDIA_PICASA_PMP_COLUMN_READER_H_ 5 #ifndef WEBKIT_FILEAPI_MEDIA_PICASA_PMP_COLUMN_READER_H_
6 #define WEBKIT_FILEAPI_MEDIA_PICASA_PMP_COLUMN_READER_H_ 6 #define WEBKIT_FILEAPI_MEDIA_PICASA_PMP_COLUMN_READER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "webkit/fileapi/media/picasa/pmp_constants.h" 13 #include "webkit/fileapi/media/picasa/pmp_constants.h"
14 #include "webkit/storage/webkit_storage_export.h" 14 #include "webkit/storage/webkit_storage_export.h"
15 15
16 namespace base { 16 namespace base {
17 class FilePath; 17 class FilePath;
18 } 18 }
19 19
20 namespace picasaimport { 20 namespace picasaimport {
21 21
22 // Reads a single PMP column from a file. 22 // Reads a single PMP column from a file.
23 class WEBKIT_STORAGE_EXPORT_PRIVATE PmpColumnReader { 23 class WEBKIT_STORAGE_EXPORT_PRIVATE PmpColumnReader {
24 public: 24 public:
25 PmpColumnReader(); 25 PmpColumnReader();
26 virtual ~PmpColumnReader(); 26 virtual ~PmpColumnReader();
27 27
28 // Returns true if read successfully. 28 // Returns true if read successfully.
29 // |rows_read| is undefined if returns false. 29 // |rows_read| is undefined if returns false.
30 bool Init(const base::FilePath& filepath, uint32* rows_read); 30 bool Init(const base::FilePath& filepath, const PmpFieldType expected_type,
31 uint32* rows_read);
31 32
32 // These functions read the value of that |row| into |result|. 33 // These functions read the value of that |row| into |result|.
33 // Functions return false if the column is of the wrong type or the row 34 // Functions return false if the column is of the wrong type or the row
34 // is out of range. 35 // is out of range.
35 bool ReadString(const uint32 row, std::string* result) const; 36 bool ReadString(const uint32 row, std::string* result) const;
36 bool ReadUInt32(const uint32 row, uint32* result) const; 37 bool ReadUInt32(const uint32 row, uint32* result) const;
37 bool ReadDouble64(const uint32 row, double* result) const; 38 bool ReadDouble64(const uint32 row, double* result) const;
38 bool ReadUInt8(const uint32 row, uint8* result) const; 39 bool ReadUInt8(const uint32 row, uint8* result) const;
39 bool ReadUInt64(const uint32 row, uint64* result) const; 40 bool ReadUInt64(const uint32 row, uint64* result) const;
40 41
41 // Returns the native encoding of field_type.
42 PmpFieldType field_type() const {
43 return field_type_;
44 }
45
46 private: 42 private:
47 bool ParseData(uint32* rows_read); 43 bool ParseData(const PmpFieldType expected_type, uint32* rows_read);
48 // Returns the number of bytes parsed in the body, or, -1 on failure. 44 // Returns the number of bytes parsed in the body, or, -1 on failure.
49 long IndexStrings(); 45 long IndexStrings();
50 46
51 // Source data 47 // Source data
52 scoped_array<uint8> data_; 48 scoped_array<uint8> data_;
53 size_t length_; 49 size_t length_;
54 50
55 // Header data 51 // Header data
56 PmpFieldType field_type_; 52 PmpFieldType field_type_;
57 uint32 rows_; 53 uint32 rows_;
58 54
59 // Index of string start locations if fields are strings. Empty otherwise. 55 // Index of string start locations if fields are strings. Empty otherwise.
60 std::vector<const char*> strings_; 56 std::vector<const char*> strings_;
61 57
62 DISALLOW_COPY_AND_ASSIGN(PmpColumnReader); 58 DISALLOW_COPY_AND_ASSIGN(PmpColumnReader);
63 }; 59 };
64 60
65 } // namespace picasaimport 61 } // namespace picasaimport
66 62
67 #endif // WEBKIT_FILEAPI_MEDIA_PICASA_PMP_COLUMN_READER_H_ 63 #endif // WEBKIT_FILEAPI_MEDIA_PICASA_PMP_COLUMN_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698