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

Side by Side Diff: chrome/browser/drive/fake_drive_service.cc

Issue 23591067: Add last_modified to CopyResource and MoveResource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
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 "chrome/browser/drive/fake_drive_service.h" 5 #include "chrome/browser/drive/fake_drive_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 base::MessageLoopProxy::current()->PostTask( 684 base::MessageLoopProxy::current()->PostTask(
685 FROM_HERE, 685 FROM_HERE,
686 base::Bind(download_action_callback, GDATA_FILE_ERROR, base::FilePath())); 686 base::Bind(download_action_callback, GDATA_FILE_ERROR, base::FilePath()));
687 return CancelCallback(); 687 return CancelCallback();
688 } 688 }
689 689
690 CancelCallback FakeDriveService::CopyResource( 690 CancelCallback FakeDriveService::CopyResource(
691 const std::string& resource_id, 691 const std::string& resource_id,
692 const std::string& in_parent_resource_id, 692 const std::string& in_parent_resource_id,
693 const std::string& new_title, 693 const std::string& new_title,
694 const base::Time& last_modified,
694 const GetResourceEntryCallback& callback) { 695 const GetResourceEntryCallback& callback) {
695 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 696 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
696 DCHECK(!callback.is_null()); 697 DCHECK(!callback.is_null());
697 698
698 if (offline_) { 699 if (offline_) {
699 scoped_ptr<ResourceEntry> null; 700 scoped_ptr<ResourceEntry> null;
700 base::MessageLoop::current()->PostTask( 701 base::MessageLoop::current()->PostTask(
701 FROM_HERE, 702 FROM_HERE,
702 base::Bind(callback, 703 base::Bind(callback,
703 GDATA_NO_CONNECTION, 704 GDATA_NO_CONNECTION,
(...skipping 26 matching lines...) Expand all
730 copied_entry->Set("link", links); 731 copied_entry->Set("link", links);
731 } 732 }
732 links->Clear(); 733 links->Clear();
733 734
734 base::DictionaryValue* link = new base::DictionaryValue; 735 base::DictionaryValue* link = new base::DictionaryValue;
735 link->SetString( 736 link->SetString(
736 "rel", "http://schemas.google.com/docs/2007#parent"); 737 "rel", "http://schemas.google.com/docs/2007#parent");
737 link->SetString("href", GetFakeLinkUrl(parent_resource_id).spec()); 738 link->SetString("href", GetFakeLinkUrl(parent_resource_id).spec());
738 links->Append(link); 739 links->Append(link);
739 740
741 if (!last_modified.is_null()) {
742 copied_entry->SetString(
743 "updated.$t",
744 google_apis::util::FormatTimeAsString(last_modified));
745 }
746
740 AddNewChangestampAndETag(copied_entry.get()); 747 AddNewChangestampAndETag(copied_entry.get());
741 748
742 // Parse the new entry. 749 // Parse the new entry.
743 scoped_ptr<ResourceEntry> resource_entry = 750 scoped_ptr<ResourceEntry> resource_entry =
744 ResourceEntry::CreateFrom(*copied_entry); 751 ResourceEntry::CreateFrom(*copied_entry);
745 // Add it to the resource list. 752 // Add it to the resource list.
746 entries->Append(copied_entry.release()); 753 entries->Append(copied_entry.release());
747 754
748 base::MessageLoop::current()->PostTask( 755 base::MessageLoop::current()->PostTask(
749 FROM_HERE, 756 FROM_HERE,
(...skipping 12 matching lines...) Expand all
762 return CancelCallback(); 769 return CancelCallback();
763 } 770 }
764 771
765 CancelCallback FakeDriveService::CopyHostedDocument( 772 CancelCallback FakeDriveService::CopyHostedDocument(
766 const std::string& resource_id, 773 const std::string& resource_id,
767 const std::string& new_title, 774 const std::string& new_title,
768 const GetResourceEntryCallback& callback) { 775 const GetResourceEntryCallback& callback) {
769 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 776 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
770 DCHECK(!callback.is_null()); 777 DCHECK(!callback.is_null());
771 778
772 return CopyResource(resource_id, std::string(), new_title, callback); 779 return CopyResource(
780 resource_id, std::string(), new_title, base::Time(), callback);
773 } 781 }
774 782
775 CancelCallback FakeDriveService::MoveResource( 783 CancelCallback FakeDriveService::MoveResource(
776 const std::string& resource_id, 784 const std::string& resource_id,
777 const std::string& parent_resource_id, 785 const std::string& parent_resource_id,
778 const std::string& new_title, 786 const std::string& new_title,
787 const base::Time& last_modified,
779 const google_apis::GetResourceEntryCallback& callback) { 788 const google_apis::GetResourceEntryCallback& callback) {
780 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 789 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
781 DCHECK(!callback.is_null()); 790 DCHECK(!callback.is_null());
782 791
783 if (offline_) { 792 if (offline_) {
784 base::MessageLoop::current()->PostTask( 793 base::MessageLoop::current()->PostTask(
785 FROM_HERE, base::Bind(callback, GDATA_NO_CONNECTION, 794 FROM_HERE, base::Bind(callback, GDATA_NO_CONNECTION,
786 base::Passed(scoped_ptr<ResourceEntry>()))); 795 base::Passed(scoped_ptr<ResourceEntry>())));
787 return CancelCallback(); 796 return CancelCallback();
788 } 797 }
(...skipping 25 matching lines...) Expand all
814 } 823 }
815 } 824 }
816 825
817 base::DictionaryValue* link = new base::DictionaryValue; 826 base::DictionaryValue* link = new base::DictionaryValue;
818 link->SetString("rel", "http://schemas.google.com/docs/2007#parent"); 827 link->SetString("rel", "http://schemas.google.com/docs/2007#parent");
819 link->SetString( 828 link->SetString(
820 "href", GetFakeLinkUrl(parent_resource_id).spec()); 829 "href", GetFakeLinkUrl(parent_resource_id).spec());
821 links->Append(link); 830 links->Append(link);
822 } 831 }
823 832
833 if (!last_modified.is_null()) {
834 entry->SetString(
835 "updated.$t",
836 google_apis::util::FormatTimeAsString(last_modified));
837 }
838
824 AddNewChangestampAndETag(entry); 839 AddNewChangestampAndETag(entry);
825 840
826 // Parse the new entry. 841 // Parse the new entry.
827 scoped_ptr<ResourceEntry> resource_entry = 842 scoped_ptr<ResourceEntry> resource_entry =
828 ResourceEntry::CreateFrom(*entry); 843 ResourceEntry::CreateFrom(*entry);
829 base::MessageLoop::current()->PostTask( 844 base::MessageLoop::current()->PostTask(
830 FROM_HERE, 845 FROM_HERE,
831 base::Bind(callback, HTTP_SUCCESS, base::Passed(&resource_entry))); 846 base::Bind(callback, HTTP_SUCCESS, base::Passed(&resource_entry)));
832 return CancelCallback(); 847 return CancelCallback();
833 } 848 }
834 849
835 base::MessageLoop::current()->PostTask( 850 base::MessageLoop::current()->PostTask(
836 FROM_HERE, 851 FROM_HERE,
837 base::Bind(callback, HTTP_NOT_FOUND, 852 base::Bind(callback, HTTP_NOT_FOUND,
838 base::Passed(scoped_ptr<ResourceEntry>()))); 853 base::Passed(scoped_ptr<ResourceEntry>())));
839 return CancelCallback(); 854 return CancelCallback();
840 } 855 }
841 856
842 CancelCallback FakeDriveService::RenameResource( 857 CancelCallback FakeDriveService::RenameResource(
843 const std::string& resource_id, 858 const std::string& resource_id,
844 const std::string& new_title, 859 const std::string& new_title,
845 const EntryActionCallback& callback) { 860 const EntryActionCallback& callback) {
846 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 861 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
847 DCHECK(!callback.is_null()); 862 DCHECK(!callback.is_null());
848 863
849 return MoveResource( 864 return MoveResource(
850 resource_id, std::string(), new_title, 865 resource_id, std::string(), new_title, base::Time(),
851 base::Bind(&EntryActionCallbackAdapter, callback)); 866 base::Bind(&EntryActionCallbackAdapter, callback));
852 } 867 }
853 868
854 CancelCallback FakeDriveService::TouchResource( 869 CancelCallback FakeDriveService::TouchResource(
855 const std::string& resource_id, 870 const std::string& resource_id,
856 const base::Time& modified_date, 871 const base::Time& modified_date,
857 const base::Time& last_viewed_by_me_date, 872 const base::Time& last_viewed_by_me_date,
858 const GetResourceEntryCallback& callback) { 873 const GetResourceEntryCallback& callback) {
859 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 874 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
860 DCHECK(!modified_date.is_null()); 875 DCHECK(!modified_date.is_null());
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1663 FROM_HERE, 1678 FROM_HERE,
1664 base::Bind(callback, HTTP_SUCCESS, base::Passed(&resource_list))); 1679 base::Bind(callback, HTTP_SUCCESS, base::Passed(&resource_list)));
1665 } 1680 }
1666 1681
1667 GURL FakeDriveService::GetNewUploadSessionUrl() { 1682 GURL FakeDriveService::GetNewUploadSessionUrl() {
1668 return GURL("https://upload_session_url/" + 1683 return GURL("https://upload_session_url/" +
1669 base::Int64ToString(next_upload_sequence_number_++)); 1684 base::Int64ToString(next_upload_sequence_number_++));
1670 } 1685 }
1671 1686
1672 } // namespace drive 1687 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/drive/fake_drive_service.h ('k') | chrome/browser/drive/fake_drive_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698