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

Side by Side Diff: components/drive/service/fake_drive_service.cc

Issue 2748053005: Parse TeamDrive resource inside ChangeList. (Closed)
Patch Set: Default the type field to UNKNOWN as it's not causing new test failures. Created 3 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 unified diff | Download patch
« no previous file with comments | « components/drive/service/drive_api_service.cc ('k') | google_apis/drive/drive_api_parser.h » ('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 #include "components/drive/service/fake_drive_service.h" 5 #include "components/drive/service/fake_drive_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 using google_apis::HTTP_CREATED; 56 using google_apis::HTTP_CREATED;
57 using google_apis::HTTP_FORBIDDEN; 57 using google_apis::HTTP_FORBIDDEN;
58 using google_apis::HTTP_NOT_FOUND; 58 using google_apis::HTTP_NOT_FOUND;
59 using google_apis::HTTP_NO_CONTENT; 59 using google_apis::HTTP_NO_CONTENT;
60 using google_apis::HTTP_PRECONDITION; 60 using google_apis::HTTP_PRECONDITION;
61 using google_apis::HTTP_RESUME_INCOMPLETE; 61 using google_apis::HTTP_RESUME_INCOMPLETE;
62 using google_apis::HTTP_SUCCESS; 62 using google_apis::HTTP_SUCCESS;
63 using google_apis::InitiateUploadCallback; 63 using google_apis::InitiateUploadCallback;
64 using google_apis::ParentReference; 64 using google_apis::ParentReference;
65 using google_apis::ProgressCallback; 65 using google_apis::ProgressCallback;
66 using google_apis::TeamDriveResource;
66 using google_apis::UploadRangeResponse; 67 using google_apis::UploadRangeResponse;
67 using google_apis::drive::UploadRangeCallback; 68 using google_apis::drive::UploadRangeCallback;
68 namespace test_util = google_apis::test_util; 69 namespace test_util = google_apis::test_util;
69 70
70 namespace drive { 71 namespace drive {
71 namespace { 72 namespace {
72 73
73 // Returns true if the entry matches with the search query. 74 // Returns true if the entry matches with the search query.
74 // Supports queries consist of following format. 75 // Supports queries consist of following format.
75 // - Phrases quoted by double/single quotes 76 // - Phrases quoted by double/single quotes
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 base::ThreadTaskRunnerHandle::Get()->PostTask( 831 base::ThreadTaskRunnerHandle::Get()->PostTask(
831 FROM_HERE, base::Bind(callback, HTTP_NOT_FOUND, 832 FROM_HERE, base::Bind(callback, HTTP_NOT_FOUND,
832 base::Passed(std::unique_ptr<FileResource>()))); 833 base::Passed(std::unique_ptr<FileResource>())));
833 return CancelCallback(); 834 return CancelCallback();
834 } 835 }
835 836
836 // Make a copy and set the new resource ID and the new title. 837 // Make a copy and set the new resource ID and the new title.
837 std::unique_ptr<EntryInfo> copied_entry(new EntryInfo); 838 std::unique_ptr<EntryInfo> copied_entry(new EntryInfo);
838 copied_entry->content_data = entry->content_data; 839 copied_entry->content_data = entry->content_data;
839 copied_entry->share_url = entry->share_url; 840 copied_entry->share_url = entry->share_url;
841 copied_entry->change_resource.set_type(ChangeResource::FILE);
840 copied_entry->change_resource.set_file( 842 copied_entry->change_resource.set_file(
841 base::MakeUnique<FileResource>(*entry->change_resource.file())); 843 base::MakeUnique<FileResource>(*entry->change_resource.file()));
842 844
843 ChangeResource* new_change = &copied_entry->change_resource; 845 ChangeResource* new_change = &copied_entry->change_resource;
844 FileResource* new_file = new_change->mutable_file(); 846 FileResource* new_file = new_change->mutable_file();
845 const std::string new_resource_id = GetNewResourceId(); 847 const std::string new_resource_id = GetNewResourceId();
846 new_change->set_file_id(new_resource_id); 848 new_change->set_file_id(new_resource_id);
847 new_file->set_file_id(new_resource_id); 849 new_file->set_file_id(new_resource_id);
848 new_file->set_title(new_title); 850 new_file->set_title(new_title);
849 851
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 1591
1590 const std::string resource_id = 1592 const std::string resource_id =
1591 given_resource_id.empty() ? GetNewResourceId() : given_resource_id; 1593 given_resource_id.empty() ? GetNewResourceId() : given_resource_id;
1592 if (entries_.count(resource_id)) 1594 if (entries_.count(resource_id))
1593 return NULL; 1595 return NULL;
1594 GURL upload_url = GURL("https://xxx/upload/" + resource_id); 1596 GURL upload_url = GURL("https://xxx/upload/" + resource_id);
1595 1597
1596 std::unique_ptr<EntryInfo> new_entry(new EntryInfo); 1598 std::unique_ptr<EntryInfo> new_entry(new EntryInfo);
1597 ChangeResource* new_change = &new_entry->change_resource; 1599 ChangeResource* new_change = &new_entry->change_resource;
1598 FileResource* new_file = new FileResource; 1600 FileResource* new_file = new FileResource;
1601 new_change->set_type(ChangeResource::FILE);
1599 new_change->set_file(base::WrapUnique(new_file)); 1602 new_change->set_file(base::WrapUnique(new_file));
1600 1603
1601 // Set the resource ID and the title 1604 // Set the resource ID and the title
1602 new_change->set_file_id(resource_id); 1605 new_change->set_file_id(resource_id);
1603 new_file->set_file_id(resource_id); 1606 new_file->set_file_id(resource_id);
1604 new_file->set_title(title); 1607 new_file->set_title(title);
1605 // Set the contents, size and MD5 for a file. 1608 // Set the contents, size and MD5 for a file.
1606 if (content_type != util::kDriveFolderMimeType && 1609 if (content_type != util::kDriveFolderMimeType &&
1607 !util::IsKnownHostedDocumentMimeType(content_type)) { 1610 !util::IsKnownHostedDocumentMimeType(content_type)) {
1608 new_entry->content_data = content_data; 1611 new_entry->content_data = content_data;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 ++num_entries_matched; 1712 ++num_entries_matched;
1710 1713
1711 // If |start_offset| is set, exclude the entry if the entry is before the 1714 // If |start_offset| is set, exclude the entry if the entry is before the
1712 // start index. <= instead of < as |num_entries_matched| was 1715 // start index. <= instead of < as |num_entries_matched| was
1713 // already incremented. 1716 // already incremented.
1714 if (start_offset > 0 && num_entries_matched <= start_offset) 1717 if (start_offset > 0 && num_entries_matched <= start_offset)
1715 should_exclude = true; 1718 should_exclude = true;
1716 1719
1717 if (!should_exclude) { 1720 if (!should_exclude) {
1718 std::unique_ptr<ChangeResource> entry_copied(new ChangeResource); 1721 std::unique_ptr<ChangeResource> entry_copied(new ChangeResource);
1722 entry_copied->set_type(entry.type());
1719 entry_copied->set_change_id(entry.change_id()); 1723 entry_copied->set_change_id(entry.change_id());
1720 entry_copied->set_file_id(entry.file_id()); 1724 entry_copied->set_file_id(entry.file_id());
1721 entry_copied->set_deleted(entry.is_deleted()); 1725 entry_copied->set_deleted(entry.is_deleted());
1722 if (entry.file()) { 1726 if (entry.type() == ChangeResource::FILE && entry.file()) {
1723 entry_copied->set_file(base::MakeUnique<FileResource>(*entry.file())); 1727 entry_copied->set_file(base::MakeUnique<FileResource>(*entry.file()));
1724 } 1728 }
1729 if (entry.type() == ChangeResource::TEAM_DRIVE && entry.team_drive()) {
1730 entry_copied->set_team_drive(
1731 base::MakeUnique<TeamDriveResource>(*entry.team_drive()));
1732 }
1725 entry_copied->set_modification_date(entry.modification_date()); 1733 entry_copied->set_modification_date(entry.modification_date());
1726 entries.push_back(std::move(entry_copied)); 1734 entries.push_back(std::move(entry_copied));
1727 } 1735 }
1728 } 1736 }
1729 1737
1730 std::unique_ptr<ChangeList> change_list(new ChangeList); 1738 std::unique_ptr<ChangeList> change_list(new ChangeList);
1731 if (start_changestamp > 0 && start_offset == 0) { 1739 if (start_changestamp > 0 && start_offset == 0) {
1732 change_list->set_largest_change_id(about_resource_->largest_change_id()); 1740 change_list->set_largest_change_id(about_resource_->largest_change_id());
1733 } 1741 }
1734 1742
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 NOTREACHED(); 1801 NOTREACHED();
1794 return std::unique_ptr<BatchRequestConfiguratorInterface>(); 1802 return std::unique_ptr<BatchRequestConfiguratorInterface>();
1795 } 1803 }
1796 1804
1797 void FakeDriveService::NotifyObservers() { 1805 void FakeDriveService::NotifyObservers() {
1798 for (auto& observer : change_observers_) 1806 for (auto& observer : change_observers_)
1799 observer.OnNewChangeAvailable(); 1807 observer.OnNewChangeAvailable();
1800 } 1808 }
1801 1809
1802 } // namespace drive 1810 } // namespace drive
OLDNEW
« no previous file with comments | « components/drive/service/drive_api_service.cc ('k') | google_apis/drive/drive_api_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698