Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 // Parses and initializes data members from content of |value|. | 250 // Parses and initializes data members from content of |value|. |
| 251 // Return false if parsing fails. | 251 // Return false if parsing fails. |
| 252 bool Parse(const base::Value& value); | 252 bool Parse(const base::Value& value); |
| 253 | 253 |
| 254 std::string etag_; | 254 std::string etag_; |
| 255 ScopedVector<AppResource> items_; | 255 ScopedVector<AppResource> items_; |
| 256 | 256 |
| 257 DISALLOW_COPY_AND_ASSIGN(AppList); | 257 DISALLOW_COPY_AND_ASSIGN(AppList); |
| 258 }; | 258 }; |
| 259 | 259 |
| 260 // FileResource reporesents a file in Drive. | |
|
satorux1
2012/07/27 23:03:11
a file or a directory? This class contains IsFolde
kochi
2012/07/30 07:46:53
I agree that this might be a confusing name, but I
satorux1
2012/07/30 09:01:13
Here's the background about my concern:
We origin
| |
| 261 // https://developers.google.com/drive/v2/reference/files | |
| 262 class FileResource { | |
| 263 public: | |
| 264 ~FileResource(); | |
| 265 | |
| 266 // Registers the mapping between JSON field names and the members in this | |
| 267 // class. | |
| 268 static void RegisterJSONConverter( | |
| 269 base::JSONValueConverter<FileResource>* converter); | |
| 270 static scoped_ptr<FileResource> CreateFrom(const base::Value& value); | |
| 271 | |
| 272 // Returns true if this is a folder. | |
| 273 bool IsFolder() const; | |
|
satorux1
2012/07/27 23:03:11
IsDirectory()?
kochi
2012/07/30 07:46:53
The term "directory" is never used in Drive API do
satorux1
2012/07/30 09:01:13
I think we should use the term "directory" in most
| |
| 274 | |
| 275 // Returns file ID. | |
| 276 const std::string& id() const { return id_; } | |
|
satorux1
2012/07/27 23:03:11
Is this equivalent of resource ID? maybe resource_
kochi
2012/07/30 07:46:53
No, this is different from old WAPI's resource ID.
satorux1
2012/07/30 09:01:13
But the purpose is the same? If so, please also me
| |
| 277 | |
| 278 // Returns ETag for this file. | |
| 279 const std::string& etag() const { return etag_; } | |
| 280 | |
| 281 // Returns MIME type of this file. | |
| 282 const std::string& mime_type() const { return mime_type_; } | |
| 283 | |
| 284 // Returns the title of this file. | |
| 285 const std::string& title() const { return title_; } | |
| 286 | |
| 287 // Returns modification time by the user. | |
| 288 const base::Time& modified_by_me_date() const { return modified_by_me_date_; } | |
| 289 | |
| 290 // Returns the download URL. | |
| 291 const GURL& download_url() const { return download_url_; } | |
| 292 | |
| 293 // Returns the extension part of the filename. | |
| 294 const std::string& file_extension() const { return file_extension_; } | |
| 295 | |
| 296 // Returns MD5 checksum of this file. | |
| 297 const std::string& md5_checksum() const { return md5_checksum_; } | |
| 298 | |
| 299 // Returns the size of this file in bytes. | |
| 300 int64 file_size() const { return file_size_; } | |
| 301 | |
| 302 private: | |
| 303 friend class base::internal::RepeatedMessageConverter<FileResource>; | |
| 304 friend class FileList; | |
| 305 FileResource(); | |
| 306 | |
| 307 // Parses and initializes data members from content of |value|. | |
| 308 // Return false if parsing fails. | |
| 309 bool Parse(const base::Value& value); | |
| 310 | |
| 311 std::string id_; | |
| 312 std::string etag_; | |
| 313 std::string mime_type_; | |
| 314 std::string title_; | |
| 315 base::Time modified_by_me_date_; | |
| 316 GURL download_url_; | |
| 317 std::string file_extension_; | |
| 318 std::string md5_checksum_; | |
| 319 int64 file_size_; | |
| 320 | |
| 321 DISALLOW_COPY_AND_ASSIGN(FileResource); | |
| 322 }; | |
| 323 | |
| 324 // FileList represents a collection of files. | |
|
satorux1
2012/07/27 23:03:11
File is a not good name if it means file or direct
kochi
2012/07/30 07:46:53
The same for FileResource. Updated the class comm
| |
| 325 // https://developers.google.com/drive/v2/reference/files/list | |
| 326 class FileList { | |
| 327 public: | |
| 328 ~FileList(); | |
| 329 | |
| 330 // Registers the mapping between JSON field names and the members in this | |
| 331 // class. | |
| 332 static void RegisterJSONConverter( | |
| 333 base::JSONValueConverter<FileList>* converter); | |
| 334 static scoped_ptr<FileList> CreateFrom(const base::Value& value); | |
| 335 | |
| 336 // Returns the ETag of the list. | |
| 337 const std::string& etag() const { return etag_; } | |
| 338 | |
| 339 // Returns the page token for the next page of files. | |
|
satorux1
2012/07/27 23:03:11
how does it look like? what's the "page token"? pl
kochi
2012/07/30 07:46:53
Added more comments, and also added checks in unit
| |
| 340 const std::string& next_page_token() const { return next_page_token_; } | |
| 341 | |
| 342 // Returns a link to the next page of files. | |
| 343 const GURL& next_link() const { return next_link_; } | |
| 344 | |
| 345 // Returns a set of files in this list. | |
| 346 const ScopedVector<FileResource>& items() const { return items_; } | |
| 347 | |
| 348 private: | |
| 349 friend class DriveAPIParserTest; | |
| 350 FRIEND_TEST_ALL_PREFIXES(DriveAPIParserTest, FileListParser); | |
| 351 FileList(); | |
| 352 | |
| 353 // Parses and initializes data members from content of |value|. | |
| 354 // Return false if parsing fails. | |
| 355 bool Parse(const base::Value& value); | |
| 356 | |
| 357 std::string etag_; | |
| 358 std::string next_page_token_; | |
| 359 GURL next_link_; | |
| 360 ScopedVector<FileResource> items_; | |
| 361 | |
| 362 DISALLOW_COPY_AND_ASSIGN(FileList); | |
| 363 }; | |
| 364 | |
| 260 } // namespace gdata | 365 } // namespace gdata |
| 261 | 366 |
| 262 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_ | 367 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_ |
| OLD | NEW |