| 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 #include <utility> | |
| 9 | 8 |
| 10 #include "base/bind.h" | 9 #include "base/bind.h" |
| 11 #include "base/callback.h" | 10 #include "base/callback.h" |
| 12 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 13 #include "base/location.h" | 12 #include "base/location.h" |
| 14 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/metrics/sparse_histogram.h" | 14 #include "base/metrics/sparse_histogram.h" |
| 16 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
| 17 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 | 409 |
| 411 if (!mime_type_.empty()) | 410 if (!mime_type_.empty()) |
| 412 root.SetString("mimeType", mime_type_); | 411 root.SetString("mimeType", mime_type_); |
| 413 | 412 |
| 414 if (!modified_date_.is_null()) | 413 if (!modified_date_.is_null()) |
| 415 root.SetString("modifiedDate", util::FormatTimeAsString(modified_date_)); | 414 root.SetString("modifiedDate", util::FormatTimeAsString(modified_date_)); |
| 416 | 415 |
| 417 if (!parents_.empty()) { | 416 if (!parents_.empty()) { |
| 418 base::ListValue* parents_value = new base::ListValue; | 417 base::ListValue* parents_value = new base::ListValue; |
| 419 for (size_t i = 0; i < parents_.size(); ++i) { | 418 for (size_t i = 0; i < parents_.size(); ++i) { |
| 420 base::DictionaryValue* parent = new base::DictionaryValue; | 419 std::unique_ptr<base::DictionaryValue> parent(new base::DictionaryValue); |
| 421 parent->SetString("id", parents_[i]); | 420 parent->SetString("id", parents_[i]); |
| 422 parents_value->Append(parent); | 421 parents_value->Append(std::move(parent)); |
| 423 } | 422 } |
| 424 root.Set("parents", parents_value); | 423 root.Set("parents", parents_value); |
| 425 } | 424 } |
| 426 | 425 |
| 427 if (!title_.empty()) | 426 if (!title_.empty()) |
| 428 root.SetString("title", title_); | 427 root.SetString("title", title_); |
| 429 | 428 |
| 430 AttachProperties(properties_, &root); | 429 AttachProperties(properties_, &root); |
| 431 base::JSONWriter::Write(root, upload_content); | 430 base::JSONWriter::Write(root, upload_content); |
| 432 | 431 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 root.SetString("modifiedDate", util::FormatTimeAsString(modified_date_)); | 487 root.SetString("modifiedDate", util::FormatTimeAsString(modified_date_)); |
| 489 | 488 |
| 490 if (!last_viewed_by_me_date_.is_null()) { | 489 if (!last_viewed_by_me_date_.is_null()) { |
| 491 root.SetString("lastViewedByMeDate", | 490 root.SetString("lastViewedByMeDate", |
| 492 util::FormatTimeAsString(last_viewed_by_me_date_)); | 491 util::FormatTimeAsString(last_viewed_by_me_date_)); |
| 493 } | 492 } |
| 494 | 493 |
| 495 if (!parents_.empty()) { | 494 if (!parents_.empty()) { |
| 496 base::ListValue* parents_value = new base::ListValue; | 495 base::ListValue* parents_value = new base::ListValue; |
| 497 for (size_t i = 0; i < parents_.size(); ++i) { | 496 for (size_t i = 0; i < parents_.size(); ++i) { |
| 498 base::DictionaryValue* parent = new base::DictionaryValue; | 497 std::unique_ptr<base::DictionaryValue> parent(new base::DictionaryValue); |
| 499 parent->SetString("id", parents_[i]); | 498 parent->SetString("id", parents_[i]); |
| 500 parents_value->Append(parent); | 499 parents_value->Append(std::move(parent)); |
| 501 } | 500 } |
| 502 root.Set("parents", parents_value); | 501 root.Set("parents", parents_value); |
| 503 } | 502 } |
| 504 | 503 |
| 505 AttachProperties(properties_, &root); | 504 AttachProperties(properties_, &root); |
| 506 base::JSONWriter::Write(root, upload_content); | 505 base::JSONWriter::Write(root, upload_content); |
| 507 | 506 |
| 508 DVLOG(1) << "FilesPatch data: " << *upload_content_type << ", [" | 507 DVLOG(1) << "FilesPatch data: " << *upload_content_type << ", [" |
| 509 << *upload_content << "]"; | 508 << *upload_content << "]"; |
| 510 return true; | 509 return true; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 *upload_content_type = util::kContentTypeApplicationJson; | 541 *upload_content_type = util::kContentTypeApplicationJson; |
| 543 | 542 |
| 544 base::DictionaryValue root; | 543 base::DictionaryValue root; |
| 545 | 544 |
| 546 if (!modified_date_.is_null()) | 545 if (!modified_date_.is_null()) |
| 547 root.SetString("modifiedDate", util::FormatTimeAsString(modified_date_)); | 546 root.SetString("modifiedDate", util::FormatTimeAsString(modified_date_)); |
| 548 | 547 |
| 549 if (!parents_.empty()) { | 548 if (!parents_.empty()) { |
| 550 base::ListValue* parents_value = new base::ListValue; | 549 base::ListValue* parents_value = new base::ListValue; |
| 551 for (size_t i = 0; i < parents_.size(); ++i) { | 550 for (size_t i = 0; i < parents_.size(); ++i) { |
| 552 base::DictionaryValue* parent = new base::DictionaryValue; | 551 std::unique_ptr<base::DictionaryValue> parent(new base::DictionaryValue); |
| 553 parent->SetString("id", parents_[i]); | 552 parent->SetString("id", parents_[i]); |
| 554 parents_value->Append(parent); | 553 parents_value->Append(std::move(parent)); |
| 555 } | 554 } |
| 556 root.Set("parents", parents_value); | 555 root.Set("parents", parents_value); |
| 557 } | 556 } |
| 558 | 557 |
| 559 if (!title_.empty()) | 558 if (!title_.empty()) |
| 560 root.SetString("title", title_); | 559 root.SetString("title", title_); |
| 561 | 560 |
| 562 base::JSONWriter::Write(root, upload_content); | 561 base::JSONWriter::Write(root, upload_content); |
| 563 DVLOG(1) << "FilesCopy data: " << *upload_content_type << ", [" | 562 DVLOG(1) << "FilesCopy data: " << *upload_content_type << ", [" |
| 564 << *upload_content << "]"; | 563 << *upload_content << "]"; |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 } else if (last_progress_value_ < child->data_offset + child->data_size && | 1451 } else if (last_progress_value_ < child->data_offset + child->data_size && |
| 1453 child->data_offset + child->data_size < current) { | 1452 child->data_offset + child->data_size < current) { |
| 1454 child->request->NotifyUploadProgress(source, child->data_size, | 1453 child->request->NotifyUploadProgress(source, child->data_size, |
| 1455 child->data_size); | 1454 child->data_size); |
| 1456 } | 1455 } |
| 1457 } | 1456 } |
| 1458 last_progress_value_ = current; | 1457 last_progress_value_ = current; |
| 1459 } | 1458 } |
| 1460 } // namespace drive | 1459 } // namespace drive |
| 1461 } // namespace google_apis | 1460 } // namespace google_apis |
| OLD | NEW |