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

Side by Side Diff: chrome/browser/chromeos/gdata/drive_api_parser.h

Issue 10855017: Add missing fields in Drive V2 API parser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reorder fields, add missed "deleted" field parsing in ChangeResource. Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/drive_api_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_DRIVE_API_PARSER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 26 matching lines...) Expand all
37 ~AboutResource(); 37 ~AboutResource();
38 38
39 // Registers the mapping between JSON field names and the members in this 39 // Registers the mapping between JSON field names and the members in this
40 // class. 40 // class.
41 static void RegisterJSONConverter( 41 static void RegisterJSONConverter(
42 base::JSONValueConverter<AboutResource>* converter); 42 base::JSONValueConverter<AboutResource>* converter);
43 43
44 // Creates about resource from parsed JSON. 44 // Creates about resource from parsed JSON.
45 static scoped_ptr<AboutResource> CreateFrom(const base::Value& value); 45 static scoped_ptr<AboutResource> CreateFrom(const base::Value& value);
46 46
47 // Returns root folder ID. 47 // Returns the largest change ID number.
48 const std::string& root_folder_id() const { return root_folder_id_; } 48 int64 largest_change_id() const { return largest_change_id_; }
49 // Returns total number of quta bytes. 49 // Returns total number of quta bytes.
50 int64 quota_bytes_total() const { return quota_bytes_total_; } 50 int64 quota_bytes_total() const { return quota_bytes_total_; }
51 // Returns the number of quota bytes used. 51 // Returns the number of quota bytes used.
52 int64 quota_bytes_used() const { return quota_bytes_used_; } 52 int64 quota_bytes_used() const { return quota_bytes_used_; }
53 // Returns the largest change ID number. 53 // Returns root folder ID.
54 int64 largest_change_id() const { return largest_change_id_; } 54 const std::string& root_folder_id() const { return root_folder_id_; }
55 55
56 private: 56 private:
57 friend class DriveAPIParserTest; 57 friend class DriveAPIParserTest;
58 FRIEND_TEST_ALL_PREFIXES(DriveAPIParserTest, AboutResourceParser); 58 FRIEND_TEST_ALL_PREFIXES(DriveAPIParserTest, AboutResourceParser);
59 AboutResource(); 59 AboutResource();
60 60
61 // Parses and initializes data members from content of |value|. 61 // Parses and initializes data members from content of |value|.
62 // Return false if parsing fails. 62 // Return false if parsing fails.
63 bool Parse(const base::Value& value); 63 bool Parse(const base::Value& value);
64 64
65 std::string root_folder_id_; 65 int64 largest_change_id_;
66 int64 quota_bytes_total_; 66 int64 quota_bytes_total_;
67 int64 quota_bytes_used_; 67 int64 quota_bytes_used_;
68 int64 largest_change_id_; 68 std::string root_folder_id_;
69 69
70 DISALLOW_COPY_AND_ASSIGN(AboutResource); 70 DISALLOW_COPY_AND_ASSIGN(AboutResource);
71 }; 71 };
72 72
73 // DriveAppIcon represents an icon for Drive Application. 73 // DriveAppIcon represents an icon for Drive Application.
74 // https://developers.google.com/drive/v2/reference/apps/list 74 // https://developers.google.com/drive/v2/reference/apps/list
75 class DriveAppIcon { 75 class DriveAppIcon {
76 public: 76 public:
77 enum IconCategory { 77 enum IconCategory {
78 UNKNOWN, // Uninitialized state 78 UNKNOWN, // Uninitialized state
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // class. 268 // class.
269 static void RegisterJSONConverter( 269 static void RegisterJSONConverter(
270 base::JSONValueConverter<ParentReference>* converter); 270 base::JSONValueConverter<ParentReference>* converter);
271 271
272 // Creates parent reference from parsed JSON. 272 // Creates parent reference from parsed JSON.
273 static scoped_ptr<ParentReference> CreateFrom(const base::Value& value); 273 static scoped_ptr<ParentReference> CreateFrom(const base::Value& value);
274 274
275 // Returns the file id of the reference. 275 // Returns the file id of the reference.
276 const std::string& file_id() const { return file_id_; } 276 const std::string& file_id() const { return file_id_; }
277 277
278 // Returns the URL for the parent in Drive.
279 const GURL& parent_link() const { return parent_link_; }
280
278 // Returns true if the reference is root directory. 281 // Returns true if the reference is root directory.
279 bool is_root() const { return is_root_; } 282 bool is_root() const { return is_root_; }
280 283
281 private: 284 private:
282 friend class base::internal::RepeatedMessageConverter<ParentReference>; 285 friend class base::internal::RepeatedMessageConverter<ParentReference>;
283 ParentReference(); 286 ParentReference();
284 287
285 // Parses and initializes data members from content of |value|. 288 // Parses and initializes data members from content of |value|.
286 // Return false if parsing fails. 289 // Return false if parsing fails.
287 bool Parse(const base::Value& value); 290 bool Parse(const base::Value& value);
288 291
289 std::string file_id_; 292 std::string file_id_;
293 GURL parent_link_;
290 bool is_root_; 294 bool is_root_;
291 295
292 DISALLOW_COPY_AND_ASSIGN(ParentReference); 296 DISALLOW_COPY_AND_ASSIGN(ParentReference);
293 }; 297 };
294 298
295 // FileResource represents a file or folder metadata in Drive. 299 // FileResource represents a file or folder metadata in Drive.
296 // https://developers.google.com/drive/v2/reference/files 300 // https://developers.google.com/drive/v2/reference/files
297 class FileResource { 301 class FileResource {
298 public: 302 public:
299 ~FileResource(); 303 ~FileResource();
(...skipping 10 matching lines...) Expand all
310 // Note: "folder" is used elsewhere in this file to match Drive API reference, 314 // Note: "folder" is used elsewhere in this file to match Drive API reference,
311 // but outside this file we use "directory" to match HTML5 filesystem API. 315 // but outside this file we use "directory" to match HTML5 filesystem API.
312 bool IsDirectory() const; 316 bool IsDirectory() const;
313 317
314 // Returns file ID. This is unique in all files in Google Drive. 318 // Returns file ID. This is unique in all files in Google Drive.
315 const std::string& file_id() const { return file_id_; } 319 const std::string& file_id() const { return file_id_; }
316 320
317 // Returns ETag for this file. 321 // Returns ETag for this file.
318 const std::string& etag() const { return etag_; } 322 const std::string& etag() const { return etag_; }
319 323
324 // Returns the link to JSON of this file itself.
325 const GURL& self_link() const { return self_link_; }
326
327 // Returns the title of this file.
328 const std::string& title() const { return title_; }
329
320 // Returns MIME type of this file. 330 // Returns MIME type of this file.
321 const std::string& mime_type() const { return mime_type_; } 331 const std::string& mime_type() const { return mime_type_; }
322 332
323 // Returns the title of this file. 333 // Returns created time of this file.
324 const std::string& title() const { return title_; } 334 const base::Time& created_date() const { return created_date_; }
325 335
326 // Returns modification time by the user. 336 // Returns modification time by the user.
327 const base::Time& modified_by_me_date() const { return modified_by_me_date_; } 337 const base::Time& modified_by_me_date() const { return modified_by_me_date_; }
328 338
329 // Returns parent references (directories) of this file. 339 // Returns the short-lived download URL for the file. This field exists
330 const ScopedVector<ParentReference>& parents() const { return parents_; } 340 // only when the file content is stored in Drive.
331
332 // Returns the download URL.
333 const GURL& download_url() const { return download_url_; } 341 const GURL& download_url() const { return download_url_; }
334 342
335 // Returns the extension part of the filename. 343 // Returns the extension part of the filename.
336 const std::string& file_extension() const { return file_extension_; } 344 const std::string& file_extension() const { return file_extension_; }
337 345
338 // Returns MD5 checksum of this file. 346 // Returns MD5 checksum of this file.
339 const std::string& md5_checksum() const { return md5_checksum_; } 347 const std::string& md5_checksum() const { return md5_checksum_; }
340 348
341 // Returns the size of this file in bytes. 349 // Returns the size of this file in bytes.
342 int64 file_size() const { return file_size_; } 350 int64 file_size() const { return file_size_; }
343 351
352 // Return the link to open the file in Google editor or viewer.
353 // E.g. Google Document, Google Spreadsheet.
354 const GURL& alternate_link() const { return alternate_link_; }
355
356 // Returns the link for embedding the file.
357 const GURL& embed_link() const { return embed_link_; }
358
359 // Returns parent references (directories) of this file.
360 const ScopedVector<ParentReference>& parents() const { return parents_; }
361
362 // Returns the link to the file's thumbnail.
363 const GURL& thumbnail_link() const { return thumbnail_link_; }
364
365 // Returns the link to open its downloadable content, using cookie based
366 // authentication.
367 const GURL& web_content_link() const { return web_content_link_; }
368
344 private: 369 private:
345 friend class base::internal::RepeatedMessageConverter<FileResource>; 370 friend class base::internal::RepeatedMessageConverter<FileResource>;
346 friend class ChangeResource; 371 friend class ChangeResource;
347 friend class FileList; 372 friend class FileList;
348 FileResource(); 373 FileResource();
349 374
350 // Parses and initializes data members from content of |value|. 375 // Parses and initializes data members from content of |value|.
351 // Return false if parsing fails. 376 // Return false if parsing fails.
352 bool Parse(const base::Value& value); 377 bool Parse(const base::Value& value);
353 378
354 std::string file_id_; 379 std::string file_id_;
355 std::string etag_; 380 std::string etag_;
381 GURL self_link_;
382 std::string title_;
356 std::string mime_type_; 383 std::string mime_type_;
357 std::string title_; 384 base::Time created_date_;
358 base::Time modified_by_me_date_; 385 base::Time modified_by_me_date_;
359 ScopedVector<ParentReference> parents_;
360 GURL download_url_; 386 GURL download_url_;
361 std::string file_extension_; 387 std::string file_extension_;
362 std::string md5_checksum_; 388 std::string md5_checksum_;
363 int64 file_size_; 389 int64 file_size_;
390 GURL alternate_link_;
391 GURL embed_link_;
392 ScopedVector<ParentReference> parents_;
393 GURL thumbnail_link_;
394 GURL web_content_link_;
364 395
365 DISALLOW_COPY_AND_ASSIGN(FileResource); 396 DISALLOW_COPY_AND_ASSIGN(FileResource);
366 }; 397 };
367 398
368 // FileList represents a collection of files and folders. 399 // FileList represents a collection of files and folders.
369 // https://developers.google.com/drive/v2/reference/files/list 400 // https://developers.google.com/drive/v2/reference/files/list
370 class FileList { 401 class FileList {
371 public: 402 public:
372 ~FileList(); 403 ~FileList();
373 404
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 GURL next_link_; 530 GURL next_link_;
500 int64 largest_change_id_; 531 int64 largest_change_id_;
501 ScopedVector<ChangeResource> items_; 532 ScopedVector<ChangeResource> items_;
502 533
503 DISALLOW_COPY_AND_ASSIGN(ChangeList); 534 DISALLOW_COPY_AND_ASSIGN(ChangeList);
504 }; 535 };
505 536
506 } // namespace gdata 537 } // namespace gdata
507 538
508 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_ 539 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/drive_api_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698