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

Side by Side Diff: google_apis/drive/drive_api_requests.cc

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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
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 #include "google_apis/drive/drive_api_requests.h" 5 #include "google_apis/drive/drive_api_requests.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 const base::Time& modified_date, 118 const base::Time& modified_date,
119 const base::Time& last_viewed_by_me_date, 119 const base::Time& last_viewed_by_me_date,
120 const Properties& properties) { 120 const Properties& properties) {
121 base::DictionaryValue root; 121 base::DictionaryValue root;
122 if (!title.empty()) 122 if (!title.empty())
123 root.SetString("title", title); 123 root.SetString("title", title);
124 124
125 // Fill parent link. 125 // Fill parent link.
126 if (!parent_resource_id.empty()) { 126 if (!parent_resource_id.empty()) {
127 std::unique_ptr<base::ListValue> parents(new base::ListValue); 127 std::unique_ptr<base::ListValue> parents(new base::ListValue);
128 parents->Append( 128 parents->Append(google_apis::util::CreateParentValue(parent_resource_id));
129 google_apis::util::CreateParentValue(parent_resource_id).release());
130 root.Set("parents", parents.release()); 129 root.Set("parents", parents.release());
131 } 130 }
132 131
133 if (!modified_date.is_null()) { 132 if (!modified_date.is_null()) {
134 root.SetString("modifiedDate", 133 root.SetString("modifiedDate",
135 google_apis::util::FormatTimeAsString(modified_date)); 134 google_apis::util::FormatTimeAsString(modified_date));
136 } 135 }
137 136
138 if (!last_viewed_by_me_date.is_null()) { 137 if (!last_viewed_by_me_date.is_null()) {
139 root.SetString("lastViewedByMeDate", google_apis::util::FormatTimeAsString( 138 root.SetString("lastViewedByMeDate", google_apis::util::FormatTimeAsString(
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 bool InitiateUploadNewFileRequest::GetContentData( 825 bool InitiateUploadNewFileRequest::GetContentData(
827 std::string* upload_content_type, 826 std::string* upload_content_type,
828 std::string* upload_content) { 827 std::string* upload_content) {
829 *upload_content_type = util::kContentTypeApplicationJson; 828 *upload_content_type = util::kContentTypeApplicationJson;
830 829
831 base::DictionaryValue root; 830 base::DictionaryValue root;
832 root.SetString("title", title_); 831 root.SetString("title", title_);
833 832
834 // Fill parent link. 833 // Fill parent link.
835 std::unique_ptr<base::ListValue> parents(new base::ListValue); 834 std::unique_ptr<base::ListValue> parents(new base::ListValue);
836 parents->Append(util::CreateParentValue(parent_resource_id_).release()); 835 parents->Append(util::CreateParentValue(parent_resource_id_));
837 root.Set("parents", parents.release()); 836 root.Set("parents", parents.release());
838 837
839 if (!modified_date_.is_null()) 838 if (!modified_date_.is_null())
840 root.SetString("modifiedDate", util::FormatTimeAsString(modified_date_)); 839 root.SetString("modifiedDate", util::FormatTimeAsString(modified_date_));
841 840
842 if (!last_viewed_by_me_date_.is_null()) { 841 if (!last_viewed_by_me_date_.is_null()) {
843 root.SetString("lastViewedByMeDate", 842 root.SetString("lastViewedByMeDate",
844 util::FormatTimeAsString(last_viewed_by_me_date_)); 843 util::FormatTimeAsString(last_viewed_by_me_date_));
845 } 844 }
846 845
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 headers.push_back(util::GenerateIfMatchHeader(etag_)); 885 headers.push_back(util::GenerateIfMatchHeader(etag_));
887 return headers; 886 return headers;
888 } 887 }
889 888
890 bool InitiateUploadExistingFileRequest::GetContentData( 889 bool InitiateUploadExistingFileRequest::GetContentData(
891 std::string* upload_content_type, 890 std::string* upload_content_type,
892 std::string* upload_content) { 891 std::string* upload_content) {
893 base::DictionaryValue root; 892 base::DictionaryValue root;
894 if (!parent_resource_id_.empty()) { 893 if (!parent_resource_id_.empty()) {
895 std::unique_ptr<base::ListValue> parents(new base::ListValue); 894 std::unique_ptr<base::ListValue> parents(new base::ListValue);
896 parents->Append(util::CreateParentValue(parent_resource_id_).release()); 895 parents->Append(util::CreateParentValue(parent_resource_id_));
897 root.Set("parents", parents.release()); 896 root.Set("parents", parents.release());
898 } 897 }
899 898
900 if (!title_.empty()) 899 if (!title_.empty())
901 root.SetString("title", title_); 900 root.SetString("title", title_);
902 901
903 if (!modified_date_.is_null()) 902 if (!modified_date_.is_null())
904 root.SetString("modifiedDate", util::FormatTimeAsString(modified_date_)); 903 root.SetString("modifiedDate", util::FormatTimeAsString(modified_date_));
905 904
906 if (!last_viewed_by_me_date_.is_null()) { 905 if (!last_viewed_by_me_date_.is_null()) {
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 } else if (last_progress_value_ < child->data_offset + child->data_size && 1452 } else if (last_progress_value_ < child->data_offset + child->data_size &&
1454 child->data_offset + child->data_size < current) { 1453 child->data_offset + child->data_size < current) {
1455 child->request->NotifyUploadProgress(source, child->data_size, 1454 child->request->NotifyUploadProgress(source, child->data_size,
1456 child->data_size); 1455 child->data_size);
1457 } 1456 }
1458 } 1457 }
1459 last_progress_value_ = current; 1458 last_progress_value_ = current;
1460 } 1459 }
1461 } // namespace drive 1460 } // namespace drive
1462 } // namespace google_apis 1461 } // namespace google_apis
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698