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

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

Issue 10829056: Add FileResource/FileList parser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for comments. 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
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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 or folder metadata in Drive.
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;
274
275 // Returns file ID.
276 const std::string& id() const { return id_; }
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 and folders.
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, if the list is large
340 // to fit in one response. If this is empty, there is no more file lists.
341 const std::string& next_page_token() const { return next_page_token_; }
342
343 // Returns a link to the next page of files. This includes the next page
344 // token.
345 const GURL& next_link() const { return next_link_; }
346
347 // Returns a set of files in this list.
348 const ScopedVector<FileResource>& items() const { return items_; }
349
350 private:
351 friend class DriveAPIParserTest;
352 FRIEND_TEST_ALL_PREFIXES(DriveAPIParserTest, FileListParser);
353 FileList();
354
355 // Parses and initializes data members from content of |value|.
356 // Return false if parsing fails.
357 bool Parse(const base::Value& value);
358
359 std::string etag_;
360 std::string next_page_token_;
361 GURL next_link_;
362 ScopedVector<FileResource> items_;
363
364 DISALLOW_COPY_AND_ASSIGN(FileList);
365 };
366
260 } // namespace gdata 367 } // namespace gdata
261 368
262 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_ 369 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698