OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_PARSER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_PARSER_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/compiler_specific.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/memory/scoped_vector.h" | |
14 #include "base/string_piece.h" | |
15 #include "base/time.h" | |
16 #include "googleurl/src/gurl.h" | |
17 | |
18 class FilePath; | |
19 class Profile; | |
20 class XmlReader; | |
21 | |
22 namespace base { | |
23 class Value; | |
24 class DictionaryValue; | |
25 template <class StructType> | |
26 class JSONValueConverter; | |
27 | |
28 namespace internal { | |
29 template <class NestedType> | |
30 class RepeatedMessageConverter; | |
31 } // namespace internal | |
32 | |
33 } // namespace base | |
34 | |
35 // Defines data elements of Google Documents API as described in | |
36 // http://code.google.com/apis/documents/. | |
37 namespace gdata { | |
38 | |
39 // Defines link (URL) of an entity (document, file, feed...). Each entity could | |
40 // have more than one link representing it. | |
41 class Link { | |
42 public: | |
43 enum LinkType { | |
44 UNKNOWN, | |
45 SELF, | |
46 NEXT, | |
47 PARENT, | |
48 ALTERNATE, | |
49 EDIT, | |
50 EDIT_MEDIA, | |
51 ALT_EDIT_MEDIA, | |
52 ALT_POST, | |
53 FEED, | |
54 POST, | |
55 BATCH, | |
56 RESUMABLE_EDIT_MEDIA, | |
57 RESUMABLE_CREATE_MEDIA, | |
58 TABLES_FEED, | |
59 WORKSHEET_FEED, | |
60 THUMBNAIL, | |
61 EMBED, | |
62 PRODUCT, | |
63 ICON, | |
64 OPEN_WITH, | |
65 }; | |
66 Link(); | |
67 ~Link(); | |
68 | |
69 // Registers the mapping between JSON field names and the members in | |
70 // this class. | |
71 static void RegisterJSONConverter(base::JSONValueConverter<Link>* converter); | |
72 | |
73 // Creates document entry from parsed XML. | |
74 static Link* CreateFromXml(XmlReader* xml_reader); | |
75 | |
76 // Type of the link. | |
77 LinkType type() const { return type_; } | |
78 | |
79 // URL of the link. | |
80 const GURL& href() const { return href_; } | |
81 | |
82 // Title of the link. | |
83 const string16& title() const { return title_; } | |
84 | |
85 // For OPEN_WITH links, this contains the application ID. For all other link | |
86 // types, it is the empty string. | |
87 const std::string& app_id() const { return app_id_; } | |
88 | |
89 // Link MIME type. | |
90 const std::string& mime_type() const { return mime_type_; } | |
91 | |
92 private: | |
93 friend class DocumentEntry; | |
94 // Converts value of link.rel into LinkType. Outputs to |type| and returns | |
95 // true when |rel| has a valid value. Otherwise does nothing and returns | |
96 // false. | |
97 static bool GetLinkType(const base::StringPiece& rel, LinkType* type); | |
98 | |
99 // Converts value of link.rel to application ID, if there is one embedded in | |
100 // the link.rel field. Outputs to |app_id| and returns true when |rel| has a | |
101 // valid value. Otherwise does nothing and returns false. | |
102 static bool GetAppID(const base::StringPiece& rel, std::string* app_id); | |
103 | |
104 | |
105 LinkType type_; | |
106 GURL href_; | |
107 string16 title_; | |
108 std::string app_id_; | |
109 std::string mime_type_; | |
110 | |
111 DISALLOW_COPY_AND_ASSIGN(Link); | |
112 }; | |
113 | |
114 // Feed links define links (URLs) to special list of entries (i.e. list of | |
115 // previous document revisions). | |
116 class FeedLink { | |
117 public: | |
118 enum FeedLinkType { | |
119 UNKNOWN, | |
120 ACL, | |
121 REVISIONS, | |
122 }; | |
123 FeedLink(); | |
124 | |
125 // Registers the mapping between JSON field names and the members in | |
126 // this class. | |
127 static void RegisterJSONConverter( | |
128 base::JSONValueConverter<FeedLink>* converter); | |
129 | |
130 static FeedLink* CreateFromXml(XmlReader* xml_reader); | |
131 | |
132 // MIME type of the feed. | |
133 FeedLinkType type() const { return type_; } | |
134 | |
135 // URL of the feed. | |
136 const GURL& href() const { return href_; } | |
137 | |
138 private: | |
139 friend class DocumentEntry; | |
140 // Converts value of gd$feedLink.rel into FeedLinkType enum. | |
141 // Outputs to |result| and returns true when |rel| has a valid | |
142 // value. Otherwise does nothing and returns false. | |
143 static bool GetFeedLinkType( | |
144 const base::StringPiece& rel, FeedLinkType* result); | |
145 | |
146 FeedLinkType type_; | |
147 GURL href_; | |
148 | |
149 DISALLOW_COPY_AND_ASSIGN(FeedLink); | |
150 }; | |
151 | |
152 // Author represents an author of an entity. | |
153 class Author { | |
154 public: | |
155 Author(); | |
156 | |
157 // Registers the mapping between JSON field names and the members in | |
158 // this class. | |
159 static void RegisterJSONConverter( | |
160 base::JSONValueConverter<Author>* converter); | |
161 | |
162 static Author* CreateFromXml(XmlReader* xml_reader); | |
163 | |
164 // Getters. | |
165 const string16& name() const { return name_; } | |
166 const std::string& email() const { return email_; } | |
167 | |
168 private: | |
169 friend class DocumentEntry; | |
170 | |
171 string16 name_; | |
172 std::string email_; | |
173 | |
174 DISALLOW_COPY_AND_ASSIGN(Author); | |
175 }; | |
176 | |
177 // Entry category. | |
178 class Category { | |
179 public: | |
180 enum CategoryType { | |
181 UNKNOWN, | |
182 ITEM, | |
183 KIND, | |
184 LABEL, | |
185 }; | |
186 | |
187 Category(); | |
188 | |
189 // Registers the mapping between JSON field names and the members in | |
190 // this class. | |
191 static void RegisterJSONConverter( | |
192 base::JSONValueConverter<Category>* converter); | |
193 | |
194 static Category* CreateFromXml(XmlReader* xml_reader); | |
195 | |
196 // Category label. | |
197 const string16& label() const { return label_; } | |
198 | |
199 // Category type. | |
200 CategoryType type() const { return type_; } | |
201 | |
202 // Category term. | |
203 const std::string& term() const { return term_; } | |
204 | |
205 private: | |
206 friend class DocumentEntry; | |
207 // Converts category scheme into CategoryType enum. For example, | |
208 // http://schemas.google.com/g/2005#kind => Category::KIND | |
209 // Returns false and does not change |result| when |scheme| has an | |
210 // unrecognizable value. | |
211 static bool GetCategoryTypeFromScheme( | |
212 const base::StringPiece& scheme, CategoryType* result); | |
213 | |
214 string16 label_; | |
215 CategoryType type_; | |
216 std::string term_; | |
217 | |
218 DISALLOW_COPY_AND_ASSIGN(Category); | |
219 }; | |
220 | |
221 // Content details of a document: mime-type, url, and so on. | |
222 class Content { | |
223 public: | |
224 Content(); | |
225 | |
226 // Registers the mapping between JSON field names and the members in | |
227 // this class. | |
228 static void RegisterJSONConverter( | |
229 base::JSONValueConverter<Content>* converter); | |
230 | |
231 static Content* CreateFromXml(XmlReader* xml_reader); | |
232 | |
233 const GURL& url() const { return url_; } | |
234 const std::string& mime_type() const { return mime_type_; } | |
235 | |
236 private: | |
237 friend class DocumentEntry; | |
238 | |
239 GURL url_; | |
240 std::string mime_type_; | |
241 }; | |
242 | |
243 // This stores a representation of an application icon as registered with the | |
244 // installed applications section of the account metadata feed. There can be | |
245 // multiple icons registered for each application, differing in size, category | |
246 // and MIME type. | |
247 class AppIcon { | |
248 public: | |
249 enum IconCategory { | |
250 UNKNOWN, // Uninitialized state | |
251 DOCUMENT, // Document icon for various MIME types | |
252 APPLICATION, // Application icon for various MIME types | |
253 SHARED_DOCUMENT, // Icon for documents that are shared from other users. | |
254 }; | |
255 | |
256 AppIcon(); | |
257 ~AppIcon(); | |
258 | |
259 // Registers the mapping between JSON field names and the members in | |
260 // this class. | |
261 static void RegisterJSONConverter( | |
262 base::JSONValueConverter<AppIcon>* converter); | |
263 | |
264 // Category of the icon. | |
265 IconCategory category() const { return category_; } | |
266 | |
267 // Size in pixels of one side of the icon (icons are always square). | |
268 const int icon_side_length() const { return icon_side_length_; } | |
269 | |
270 // Get a list of links available for this AppIcon. | |
271 const ScopedVector<Link>& links() const { return links_; } | |
272 | |
273 // Get the icon URL from the internal list of links. Returns the first | |
274 // icon URL found in the list. | |
275 GURL GetIconURL() const; | |
276 | |
277 private: | |
278 // Extracts the icon category from the given string. Returns false and does | |
279 // not change |result| when |scheme| has an unrecognizable value. | |
280 static bool GetIconCategory(const base::StringPiece& category, | |
281 IconCategory* result); | |
282 | |
283 IconCategory category_; | |
284 int icon_side_length_; | |
285 ScopedVector<Link> links_; | |
286 | |
287 DISALLOW_COPY_AND_ASSIGN(AppIcon); | |
288 }; | |
289 | |
290 // Base class for feed entries. | |
291 class FeedEntry { | |
292 public: | |
293 FeedEntry(); | |
294 virtual ~FeedEntry(); | |
295 | |
296 // Returns a link of a given |type| for this entry. If not found, it returns | |
297 // NULL. | |
298 const Link* GetLinkByType(Link::LinkType type) const; | |
299 | |
300 // Entry update time. | |
301 base::Time updated_time() const { return updated_time_; } | |
302 | |
303 // Entry ETag. | |
304 const std::string& etag() const { return etag_; } | |
305 | |
306 // List of entry authors. | |
307 const ScopedVector<Author>& authors() const { return authors_; } | |
308 | |
309 // List of entry links. | |
310 const ScopedVector<Link>& links() const { return links_; } | |
311 | |
312 // List of entry categories. | |
313 const ScopedVector<Category>& categories() const { return categories_; } | |
314 | |
315 // Returns true when time string (in format yyyy-mm-ddThh:mm:ss.dddZ), is | |
316 // successfully parsed and output as |time|. | |
317 static bool GetTimeFromString( | |
318 const base::StringPiece& raw_value, base::Time* time); | |
319 | |
320 // Registers the mapping between JSON field names and the members in | |
321 // this class. | |
322 static void RegisterJSONConverter( | |
323 base::JSONValueConverter<FeedEntry>* converter); | |
324 | |
325 protected: | |
326 std::string etag_; | |
327 ScopedVector<Author> authors_; | |
328 ScopedVector<Link> links_; | |
329 ScopedVector<Category> categories_; | |
330 base::Time updated_time_; | |
331 | |
332 DISALLOW_COPY_AND_ASSIGN(FeedEntry); | |
333 }; | |
334 | |
335 // Document feed entry. | |
336 class DocumentEntry : public FeedEntry { | |
337 public: | |
338 // kEntryKindMap should be also updated if you modify EntryKind. | |
339 enum EntryKind { | |
340 UNKNOWN = 0x000000, | |
341 // Special entries. | |
342 ITEM = 0x001001, | |
343 SITE = 0x001002, | |
344 // Hosted Google document. | |
345 DOCUMENT = 0x002101, | |
346 SPREADSHEET = 0x002102, | |
347 PRESENTATION = 0x002103, | |
348 DRAWING = 0x002104, | |
349 TABLE = 0x002105, | |
350 // Hosted external application document. | |
351 EXTERNAL_APP = 0x002201, | |
352 // Folders, collections. | |
353 FOLDER = 0x004001, | |
354 // Regular files. | |
355 FILE = 0x008001, | |
356 PDF = 0x008002, | |
357 }; | |
358 virtual ~DocumentEntry(); | |
359 | |
360 // Extracts "entry" dictionary from the JSON value, and parse the contents, | |
361 // using CreateFrom(). Returns NULL on failure. The input JSON data, coming | |
362 // from the gdata server, looks like: | |
363 // | |
364 // { | |
365 // "encoding": "UTF-8", | |
366 // "entry": { ... }, // This function will extract this and parse. | |
367 // "version": "1.0" | |
368 // } | |
369 static DocumentEntry* ExtractAndParse(const base::Value& value); | |
370 | |
371 // Creates document entry from parsed JSON Value. You should call | |
372 // this instead of instantiating JSONValueConverter by yourself | |
373 // because this method does some post-process for some fields. See | |
374 // FillRemainingFields comment and implementation for the details. | |
375 static DocumentEntry* CreateFrom(const base::Value* value); | |
376 | |
377 // Creates document entry from parsed XML. | |
378 static DocumentEntry* CreateFromXml(XmlReader* xml_reader); | |
379 | |
380 // Returns name of entry node. | |
381 static std::string GetEntryNodeName(); | |
382 | |
383 // Registers the mapping between JSON field names and the members in | |
384 // this class. | |
385 static void RegisterJSONConverter( | |
386 base::JSONValueConverter<DocumentEntry>* converter); | |
387 | |
388 // Helper function for parsing bool fields based on presence of | |
389 // their value nodes. | |
390 static bool HasFieldPresent(const base::Value* value, bool* result); | |
391 | |
392 // Returns true if |file| has one of the hosted document extensions. | |
393 static bool HasHostedDocumentExtension(const FilePath& file); | |
394 | |
395 // Returns a list of all entry kinds. | |
396 static std::vector<int> GetAllEntryKinds(); | |
397 | |
398 // Document entry resource id. | |
399 const std::string& resource_id() const { return resource_id_; } | |
400 | |
401 // Document entry id. | |
402 const std::string& id() const { return id_; } | |
403 | |
404 // Document entry kind. | |
405 EntryKind kind() const { return kind_; } | |
406 | |
407 // Document entry title. | |
408 const string16& title() const { return title_; } | |
409 | |
410 // Document entry published time. | |
411 base::Time published_time() const { return published_time_; } | |
412 | |
413 // List of document feed labels. | |
414 const std::vector<string16>& labels() const { return labels_; } | |
415 | |
416 // Document entry content URL. | |
417 const GURL& content_url() const { return content_.url(); } | |
418 | |
419 // Document entry MIME type. | |
420 const std::string& content_mime_type() const { return content_.mime_type(); } | |
421 | |
422 // List of document feed links. | |
423 const ScopedVector<FeedLink>& feed_links() const { return feed_links_; } | |
424 | |
425 // Document feed file name (exists only for kinds FILE and PDF). | |
426 const string16& filename() const { return filename_; } | |
427 | |
428 // Document feed suggested file name (exists only for kinds FILE and PDF). | |
429 const string16& suggested_filename() const { return suggested_filename_; } | |
430 | |
431 // Document feed file content MD5 (exists only for kinds FILE and PDF). | |
432 const std::string& file_md5() const { return file_md5_; } | |
433 | |
434 // Document feed file size (exists only for kinds FILE and PDF). | |
435 int64 file_size() const { return file_size_; } | |
436 | |
437 // True if the file or directory is deleted (applicable to change feeds only). | |
438 bool deleted() const { return deleted_ || removed_; } | |
439 | |
440 // Text version of document entry kind. Returns an empty string for | |
441 // unknown entry kind. | |
442 std::string GetEntryKindText() const; | |
443 | |
444 // Returns preferred file extension for hosted documents. If entry is not | |
445 // a hosted document, this call returns an empty string. | |
446 std::string GetHostedDocumentExtension() const; | |
447 | |
448 // True if document entry is remotely hosted. | |
449 bool is_hosted_document() const { return (kind_ & 0x002000) == 0x002000; } | |
450 // True if document entry hosted by Google Documents. | |
451 bool is_google_document() const { return (kind_ & 0x002100) == 0x002100; } | |
452 // True if document entry is hosted by an external application. | |
453 bool is_external_document() const { return (kind_ & 0x002200) == 0x002200; } | |
454 // True if document entry is a folder (collection). | |
455 bool is_folder() const { return (kind_ & 0x004000) != 0; } | |
456 // True if document entry is regular file. | |
457 bool is_file() const { return (kind_ & 0x008000) != 0; } | |
458 // True if document entry can't be mapped to the file system. | |
459 bool is_special() const { | |
460 return !is_file() && !is_folder() && !is_hosted_document(); | |
461 } | |
462 | |
463 private: | |
464 friend class base::internal::RepeatedMessageConverter<DocumentEntry>; | |
465 friend class DocumentFeed; | |
466 friend class ResumeUploadOperation; | |
467 | |
468 DocumentEntry(); | |
469 | |
470 // Fills the remaining fields where JSONValueConverter cannot catch. | |
471 void FillRemainingFields(); | |
472 | |
473 // Converts categories.term into EntryKind enum. | |
474 static EntryKind GetEntryKindFromTerm(const std::string& term); | |
475 // Converts |kind| into its text identifier equivalent. | |
476 static const char* GetEntryKindDescription(EntryKind kind); | |
477 | |
478 std::string resource_id_; | |
479 std::string id_; | |
480 EntryKind kind_; | |
481 string16 title_; | |
482 base::Time published_time_; | |
483 std::vector<string16> labels_; | |
484 Content content_; | |
485 ScopedVector<FeedLink> feed_links_; | |
486 // Optional fields for files only. | |
487 string16 filename_; | |
488 string16 suggested_filename_; | |
489 std::string file_md5_; | |
490 int64 file_size_; | |
491 bool deleted_; | |
492 bool removed_; | |
493 | |
494 DISALLOW_COPY_AND_ASSIGN(DocumentEntry); | |
495 }; | |
496 | |
497 // Document feed represents a list of entries. The feed is paginated and | |
498 // the rest of the feed can be fetched by retrieving the remaining parts of the | |
499 // feed from URLs provided by GetNextFeedURL() method. | |
500 class DocumentFeed : public FeedEntry { | |
501 public: | |
502 virtual ~DocumentFeed(); | |
503 | |
504 // Extracts "feed" dictionary from the JSON value, and parse the contents, | |
505 // using CreateFrom(). Returns NULL on failure. The input JSON data, coming | |
506 // from the gdata server, looks like: | |
507 // | |
508 // { | |
509 // "encoding": "UTF-8", | |
510 // "feed": { ... }, // This function will extract this and parse. | |
511 // "version": "1.0" | |
512 // } | |
513 static scoped_ptr<DocumentFeed> ExtractAndParse(const base::Value& value); | |
514 | |
515 // Creates feed from parsed JSON Value. You should call this | |
516 // instead of instantiating JSONValueConverter by yourself because | |
517 // this method does some post-process for some fields. See | |
518 // FillRemainingFields comment and implementation in DocumentEntry | |
519 // class for the details. | |
520 static scoped_ptr<DocumentFeed> CreateFrom(const base::Value& value); | |
521 | |
522 // Registers the mapping between JSON field names and the members in | |
523 // this class. | |
524 static void RegisterJSONConverter( | |
525 base::JSONValueConverter<DocumentFeed>* converter); | |
526 | |
527 // Returns true and passes|url| of the next feed if the current entry list | |
528 // does not completed this feed. | |
529 bool GetNextFeedURL(GURL* url); | |
530 | |
531 // List of document entries. | |
532 const ScopedVector<DocumentEntry>& entries() const { return entries_; } | |
533 | |
534 // Start index of the document entry list. | |
535 int start_index() const { return start_index_; } | |
536 | |
537 // Number of items per feed of the document entry list. | |
538 int items_per_page() const { return items_per_page_; } | |
539 | |
540 // The largest changestamp. Next time the documents should be fetched | |
541 // from this changestamp. | |
542 int largest_changestamp() const { return largest_changestamp_; } | |
543 | |
544 // Document entry list title. | |
545 const std::string& title() { return title_; } | |
546 | |
547 private: | |
548 DocumentFeed(); | |
549 | |
550 // Parses and initializes data members from content of |value|. | |
551 // Return false if parsing fails. | |
552 bool Parse(const base::Value& value); | |
553 | |
554 ScopedVector<DocumentEntry> entries_; | |
555 int start_index_; | |
556 int items_per_page_; | |
557 std::string title_; | |
558 int largest_changestamp_; | |
559 | |
560 DISALLOW_COPY_AND_ASSIGN(DocumentFeed); | |
561 }; | |
562 | |
563 // Metadata representing installed Google Drive application. | |
564 class InstalledApp { | |
565 public: | |
566 typedef std::vector<std::pair<int, GURL> > IconList; | |
567 | |
568 InstalledApp(); | |
569 virtual ~InstalledApp(); | |
570 | |
571 // WebApp name. | |
572 const string16& app_name() const { return app_name_; } | |
573 | |
574 // Drive app id | |
575 const std::string& app_id() const { return app_id_; } | |
576 | |
577 // Object (file) type name that is generated by this WebApp. | |
578 const string16& object_type() const { return object_type_; } | |
579 | |
580 // True if WebApp supports creation of new file instances. | |
581 bool supports_create() const { return supports_create_; } | |
582 | |
583 // List of primary mime types supported by this WebApp. Primary status should | |
584 // trigger this WebApp becoming the default handler of file instances that | |
585 // have these mime types. | |
586 const ScopedVector<std::string>& primary_mimetypes() const { | |
587 return primary_mimetypes_; | |
588 } | |
589 | |
590 // List of secondary mime types supported by this WebApp. Secondary status | |
591 // should make this WebApp show up in "Open with..." pop-up menu of the | |
592 // default action menu for file with matching mime types. | |
593 const ScopedVector<std::string>& secondary_mimetypes() const { | |
594 return secondary_mimetypes_; | |
595 } | |
596 | |
597 // List of primary file extensions supported by this WebApp. Primary status | |
598 // should trigger this WebApp becoming the default handler of file instances | |
599 // that match these extensions. | |
600 const ScopedVector<std::string>& primary_extensions() const { | |
601 return primary_extensions_; | |
602 } | |
603 | |
604 // List of secondary file extensions supported by this WebApp. Secondary | |
605 // status should make this WebApp show up in "Open with..." pop-up menu of the | |
606 // default action menu for file with matching extensions. | |
607 const ScopedVector<std::string>& secondary_extensions() const { | |
608 return secondary_extensions_; | |
609 } | |
610 | |
611 // List of entry links. | |
612 const ScopedVector<Link>& links() const { return links_; } | |
613 | |
614 // Returns a list of icons associated with this installed application. | |
615 const ScopedVector<AppIcon>& app_icons() const { | |
616 return app_icons_; | |
617 } | |
618 | |
619 // Convenience function for getting the icon URLs for a particular |category| | |
620 // of icon. Icons are returned in a sorted list, from smallest to largest. | |
621 IconList GetIconsForCategory(AppIcon::IconCategory category) const; | |
622 | |
623 // Retrieves product URL from the link collection. | |
624 GURL GetProductUrl() const; | |
625 | |
626 // Registers the mapping between JSON field names and the members in | |
627 // this class. | |
628 static void RegisterJSONConverter( | |
629 base::JSONValueConverter<InstalledApp>* converter); | |
630 | |
631 private: | |
632 // Extracts "$t" value from the dictionary |value| and returns it in |result|. | |
633 // If the string value can't be found, it returns false. | |
634 static bool GetValueString(const base::Value* value, | |
635 std::string* result); | |
636 | |
637 std::string app_id_; | |
638 string16 app_name_; | |
639 string16 object_type_; | |
640 bool supports_create_; | |
641 ScopedVector<std::string> primary_mimetypes_; | |
642 ScopedVector<std::string> secondary_mimetypes_; | |
643 ScopedVector<std::string> primary_extensions_; | |
644 ScopedVector<std::string> secondary_extensions_; | |
645 ScopedVector<Link> links_; | |
646 ScopedVector<AppIcon> app_icons_; | |
647 }; | |
648 | |
649 // Account metadata feed represents the metadata object attached to the user's | |
650 // account. | |
651 class AccountMetadataFeed { | |
652 public: | |
653 virtual ~AccountMetadataFeed(); | |
654 | |
655 // Creates feed from parsed JSON Value. You should call this | |
656 // instead of instantiating JSONValueConverter by yourself because | |
657 // this method does some post-process for some fields. See | |
658 // FillRemainingFields comment and implementation in DocumentEntry | |
659 // class for the details. | |
660 static scoped_ptr<AccountMetadataFeed> CreateFrom(const base::Value& value); | |
661 | |
662 int64 quota_bytes_total() const { | |
663 return quota_bytes_total_; | |
664 } | |
665 | |
666 int64 quota_bytes_used() const { | |
667 return quota_bytes_used_; | |
668 } | |
669 | |
670 int largest_changestamp() const { | |
671 return largest_changestamp_; | |
672 } | |
673 | |
674 const ScopedVector<InstalledApp>& installed_apps() const { | |
675 return installed_apps_; | |
676 } | |
677 | |
678 // Registers the mapping between JSON field names and the members in | |
679 // this class. | |
680 static void RegisterJSONConverter( | |
681 base::JSONValueConverter<AccountMetadataFeed>* converter); | |
682 | |
683 private: | |
684 AccountMetadataFeed(); | |
685 | |
686 // Parses and initializes data members from content of |value|. | |
687 // Return false if parsing fails. | |
688 bool Parse(const base::Value& value); | |
689 | |
690 int64 quota_bytes_total_; | |
691 int64 quota_bytes_used_; | |
692 int largest_changestamp_; | |
693 ScopedVector<InstalledApp> installed_apps_; | |
694 | |
695 DISALLOW_COPY_AND_ASSIGN(AccountMetadataFeed); | |
696 }; | |
697 | |
698 | |
699 } // namespace gdata | |
700 | |
701 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_PARSER_H_ | |
OLD | NEW |