| 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 #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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // Attaches |properties| to the |request_body| if |properties| is not empty. | 85 // Attaches |properties| to the |request_body| if |properties| is not empty. |
| 86 // |request_body| must not be NULL. | 86 // |request_body| must not be NULL. |
| 87 void AttachProperties(const Properties& properties, | 87 void AttachProperties(const Properties& properties, |
| 88 base::DictionaryValue* request_body) { | 88 base::DictionaryValue* request_body) { |
| 89 DCHECK(request_body); | 89 DCHECK(request_body); |
| 90 if (properties.empty()) | 90 if (properties.empty()) |
| 91 return; | 91 return; |
| 92 | 92 |
| 93 base::ListValue* const properties_value = new base::ListValue; | 93 base::ListValue* const properties_value = new base::ListValue; |
| 94 for (const auto& property : properties) { | 94 for (const auto& property : properties) { |
| 95 base::DictionaryValue* const property_value = new base::DictionaryValue; | 95 std::unique_ptr<base::DictionaryValue> property_value( |
| 96 new base::DictionaryValue); |
| 96 std::string visibility_as_string; | 97 std::string visibility_as_string; |
| 97 switch (property.visibility()) { | 98 switch (property.visibility()) { |
| 98 case Property::VISIBILITY_PRIVATE: | 99 case Property::VISIBILITY_PRIVATE: |
| 99 visibility_as_string = "PRIVATE"; | 100 visibility_as_string = "PRIVATE"; |
| 100 break; | 101 break; |
| 101 case Property::VISIBILITY_PUBLIC: | 102 case Property::VISIBILITY_PUBLIC: |
| 102 visibility_as_string = "PUBLIC"; | 103 visibility_as_string = "PUBLIC"; |
| 103 break; | 104 break; |
| 104 } | 105 } |
| 105 property_value->SetString("visibility", visibility_as_string); | 106 property_value->SetString("visibility", visibility_as_string); |
| 106 property_value->SetString("key", property.key()); | 107 property_value->SetString("key", property.key()); |
| 107 property_value->SetString("value", property.value()); | 108 property_value->SetString("value", property.value()); |
| 108 properties_value->Append(property_value); | 109 properties_value->Append(std::move(property_value)); |
| 109 } | 110 } |
| 110 request_body->Set("properties", properties_value); | 111 request_body->Set("properties", properties_value); |
| 111 } | 112 } |
| 112 | 113 |
| 113 // Creates metadata JSON string for multipart uploading. | 114 // Creates metadata JSON string for multipart uploading. |
| 114 // All the values are optional. If the value is empty or null, the value does | 115 // All the values are optional. If the value is empty or null, the value does |
| 115 // not appear in the metadata. | 116 // not appear in the metadata. |
| 116 std::string CreateMultipartUploadMetadataJson( | 117 std::string CreateMultipartUploadMetadataJson( |
| 117 const std::string& title, | 118 const std::string& title, |
| 118 const std::string& parent_resource_id, | 119 const std::string& parent_resource_id, |
| (...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1425 } else if (last_progress_value_ < child->data_offset + child->data_size && | 1426 } else if (last_progress_value_ < child->data_offset + child->data_size && |
| 1426 child->data_offset + child->data_size < current) { | 1427 child->data_offset + child->data_size < current) { |
| 1427 child->request->NotifyUploadProgress(source, child->data_size, | 1428 child->request->NotifyUploadProgress(source, child->data_size, |
| 1428 child->data_size); | 1429 child->data_size); |
| 1429 } | 1430 } |
| 1430 } | 1431 } |
| 1431 last_progress_value_ = current; | 1432 last_progress_value_ = current; |
| 1432 } | 1433 } |
| 1433 } // namespace drive | 1434 } // namespace drive |
| 1434 } // namespace google_apis | 1435 } // namespace google_apis |
| OLD | NEW |