OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_CHROMEOS_GDATA_GDATA_PARSER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_PARSER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_PARSER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_PARSER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/string_piece.h" |
14 #include "base/time.h" | 15 #include "base/time.h" |
15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
16 | 17 |
17 class Profile; | 18 class Profile; |
18 namespace base { | 19 namespace base { |
19 class Value; | 20 class Value; |
20 class DictionaryValue; | 21 class DictionaryValue; |
| 22 template <class StructType> |
| 23 class JSONValueConverter; |
| 24 namespace internal { |
| 25 template <class NestedType> |
| 26 class RepeatedMessageConverter; |
| 27 } |
21 } | 28 } |
22 | 29 |
23 // Defines data elements of Google Documents API as described in | 30 // Defines data elements of Google Documents API as described in |
24 // http://code.google.com/apis/documents/. | 31 // http://code.google.com/apis/documents/. |
25 namespace gdata { | 32 namespace gdata { |
26 | 33 |
27 // Defines link (URL) of an entity (document, file, feed...). Each entity could | 34 // Defines link (URL) of an entity (document, file, feed...). Each entity could |
28 // have more than one link representing it. | 35 // have more than one link representing it. |
29 class Link { | 36 class Link { |
30 public: | 37 public: |
31 enum LinkType { | 38 enum LinkType { |
32 UNKNOWN, | 39 UNKNOWN, |
33 SELF, | 40 SELF, |
34 NEXT, | 41 NEXT, |
35 PARENT, | 42 PARENT, |
36 ALTERNATE, | 43 ALTERNATE, |
37 EDIT, | 44 EDIT, |
38 EDIT_MEDIA, | 45 EDIT_MEDIA, |
39 FEED, | 46 FEED, |
40 POST, | 47 POST, |
41 BATCH, | 48 BATCH, |
42 RESUMABLE_EDIT_MEDIA, | 49 RESUMABLE_EDIT_MEDIA, |
43 RESUMABLE_CREATE_MEDIA, | 50 RESUMABLE_CREATE_MEDIA, |
44 TABLES_FEED, | 51 TABLES_FEED, |
45 WORKSHEET_FEED, | 52 WORKSHEET_FEED, |
46 THUMBNAIL, | 53 THUMBNAIL, |
47 }; | 54 }; |
48 Link(); | 55 Link(); |
49 | 56 |
50 // Reads link fields from corresponding fields from |dictionary|. | 57 // Registers the mapping between JSON field names and the members in |
51 bool Parse(const base::DictionaryValue* dictionary); | 58 // this class. |
| 59 static void RegisterJSONConverter(base::JSONValueConverter<Link>* converter); |
52 | 60 |
53 // Type of the link. | 61 // Type of the link. |
54 LinkType type() const { return type_; } | 62 LinkType type() const { return type_; } |
55 | 63 |
56 // URL of the link. | 64 // URL of the link. |
57 const GURL& href() const { return href_; } | 65 const GURL& href() const { return href_; } |
58 | 66 |
59 // Title of the link. | 67 // Title of the link. |
60 const string16& title() const { return title_; } | 68 const string16& title() const { return title_; } |
61 | 69 |
62 // Link MIME type. | 70 // Link MIME type. |
63 const std::string& mime_type() const { return mime_type_; } | 71 const std::string& mime_type() const { return mime_type_; } |
64 | 72 |
65 private: | 73 private: |
66 // Converts value of link.rel into LinkType. | 74 // Converts value of link.rel into LinkType. Outputs to |result| and |
67 static LinkType GetLinkType(const std::string& rel); | 75 // returns true when |rel| has a valid value. Otherwise does nothing |
| 76 // and returns false. |
| 77 static bool GetLinkType(const base::StringPiece& rel, LinkType* result); |
68 | 78 |
69 LinkType type_; | 79 LinkType type_; |
70 GURL href_; | 80 GURL href_; |
71 string16 title_; | 81 string16 title_; |
72 std::string mime_type_; | 82 std::string mime_type_; |
73 | 83 |
74 static const char kHrefField[]; | 84 static const char kHrefField[]; |
75 static const char kRelField[]; | 85 static const char kRelField[]; |
76 static const char kTitleField[]; | 86 static const char kTitleField[]; |
77 static const char kTypeField[]; | 87 static const char kTypeField[]; |
| 88 |
| 89 DISALLOW_COPY_AND_ASSIGN(Link); |
78 }; | 90 }; |
79 | 91 |
80 // Feed links define links (URLs) to special list of entries (i.e. list of | 92 // Feed links define links (URLs) to special list of entries (i.e. list of |
81 // previous document revisions). | 93 // previous document revisions). |
82 class FeedLink { | 94 class FeedLink { |
83 public: | 95 public: |
84 enum FeedLinkType { | 96 enum FeedLinkType { |
85 UNKNOWN, | 97 UNKNOWN, |
86 ACL, | 98 ACL, |
87 REVISIONS, | 99 REVISIONS, |
88 }; | 100 }; |
89 FeedLink(); | 101 FeedLink(); |
90 | 102 |
91 // Reads link details from corresponding fields from |dictionary|. | 103 // Registers the mapping between JSON field names and the members in |
92 bool Parse(const base::DictionaryValue* dictionary); | 104 // this class. |
| 105 static void RegisterJSONConverter( |
| 106 base::JSONValueConverter<FeedLink>* converter); |
93 | 107 |
94 // URL of the feed. | 108 // URL of the feed. |
95 FeedLinkType type() const { return type_; } | 109 FeedLinkType type() const { return type_; } |
96 | 110 |
97 // MIME type of the feed. | 111 // MIME type of the feed. |
98 const GURL& href() const { return href_; } | 112 const GURL& href() const { return href_; } |
99 | 113 |
100 private: | 114 private: |
101 // Converts value of gd$feedLink.rel into FeedLinkType enum. | 115 // Converts value of gd$feedLink.rel into FeedLinkType enum. |
102 static FeedLinkType GetFeedLinkType(const std::string& rel); | 116 // Outputs to |result| and returns true when |rel| has a valid |
| 117 // value. Otherwise does nothing and returns false. |
| 118 static bool GetFeedLinkType( |
| 119 const base::StringPiece& rel, FeedLinkType* result); |
103 | 120 |
104 FeedLinkType type_; | 121 FeedLinkType type_; |
105 GURL href_; | 122 GURL href_; |
106 | 123 |
107 static const char kHrefField[]; | 124 static const char kHrefField[]; |
108 static const char kRelField[]; | 125 static const char kRelField[]; |
| 126 |
| 127 DISALLOW_COPY_AND_ASSIGN(FeedLink); |
109 }; | 128 }; |
110 | 129 |
| 130 // Author represents an author of an entity. |
111 class Author { | 131 class Author { |
112 public: | 132 public: |
113 Author(); | 133 Author(); |
114 | 134 |
115 // Reads author details from corresponding fields from |dictionary|. | 135 // Registers the mapping between JSON field names and the members in |
116 bool Parse(const base::DictionaryValue* dictionary); | 136 // this class. |
| 137 static void RegisterJSONConverter( |
| 138 base::JSONValueConverter<Author>* converter); |
117 | 139 |
118 // Getters. | 140 // Getters. |
119 const string16& name() const { return name_; } | 141 const string16& name() const { return name_; } |
120 const std::string& email() const { return email_; } | 142 const std::string& email() const { return email_; } |
121 | 143 |
122 private: | 144 private: |
123 string16 name_; | 145 string16 name_; |
124 std::string email_; | 146 std::string email_; |
125 static const char kNameField[]; | 147 static const char kNameField[]; |
126 static const char kEmailField[]; | 148 static const char kEmailField[]; |
| 149 |
| 150 DISALLOW_COPY_AND_ASSIGN(Author); |
127 }; | 151 }; |
128 | 152 |
129 // Entry category. | 153 // Entry category. |
130 class Category { | 154 class Category { |
131 public: | 155 public: |
132 enum CategoryType { | 156 enum CategoryType { |
133 UNKNOWN, | 157 UNKNOWN, |
134 ITEM, | 158 ITEM, |
135 KIND, | 159 KIND, |
136 LABEL, | 160 LABEL, |
137 }; | 161 }; |
138 Category(); | 162 Category(); |
139 | 163 |
140 // Reads category details from corresponding fields from |dictionary|. | 164 // Registers the mapping between JSON field names and the members in |
141 bool Parse(const base::DictionaryValue* dictionary); | 165 // this class. |
| 166 static void RegisterJSONConverter( |
| 167 base::JSONValueConverter<Category>* converter); |
142 | 168 |
143 // Category label. | 169 // Category label. |
144 const string16& label() const { return label_; } | 170 const string16& label() const { return label_; } |
145 | 171 |
146 // Category type. | 172 // Category type. |
147 CategoryType type() const { return type_; } | 173 CategoryType type() const { return type_; } |
148 | 174 |
149 // Category term. | 175 // Category term. |
150 const std::string& term() const { return term_; } | 176 const std::string& term() const { return term_; } |
151 | 177 |
152 private: | 178 private: |
153 // Converts catory scheme into CategoryType enum. For example, | 179 // Converts catory scheme into CategoryType enum. For example, |
154 // http://schemas.google.com/g/2005#kind => Category::KIND | 180 // http://schemas.google.com/g/2005#kind => Category::KIND |
155 CategoryType GetCategoryTypeFromScheme(const std::string& scheme); | 181 // Returns false and does not change |result| when |scheme| has an |
| 182 // unrecognizable value. |
| 183 static bool GetCategoryTypeFromScheme( |
| 184 const base::StringPiece& scheme, CategoryType* result); |
156 | 185 |
157 string16 label_; | 186 string16 label_; |
158 CategoryType type_; | 187 CategoryType type_; |
159 std::string term_; | 188 std::string term_; |
160 | |
161 static const char kLabelField[]; | 189 static const char kLabelField[]; |
162 static const char kSchemeField[]; | 190 static const char kSchemeField[]; |
163 static const char kTermField[]; | 191 static const char kTermField[]; |
| 192 |
| 193 DISALLOW_COPY_AND_ASSIGN(Category); |
| 194 }; |
| 195 |
| 196 // Content details of a document: mime-type, url, and so on. |
| 197 class Content { |
| 198 public: |
| 199 Content(); |
| 200 |
| 201 // Registers the mapping between JSON field names and the members in |
| 202 // this class. |
| 203 static void RegisterJSONConverter( |
| 204 base::JSONValueConverter<Content>* converter); |
| 205 |
| 206 const GURL& url() const { return url_; } |
| 207 const std::string& mime_type() const { return mime_type_; } |
| 208 |
| 209 private: |
| 210 GURL url_; |
| 211 std::string mime_type_; |
| 212 |
| 213 static const char kSrcField[]; |
| 214 static const char kTypeField[]; |
| 215 |
| 216 DISALLOW_COPY_AND_ASSIGN(Content); |
164 }; | 217 }; |
165 | 218 |
166 // Base class for feed entries. | 219 // Base class for feed entries. |
167 class GDataEntry { | 220 class GDataEntry { |
168 public: | 221 public: |
169 GDataEntry(); | 222 GDataEntry(); |
170 virtual ~GDataEntry(); | 223 virtual ~GDataEntry(); |
171 | 224 |
172 // Returns a link of a given |type| for this entry. If not found, it returns | 225 // Returns a link of a given |type| for this entry. If not found, it returns |
173 // NULL. | 226 // NULL. |
174 const Link* GetLinkByType(Link::LinkType type) const; | 227 const Link* GetLinkByType(Link::LinkType type) const; |
175 | 228 |
176 // Entry update time. | 229 // Entry update time. |
177 base::Time updated_time() const { return updated_time_; } | 230 base::Time updated_time() const { return updated_time_; } |
178 | 231 |
179 // Entry ETag. | 232 // Entry ETag. |
180 const std::string& etag() const { return etag_; } | 233 const std::string& etag() const { return etag_; } |
181 | 234 |
182 // List of entry authors. | 235 // List of entry authors. |
183 const ScopedVector<Author>& authors() const { return authors_; } | 236 const ScopedVector<Author>& authors() const { return authors_; } |
184 | 237 |
185 // List of entry links. | 238 // List of entry links. |
186 const ScopedVector<Link>& links() const { return links_; } | 239 const ScopedVector<Link>& links() const { return links_; } |
187 | 240 |
188 // List of entry categories. | 241 // List of entry categories. |
189 const ScopedVector<Category>& categories() const { return categories_; } | 242 const ScopedVector<Category>& categories() const { return categories_; } |
190 | 243 |
191 // Returns true when time string (in format yyyy-mm-ddThh:mm:ss.dddZ), is | 244 // Returns true when time string (in format yyyy-mm-ddThh:mm:ss.dddZ), is |
192 // successfully parsed and output as |time|. | 245 // successfully parsed and output as |time|. |
193 static bool GetTimeFromString(const std::string& raw_value, base::Time* time); | 246 static bool GetTimeFromString( |
| 247 const base::StringPiece& raw_value, base::Time* time); |
| 248 |
| 249 // Registers the mapping between JSON field names and the members in |
| 250 // this class. |
| 251 static void RegisterJSONConverter( |
| 252 base::JSONValueConverter<GDataEntry>* converter); |
194 | 253 |
195 protected: | 254 protected: |
196 // Handler method, invoked when a new category is added to the entry. | |
197 virtual void OnAddCategory(Category* category) {} | |
198 | |
199 // Parses links from |dictionary|. | |
200 bool ParseLinks(const base::DictionaryValue* dictionary); | |
201 | |
202 // Parses categories from |dictionary|. | |
203 bool ParseCategories(const base::DictionaryValue* dictionary); | |
204 | |
205 // Parses authors from |dictionary|. | |
206 bool ParseAuthors(const base::DictionaryValue* dictionary); | |
207 | |
208 // Returns true when time string (in format yyyy-mm-ddThh:mm:ss.dddZ), is | |
209 // successfully parsed and output as |time|. | |
210 static bool ParseDateTime(const base::DictionaryValue* dict, | |
211 const std::string& field, | |
212 base::Time* time); | |
213 | |
214 std::string etag_; | 255 std::string etag_; |
215 ScopedVector<Author> authors_; | 256 ScopedVector<Author> authors_; |
216 ScopedVector<Link> links_; | 257 ScopedVector<Link> links_; |
217 ScopedVector<Category> categories_; | 258 ScopedVector<Category> categories_; |
218 base::Time updated_time_; | 259 base::Time updated_time_; |
219 | 260 |
220 static const char kTimeParsingDelimiters[]; | 261 static const char kTimeParsingDelimiters[]; |
221 static const char kAuthorField[]; | 262 static const char kAuthorField[]; |
222 static const char kLinkField[]; | 263 static const char kLinkField[]; |
223 static const char kCategoryField[]; | 264 static const char kCategoryField[]; |
| 265 static const char kUpdatedField[]; |
| 266 static const char kETagField[]; |
| 267 |
| 268 DISALLOW_COPY_AND_ASSIGN(GDataEntry); |
224 }; | 269 }; |
225 | 270 |
226 // Document feed entry. | 271 // Document feed entry. |
227 class DocumentEntry : public GDataEntry { | 272 class DocumentEntry : public GDataEntry { |
228 public: | 273 public: |
229 enum EntryKind { | 274 enum EntryKind { |
230 UNKNOWN, | 275 UNKNOWN, |
231 ITEM, | 276 ITEM, |
232 DOCUMENT, | 277 DOCUMENT, |
233 SPREADSHEET, | 278 SPREADSHEET, |
234 PRESENTATION, | 279 PRESENTATION, |
235 FOLDER, | 280 FOLDER, |
236 FILE, | 281 FILE, |
237 PDF, | 282 PDF, |
238 }; | 283 }; |
239 virtual ~DocumentEntry(); | 284 virtual ~DocumentEntry(); |
240 // Creates document entry from parsed JSON Value. | 285 |
| 286 // Creates document entry from parsed JSON Value. You should call |
| 287 // this instead of instantiating JSONValueConverter by yourself |
| 288 // because this method does some post-process for some fields. See |
| 289 // FillRemainingFields comment and implementation for the details. |
241 static DocumentEntry* CreateFrom(base::Value* value); | 290 static DocumentEntry* CreateFrom(base::Value* value); |
242 | 291 |
| 292 // Registers the mapping between JSON field names and the members in |
| 293 // this class. |
| 294 static void RegisterJSONConverter( |
| 295 base::JSONValueConverter<DocumentEntry>* converter); |
| 296 |
243 // Document entry resource id. | 297 // Document entry resource id. |
244 const std::string& resource_id() const { return resource_id_; } | 298 const std::string& resource_id() const { return resource_id_; } |
245 | 299 |
246 // Document entry id. | 300 // Document entry id. |
247 const std::string& id() const { return id_; } | 301 const std::string& id() const { return id_; } |
248 | 302 |
249 // Document entry kind. | 303 // Document entry kind. |
250 EntryKind kind() const { return kind_; } | 304 EntryKind kind() const { return kind_; } |
251 | 305 |
252 // Document entry title. | 306 // Document entry title. |
253 const string16& title() const { return title_; } | 307 const string16& title() const { return title_; } |
254 | 308 |
255 // Document entry published time. | 309 // Document entry published time. |
256 base::Time published_time() const { return published_time_; } | 310 base::Time published_time() const { return published_time_; } |
257 | 311 |
258 // List of document feed labels. | 312 // List of document feed labels. |
259 const std::vector<string16>& labels() const { return labels_; } | 313 const std::vector<string16>& labels() const { return labels_; } |
260 | 314 |
261 // Document entry content URL. | 315 // Document entry content URL. |
262 const GURL& content_url() const { return content_url_; } | 316 const GURL& content_url() const { return content_.url(); } |
263 | 317 |
264 // Document entry MIME type. | 318 // Document entry MIME type. |
265 const std::string& content_mime_type() const { return content_mime_type_; } | 319 const std::string& content_mime_type() const { return content_.mime_type(); } |
266 | 320 |
267 // List of document feed links. | 321 // List of document feed links. |
268 const ScopedVector<FeedLink>& feed_links() const { return feed_links_; } | 322 const ScopedVector<FeedLink>& feed_links() const { return feed_links_; } |
269 | 323 |
270 // Document feed file name (exists only for kinds FILE and PDF). | 324 // Document feed file name (exists only for kinds FILE and PDF). |
271 const string16& filename() const { return filename_; } | 325 const string16& filename() const { return filename_; } |
272 | 326 |
273 // Document feed suggested file name (exists only for kinds FILE and PDF). | 327 // Document feed suggested file name (exists only for kinds FILE and PDF). |
274 const string16& suggested_filename() const { return suggested_filename_; } | 328 const string16& suggested_filename() const { return suggested_filename_; } |
275 | 329 |
276 // Document feed file content MD5 (exists only for kinds FILE and PDF). | 330 // Document feed file content MD5 (exists only for kinds FILE and PDF). |
277 const std::string& file_md5() const { return file_md5_; } | 331 const std::string& file_md5() const { return file_md5_; } |
278 | 332 |
279 // Document feed file size (exists only for kinds FILE and PDF). | 333 // Document feed file size (exists only for kinds FILE and PDF). |
280 int64 file_size() const { return file_size_; } | 334 int64 file_size() const { return file_size_; } |
281 | 335 |
282 private: | 336 private: |
| 337 friend class base::internal::RepeatedMessageConverter<DocumentEntry>; |
| 338 friend class DocumentFeed; |
| 339 |
283 DocumentEntry(); | 340 DocumentEntry(); |
284 | 341 |
285 // Parses and initializes data members from content of |dictionary|. Returns | 342 // Fills the remaining fields where JSONValueConverter cannot catch. |
286 // false if parsing fails. | 343 void FillRemainingFields(); |
287 bool Parse(const base::DictionaryValue* dictionary); | |
288 | 344 |
289 // Parses properties for file entry from |dictionary|. | |
290 bool ParseFileProperties(const base::DictionaryValue* dictionary); | |
291 | |
292 // Parses content properties from |dictionary|. | |
293 bool ParseContent(const base::DictionaryValue* dictionary); | |
294 | |
295 // Parses feed links from |dictionary|. | |
296 bool ParseFeedLinks(const base::DictionaryValue* dictionary); | |
297 | |
298 // GDataEntry overrides. | |
299 virtual void OnAddCategory(Category* category) OVERRIDE; | |
300 // Converts categories.term into EntryKind enum. | 345 // Converts categories.term into EntryKind enum. |
301 static EntryKind GetEntryKindFromTerm(const std::string& term); | 346 static EntryKind GetEntryKindFromTerm(const std::string& term); |
302 | 347 |
303 std::string resource_id_; | 348 std::string resource_id_; |
304 std::string id_; | 349 std::string id_; |
305 EntryKind kind_; | 350 EntryKind kind_; |
306 string16 title_; | 351 string16 title_; |
307 base::Time published_time_; | 352 base::Time published_time_; |
308 std::vector<string16> labels_; | 353 std::vector<string16> labels_; |
309 GURL content_url_; | 354 Content content_; |
310 std::string content_mime_type_; | |
311 ScopedVector<FeedLink> feed_links_; | 355 ScopedVector<FeedLink> feed_links_; |
312 // Optional fields for files only. | 356 // Optional fields for files only. |
313 string16 filename_; | 357 string16 filename_; |
314 string16 suggested_filename_; | 358 string16 suggested_filename_; |
315 std::string file_md5_; | 359 std::string file_md5_; |
316 int64 file_size_; | 360 int64 file_size_; |
317 | 361 |
318 static const char kFeedLinkField[]; | 362 static const char kFeedLinkField[]; |
319 static const char kContentField[]; | 363 static const char kContentField[]; |
320 static const char kSrcField[]; | |
321 static const char kTypeField[]; | |
322 static const char kFileNameField[]; | 364 static const char kFileNameField[]; |
323 static const char kMD5Field[]; | 365 static const char kMD5Field[]; |
324 static const char kSizeField[]; | 366 static const char kSizeField[]; |
325 static const char kSuggestedFileNameField[]; | 367 static const char kSuggestedFileNameField[]; |
326 static const char kETagField[]; | |
327 static const char kResourceIdField[]; | 368 static const char kResourceIdField[]; |
328 static const char kIDField[]; | 369 static const char kIDField[]; |
329 static const char kTitleField[]; | 370 static const char kTitleField[]; |
330 static const char kUpdatedField[]; | |
331 static const char kPublishedField[]; | 371 static const char kPublishedField[]; |
| 372 |
| 373 DISALLOW_COPY_AND_ASSIGN(DocumentEntry); |
332 }; | 374 }; |
333 | 375 |
334 // Document feed represents a list of entries. The feed is paginated and | 376 // Document feed represents a list of entries. The feed is paginated and |
335 // the rest of the feed can be fetched by retrieving the remaining parts of the | 377 // the rest of the feed can be fetched by retrieving the remaining parts of the |
336 // feed from URLs provided by GetNextFeedURL() method. | 378 // feed from URLs provided by GetNextFeedURL() method. |
337 class DocumentFeed : public GDataEntry { | 379 class DocumentFeed : public GDataEntry { |
338 public: | 380 public: |
339 virtual ~DocumentFeed(); | 381 virtual ~DocumentFeed(); |
340 | 382 |
341 // Creates feed from parsed JSON Value. | 383 // Creates feed from parsed JSON Value. You should call this |
| 384 // instead of instantiating JSONValueConverter by yourself because |
| 385 // this method does some post-process for some fields. See |
| 386 // FillRemainingFields comment and implementation in DocumentEntry |
| 387 // class for the details. |
342 static DocumentFeed* CreateFrom(base::Value* value); | 388 static DocumentFeed* CreateFrom(base::Value* value); |
343 | 389 |
| 390 // Registers the mapping between JSON field names and the members in |
| 391 // this class. |
| 392 static void RegisterJSONConverter( |
| 393 base::JSONValueConverter<DocumentFeed>* converter); |
| 394 |
344 // Returns true and passes|url| of the next feed if the current entry list | 395 // Returns true and passes|url| of the next feed if the current entry list |
345 // does not completed this feed. | 396 // does not completed this feed. |
346 bool GetNextFeedURL(GURL* url); | 397 bool GetNextFeedURL(GURL* url); |
347 | 398 |
348 // List of document entries. | 399 // List of document entries. |
349 const ScopedVector<DocumentEntry>& entries() const { return entries_; } | 400 const ScopedVector<DocumentEntry>& entries() const { return entries_; } |
350 | 401 |
351 // Start index of the document entry list. | 402 // Start index of the document entry list. |
352 int start_index() const { return start_index_; } | 403 int start_index() const { return start_index_; } |
353 | 404 |
354 // Number of items per feed of the document entry list. | 405 // Number of items per feed of the document entry list. |
355 int items_per_page() const { return items_per_page_; } | 406 int items_per_page() const { return items_per_page_; } |
356 | 407 |
357 // Document entry list title. | 408 // Document entry list title. |
358 const std::string& title() { return title_; } | 409 const std::string& title() { return title_; } |
359 | 410 |
360 private: | 411 private: |
361 DocumentFeed(); | 412 DocumentFeed(); |
362 // Parses and initializes data members from content of |dictionary|. Returns | 413 |
363 // false if parsing fails. | 414 // Parses and initializes data members from content of |value|. |
364 bool Parse(const base::DictionaryValue* dictionary); | 415 // Return false if parsing fails. |
| 416 bool Parse(base::Value* value); |
365 | 417 |
366 ScopedVector<DocumentEntry> entries_; | 418 ScopedVector<DocumentEntry> entries_; |
367 int start_index_; | 419 int start_index_; |
368 int items_per_page_; | 420 int items_per_page_; |
369 std::string title_; | 421 std::string title_; |
370 | 422 |
371 static const char kETagField[]; | |
372 static const char kStartIndexField[]; | 423 static const char kStartIndexField[]; |
373 static const char kItemsPerPageField[]; | 424 static const char kItemsPerPageField[]; |
374 static const char kUpdatedField[]; | |
375 static const char kTitleField[]; | 425 static const char kTitleField[]; |
376 static const char kEntryField[]; | 426 static const char kEntryField[]; |
| 427 |
| 428 DISALLOW_COPY_AND_ASSIGN(DocumentFeed); |
377 }; | 429 }; |
378 | 430 |
379 } // namespace gdata | 431 } // namespace gdata |
380 | 432 |
381 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_PARSER_H_ | 433 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_PARSER_H_ |
OLD | NEW |