Index: chrome/browser/drive/fake_drive_service.cc |
diff --git a/chrome/browser/drive/fake_drive_service.cc b/chrome/browser/drive/fake_drive_service.cc |
index 32d9d2d1720bb47382ac018741308110a07e894f..f9083f24cf39819cd63af002e1f72bbb5c579974 100644 |
--- a/chrome/browser/drive/fake_drive_service.cc |
+++ b/chrome/browser/drive/fake_drive_service.cc |
@@ -7,6 +7,7 @@ |
#include <string> |
#include "base/logging.h" |
+#include "base/md5.h" |
#include "base/message_loop.h" |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/string_split.h" |
@@ -548,7 +549,6 @@ CancelCallback FakeDriveService::DownloadFile( |
// Write "x"s of the file size specified in the entry. |
std::string file_size_string; |
entry->GetString("docs$size.$t", &file_size_string); |
- // TODO(satorux): To be correct, we should update docs$md5Checksum.$t here. |
int64 file_size = 0; |
if (base::StringToInt64(file_size_string, &file_size)) { |
base::BinaryValue* content_binary_data; |
@@ -1029,6 +1029,32 @@ CancelCallback FakeDriveService::ResumeUpload( |
entry->SetString("docs$size.$t", base::Int64ToString(end_position)); |
+ scoped_ptr<char[]> buffer(new char[end_position]); |
+ if (!test_util::ReadFile(local_file_path, |
+ start_position, buffer.get() + start_position, |
+ end_position - start_position)) { |
+ base::MessageLoop::current()->PostTask( |
+ FROM_HERE, |
+ base::Bind(callback, |
+ UploadRangeResponse(GDATA_FILE_ERROR, |
+ start_position, |
+ end_position), |
+ base::Passed(&result_entry))); |
+ return CancelCallback(); |
+ } |
+ |
+ base::BinaryValue* content_binary_data = NULL; |
+ if (entry->GetBinary("test$data", &content_binary_data)) { |
+ std::copy(content_binary_data->GetBuffer(), |
+ content_binary_data->GetBuffer() + start_position, |
+ buffer.get()); |
+ } |
+ |
+ base::MD5Digest digest; |
+ base::MD5Sum(buffer.get(), end_position, &digest); |
+ entry->SetString("docs$md5Checksum.$t", base::MD5DigestToBase16(digest)); |
+ entry->Set("test$data", new base::BinaryValue(buffer.Pass(), end_position)); |
hashimoto
2013/06/20 10:17:42
Do we need to update the entry's state before the
tzik
2013/06/20 13:37:22
It needs a bit more work to achieve no-op on cance
hashimoto
2013/06/20 14:36:44
Good catch, setting "docs$size.$t" to 0 while leav
tzik
2013/06/20 15:31:46
Done.
I introduced UploadSession to make abondand
|
+ |
if (!progress_callback.is_null()) { |
// In the real GDataWapi/Drive DriveService, progress is reported in |
// nondeterministic timing. In this fake implementation, we choose to call |
@@ -1290,9 +1316,8 @@ const base::DictionaryValue* FakeDriveService::AddNewEntry( |
content_data.c_str(), content_data.size())); |
new_entry->SetString("docs$size.$t", |
base::Int64ToString(content_data.size())); |
- // TODO(satorux): Set the correct MD5 here. |
new_entry->SetString("docs$md5Checksum.$t", |
- "3b4385ebefec6e743574c76bbd0575de"); |
+ base::MD5String(content_data)); |
} |
// Add "category" which sets the resource type to |entry_kind|. |