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

Unified Diff: google_apis/drive/drive_api_parser.cc

Issue 216433002: drive: Make FileResource copyable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « google_apis/drive/drive_api_parser.h ('k') | google_apis/drive/drive_api_parser_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/drive/drive_api_parser.cc
diff --git a/google_apis/drive/drive_api_parser.cc b/google_apis/drive/drive_api_parser.cc
index 1eefb8bc4fb06ee55552286bd1a59a539d7d7dd1..fff3d9d4301bb29a6023a40bfa17628eb88a2378 100644
--- a/google_apis/drive/drive_api_parser.cc
+++ b/google_apis/drive/drive_api_parser.cc
@@ -38,6 +38,28 @@ bool GetGURLFromString(const base::StringPiece& url_string, GURL* result) {
return true;
}
+// Converts |value| to |result|.
+bool GetParentsFromValue(const base::Value* value,
+ std::vector<ParentReference>* result) {
+ DCHECK(value);
+ DCHECK(result);
+
+ const base::ListValue* list_value = NULL;
+ if (!value->GetAsList(&list_value))
+ return false;
+
+ base::JSONValueConverter<ParentReference> converter;
+ result->resize(list_value->GetSize());
+ for (size_t i = 0; i < list_value->GetSize(); ++i) {
+ const base::Value* parent_value = NULL;
+ if (!list_value->Get(i, &parent_value) ||
+ !converter.Convert(*parent_value, &(*result)[i]))
+ return false;
+ }
+
+ return true;
+}
+
// Converts |value| to |result|. The key of |value| is app_id, and its value
// is URL to open the resource on the web app.
bool GetOpenWithLinksFromDictionaryValue(
@@ -469,8 +491,10 @@ void FileResource::RegisterJSONConverter(
converter->RegisterCustomField<GURL>(kAlternateLink,
&FileResource::alternate_link_,
GetGURLFromString);
- converter->RegisterRepeatedMessage<ParentReference>(kParents,
- &FileResource::parents_);
+ converter->RegisterCustomValueField<std::vector<ParentReference> >(
+ kParents,
+ &FileResource::parents_,
+ GetParentsFromValue);
converter->RegisterCustomValueField<std::vector<OpenWithLink> >(
kOpenWithLinks,
&FileResource::open_with_links_,
« no previous file with comments | « google_apis/drive/drive_api_parser.h ('k') | google_apis/drive/drive_api_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698