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

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: rebase. 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 129
130 // Registers the mapping between JSON field names and the members in this 130 // Registers the mapping between JSON field names and the members in this
131 // class. 131 // class.
132 static void RegisterJSONConverter( 132 static void RegisterJSONConverter(
133 base::JSONValueConverter<AppResource>* converter); 133 base::JSONValueConverter<AppResource>* converter);
134 134
135 // Creates app resource from parsed JSON. 135 // Creates app resource from parsed JSON.
136 static scoped_ptr<AppResource> CreateFrom(const base::Value& value); 136 static scoped_ptr<AppResource> CreateFrom(const base::Value& value);
137 137
138 // Returns application ID, which is 12-digit decimals (e.g. "123456780123"). 138 // Returns application ID, which is 12-digit decimals (e.g. "123456780123").
139 const std::string& id() const { return id_; } 139 const std::string& application_id() const { return application_id_; }
140 140
141 // Returns application name. 141 // Returns application name.
142 const std::string& name() const { return name_; } 142 const std::string& name() const { return name_; }
143 143
144 // Returns the name of the type of object this application creates. 144 // Returns the name of the type of object this application creates.
145 // This can be any string. TODO(kochi): figure out how to use this value. 145 // This can be any string. TODO(kochi): figure out how to use this value.
146 const std::string& object_type() const { return object_type_; } 146 const std::string& object_type() const { return object_type_; }
147 147
148 // Returns whether this application suuports creating new objects. 148 // Returns whether this application suuports creating new objects.
149 bool supports_create() const { return supports_create_; } 149 bool supports_create() const { return supports_create_; }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 private: 199 private:
200 friend class base::internal::RepeatedMessageConverter<AppResource>; 200 friend class base::internal::RepeatedMessageConverter<AppResource>;
201 friend class AppList; 201 friend class AppList;
202 AppResource(); 202 AppResource();
203 203
204 // Parses and initializes data members from content of |value|. 204 // Parses and initializes data members from content of |value|.
205 // Return false if parsing fails. 205 // Return false if parsing fails.
206 bool Parse(const base::Value& value); 206 bool Parse(const base::Value& value);
207 207
208 std::string id_; 208 std::string application_id_;
209 std::string name_; 209 std::string name_;
210 std::string object_type_; 210 std::string object_type_;
211 bool supports_create_; 211 bool supports_create_;
212 bool supports_import_; 212 bool supports_import_;
213 bool installed_; 213 bool installed_;
214 bool authorized_; 214 bool authorized_;
215 GURL product_url_; 215 GURL product_url_;
216 ScopedVector<std::string> primary_mimetypes_; 216 ScopedVector<std::string> primary_mimetypes_;
217 ScopedVector<std::string> secondary_mimetypes_; 217 ScopedVector<std::string> secondary_mimetypes_;
218 ScopedVector<std::string> primary_file_extensions_; 218 ScopedVector<std::string> primary_file_extensions_;
(...skipping 31 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 directory.
273 // Note: "folder" is used elsewhere in this file to match Drive API reference,
274 // but outside this file we use "directory" to match HTML5 filesystem API.
275 bool IsDirectory() const;
276
277 // Returns file ID. This is unique in all files in Google Drive.
278 const std::string& file_id() const { return file_id_; }
279
280 // Returns ETag for this file.
281 const std::string& etag() const { return etag_; }
282
283 // Returns MIME type of this file.
284 const std::string& mime_type() const { return mime_type_; }
285
286 // Returns the title of this file.
287 const std::string& title() const { return title_; }
288
289 // Returns modification time by the user.
290 const base::Time& modified_by_me_date() const { return modified_by_me_date_; }
291
292 // Returns the download URL.
293 const GURL& download_url() const { return download_url_; }
294
295 // Returns the extension part of the filename.
296 const std::string& file_extension() const { return file_extension_; }
297
298 // Returns MD5 checksum of this file.
299 const std::string& md5_checksum() const { return md5_checksum_; }
300
301 // Returns the size of this file in bytes.
302 int64 file_size() const { return file_size_; }
303
304 private:
305 friend class base::internal::RepeatedMessageConverter<FileResource>;
306 friend class FileList;
307 FileResource();
308
309 // Parses and initializes data members from content of |value|.
310 // Return false if parsing fails.
311 bool Parse(const base::Value& value);
312
313 std::string file_id_;
314 std::string etag_;
315 std::string mime_type_;
316 std::string title_;
317 base::Time modified_by_me_date_;
318 GURL download_url_;
319 std::string file_extension_;
320 std::string md5_checksum_;
321 int64 file_size_;
322
323 DISALLOW_COPY_AND_ASSIGN(FileResource);
324 };
325
326 // FileList represents a collection of files and folders.
327 // https://developers.google.com/drive/v2/reference/files/list
328 class FileList {
329 public:
330 ~FileList();
331
332 // Registers the mapping between JSON field names and the members in this
333 // class.
334 static void RegisterJSONConverter(
335 base::JSONValueConverter<FileList>* converter);
336 static scoped_ptr<FileList> CreateFrom(const base::Value& value);
337
338 // Returns the ETag of the list.
339 const std::string& etag() const { return etag_; }
340
341 // Returns the page token for the next page of files, if the list is large
342 // to fit in one response. If this is empty, there is no more file lists.
343 const std::string& next_page_token() const { return next_page_token_; }
344
345 // Returns a link to the next page of files. The URL includes the next page
346 // token.
347 const GURL& next_link() const { return next_link_; }
348
349 // Returns a set of files in this list.
350 const ScopedVector<FileResource>& items() const { return items_; }
351
352 private:
353 friend class DriveAPIParserTest;
354 FRIEND_TEST_ALL_PREFIXES(DriveAPIParserTest, FileListParser);
355 FileList();
356
357 // Parses and initializes data members from content of |value|.
358 // Return false if parsing fails.
359 bool Parse(const base::Value& value);
360
361 std::string etag_;
362 std::string next_page_token_;
363 GURL next_link_;
364 ScopedVector<FileResource> items_;
365
366 DISALLOW_COPY_AND_ASSIGN(FileList);
367 };
368
260 } // namespace gdata 369 } // namespace gdata
261 370
262 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_ 371 #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