| 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 "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/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 scoped_ptr<FileResource> entry) { | 108 scoped_ptr<FileResource> entry) { |
| 109 base::MessageLoop::current()->PostTask( | 109 base::MessageLoop::current()->PostTask( |
| 110 FROM_HERE, | 110 FROM_HERE, |
| 111 base::Bind(callback, | 111 base::Bind(callback, |
| 112 UploadRangeResponse(error, | 112 UploadRangeResponse(error, |
| 113 start_position, | 113 start_position, |
| 114 end_position), | 114 end_position), |
| 115 base::Passed(&entry))); | 115 base::Passed(&entry))); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void EntryActionCallbackAdapter( | |
| 119 const EntryActionCallback& callback, | |
| 120 GDataErrorCode error, scoped_ptr<FileResource> file) { | |
| 121 callback.Run(error); | |
| 122 } | |
| 123 | |
| 124 void FileListCallbackAdapter(const FileListCallback& callback, | 118 void FileListCallbackAdapter(const FileListCallback& callback, |
| 125 GDataErrorCode error, | 119 GDataErrorCode error, |
| 126 scoped_ptr<ChangeList> change_list) { | 120 scoped_ptr<ChangeList> change_list) { |
| 127 scoped_ptr<FileList> file_list; | 121 scoped_ptr<FileList> file_list; |
| 128 if (change_list) { | 122 if (change_list) { |
| 129 file_list.reset(new FileList); | 123 file_list.reset(new FileList); |
| 130 file_list->set_next_link(change_list->next_link()); | 124 file_list->set_next_link(change_list->next_link()); |
| 131 for (size_t i = 0; i < change_list->items().size(); ++i) { | 125 for (size_t i = 0; i < change_list->items().size(); ++i) { |
| 132 const ChangeResource& entry = *change_list->items()[i]; | 126 const ChangeResource& entry = *change_list->items()[i]; |
| 133 if (entry.file()) | 127 if (entry.file()) |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 return CancelCallback(); | 847 return CancelCallback(); |
| 854 } | 848 } |
| 855 | 849 |
| 856 base::MessageLoop::current()->PostTask( | 850 base::MessageLoop::current()->PostTask( |
| 857 FROM_HERE, | 851 FROM_HERE, |
| 858 base::Bind(callback, HTTP_NOT_FOUND, | 852 base::Bind(callback, HTTP_NOT_FOUND, |
| 859 base::Passed(scoped_ptr<FileResource>()))); | 853 base::Passed(scoped_ptr<FileResource>()))); |
| 860 return CancelCallback(); | 854 return CancelCallback(); |
| 861 } | 855 } |
| 862 | 856 |
| 863 CancelCallback FakeDriveService::RenameResource( | |
| 864 const std::string& resource_id, | |
| 865 const std::string& new_title, | |
| 866 const EntryActionCallback& callback) { | |
| 867 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 868 DCHECK(!callback.is_null()); | |
| 869 | |
| 870 return UpdateResource( | |
| 871 resource_id, std::string(), new_title, base::Time(), base::Time(), | |
| 872 base::Bind(&EntryActionCallbackAdapter, callback)); | |
| 873 } | |
| 874 | |
| 875 CancelCallback FakeDriveService::AddResourceToDirectory( | 857 CancelCallback FakeDriveService::AddResourceToDirectory( |
| 876 const std::string& parent_resource_id, | 858 const std::string& parent_resource_id, |
| 877 const std::string& resource_id, | 859 const std::string& resource_id, |
| 878 const EntryActionCallback& callback) { | 860 const EntryActionCallback& callback) { |
| 879 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 861 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 880 DCHECK(!callback.is_null()); | 862 DCHECK(!callback.is_null()); |
| 881 | 863 |
| 882 if (offline_) { | 864 if (offline_) { |
| 883 base::MessageLoop::current()->PostTask( | 865 base::MessageLoop::current()->PostTask( |
| 884 FROM_HERE, base::Bind(callback, GDATA_NO_CONNECTION)); | 866 FROM_HERE, base::Bind(callback, GDATA_NO_CONNECTION)); |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 google_apis::drive::PermissionRole role, | 1557 google_apis::drive::PermissionRole role, |
| 1576 const google_apis::EntryActionCallback& callback) { | 1558 const google_apis::EntryActionCallback& callback) { |
| 1577 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1559 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1578 DCHECK(!callback.is_null()); | 1560 DCHECK(!callback.is_null()); |
| 1579 | 1561 |
| 1580 NOTREACHED(); | 1562 NOTREACHED(); |
| 1581 return CancelCallback(); | 1563 return CancelCallback(); |
| 1582 } | 1564 } |
| 1583 | 1565 |
| 1584 } // namespace drive | 1566 } // namespace drive |
| OLD | NEW |