| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <map> | 6 #include <map> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 | 887 |
| 888 UploadRangeResponse response; | 888 UploadRangeResponse response; |
| 889 scoped_ptr<ResourceEntry> new_entry; | 889 scoped_ptr<ResourceEntry> new_entry; |
| 890 | 890 |
| 891 ResumeUploadOperation* resume_operation = new ResumeUploadOperation( | 891 ResumeUploadOperation* resume_operation = new ResumeUploadOperation( |
| 892 &operation_registry_, | 892 &operation_registry_, |
| 893 request_context_getter_.get(), | 893 request_context_getter_.get(), |
| 894 CreateComposedCallback( | 894 CreateComposedCallback( |
| 895 base::Bind(&test_util::RunAndQuit), | 895 base::Bind(&test_util::RunAndQuit), |
| 896 test_util::CreateCopyResultCallback(&response, &new_entry)), | 896 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 897 ProgressCallback(), |
| 897 UPLOAD_NEW_FILE, | 898 UPLOAD_NEW_FILE, |
| 898 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 899 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 899 upload_url, | 900 upload_url, |
| 900 0, // start_position | 901 0, // start_position |
| 901 kUploadContent.size(), // end_position (exclusive) | 902 kUploadContent.size(), // end_position (exclusive) |
| 902 kUploadContent.size(), // content_length, | 903 kUploadContent.size(), // content_length, |
| 903 "text/plain", // content_type | 904 "text/plain", // content_type |
| 904 buffer); | 905 buffer); |
| 905 | 906 |
| 906 resume_operation->Start( | 907 resume_operation->Start( |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 | 1042 |
| 1042 UploadRangeResponse response; | 1043 UploadRangeResponse response; |
| 1043 scoped_ptr<ResourceEntry> new_entry; | 1044 scoped_ptr<ResourceEntry> new_entry; |
| 1044 | 1045 |
| 1045 ResumeUploadOperation* resume_operation = new ResumeUploadOperation( | 1046 ResumeUploadOperation* resume_operation = new ResumeUploadOperation( |
| 1046 &operation_registry_, | 1047 &operation_registry_, |
| 1047 request_context_getter_.get(), | 1048 request_context_getter_.get(), |
| 1048 CreateComposedCallback( | 1049 CreateComposedCallback( |
| 1049 base::Bind(&test_util::RunAndQuit), | 1050 base::Bind(&test_util::RunAndQuit), |
| 1050 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1051 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1052 ProgressCallback(), |
| 1051 UPLOAD_NEW_FILE, | 1053 UPLOAD_NEW_FILE, |
| 1052 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1054 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 1053 upload_url, | 1055 upload_url, |
| 1054 start_position, | 1056 start_position, |
| 1055 end_position, | 1057 end_position, |
| 1056 kUploadContent.size(), // content_length, | 1058 kUploadContent.size(), // content_length, |
| 1057 "text/plain", // content_type | 1059 "text/plain", // content_type |
| 1058 buffer); | 1060 buffer); |
| 1059 | 1061 |
| 1060 resume_operation->Start( | 1062 resume_operation->Start( |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 | 1187 |
| 1186 UploadRangeResponse response; | 1188 UploadRangeResponse response; |
| 1187 scoped_ptr<ResourceEntry> new_entry; | 1189 scoped_ptr<ResourceEntry> new_entry; |
| 1188 | 1190 |
| 1189 ResumeUploadOperation* resume_operation = new ResumeUploadOperation( | 1191 ResumeUploadOperation* resume_operation = new ResumeUploadOperation( |
| 1190 &operation_registry_, | 1192 &operation_registry_, |
| 1191 request_context_getter_.get(), | 1193 request_context_getter_.get(), |
| 1192 CreateComposedCallback( | 1194 CreateComposedCallback( |
| 1193 base::Bind(&test_util::RunAndQuit), | 1195 base::Bind(&test_util::RunAndQuit), |
| 1194 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1196 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1197 ProgressCallback(), |
| 1195 UPLOAD_NEW_FILE, | 1198 UPLOAD_NEW_FILE, |
| 1196 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1199 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 1197 upload_url, | 1200 upload_url, |
| 1198 0, // start_position | 1201 0, // start_position |
| 1199 kUploadContent.size(), // end_position (exclusive) | 1202 kUploadContent.size(), // end_position (exclusive) |
| 1200 kUploadContent.size(), // content_length, | 1203 kUploadContent.size(), // content_length, |
| 1201 "text/plain", // content_type | 1204 "text/plain", // content_type |
| 1202 buffer); | 1205 buffer); |
| 1203 | 1206 |
| 1204 resume_operation->Start( | 1207 resume_operation->Start( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 | 1279 |
| 1277 UploadRangeResponse response; | 1280 UploadRangeResponse response; |
| 1278 scoped_ptr<ResourceEntry> new_entry; | 1281 scoped_ptr<ResourceEntry> new_entry; |
| 1279 | 1282 |
| 1280 ResumeUploadOperation* resume_operation = new ResumeUploadOperation( | 1283 ResumeUploadOperation* resume_operation = new ResumeUploadOperation( |
| 1281 &operation_registry_, | 1284 &operation_registry_, |
| 1282 request_context_getter_.get(), | 1285 request_context_getter_.get(), |
| 1283 CreateComposedCallback( | 1286 CreateComposedCallback( |
| 1284 base::Bind(&test_util::RunAndQuit), | 1287 base::Bind(&test_util::RunAndQuit), |
| 1285 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1288 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1289 ProgressCallback(), |
| 1286 UPLOAD_EXISTING_FILE, | 1290 UPLOAD_EXISTING_FILE, |
| 1287 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), | 1291 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), |
| 1288 upload_url, | 1292 upload_url, |
| 1289 0, // start_position | 1293 0, // start_position |
| 1290 kUploadContent.size(), // end_position (exclusive) | 1294 kUploadContent.size(), // end_position (exclusive) |
| 1291 kUploadContent.size(), // content_length, | 1295 kUploadContent.size(), // content_length, |
| 1292 "text/plain", // content_type | 1296 "text/plain", // content_type |
| 1293 buffer); | 1297 buffer); |
| 1294 | 1298 |
| 1295 resume_operation->Start( | 1299 resume_operation->Start( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 | 1373 |
| 1370 UploadRangeResponse response; | 1374 UploadRangeResponse response; |
| 1371 scoped_ptr<ResourceEntry> new_entry; | 1375 scoped_ptr<ResourceEntry> new_entry; |
| 1372 | 1376 |
| 1373 ResumeUploadOperation* resume_operation = new ResumeUploadOperation( | 1377 ResumeUploadOperation* resume_operation = new ResumeUploadOperation( |
| 1374 &operation_registry_, | 1378 &operation_registry_, |
| 1375 request_context_getter_.get(), | 1379 request_context_getter_.get(), |
| 1376 CreateComposedCallback( | 1380 CreateComposedCallback( |
| 1377 base::Bind(&test_util::RunAndQuit), | 1381 base::Bind(&test_util::RunAndQuit), |
| 1378 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1382 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1383 ProgressCallback(), |
| 1379 UPLOAD_EXISTING_FILE, | 1384 UPLOAD_EXISTING_FILE, |
| 1380 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), | 1385 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), |
| 1381 upload_url, | 1386 upload_url, |
| 1382 0, // start_position | 1387 0, // start_position |
| 1383 kUploadContent.size(), // end_position (exclusive) | 1388 kUploadContent.size(), // end_position (exclusive) |
| 1384 kUploadContent.size(), // content_length, | 1389 kUploadContent.size(), // content_length, |
| 1385 "text/plain", // content_type | 1390 "text/plain", // content_type |
| 1386 buffer); | 1391 buffer); |
| 1387 | 1392 |
| 1388 resume_operation->Start( | 1393 resume_operation->Start( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), | 1456 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), |
| 1452 http_request_.headers["X-Upload-Content-Length"]); | 1457 http_request_.headers["X-Upload-Content-Length"]); |
| 1453 // For updating an existing file, an empty body should be attached (PUT | 1458 // For updating an existing file, an empty body should be attached (PUT |
| 1454 // requires a body) | 1459 // requires a body) |
| 1455 EXPECT_TRUE(http_request_.has_content); | 1460 EXPECT_TRUE(http_request_.has_content); |
| 1456 EXPECT_EQ("", http_request_.content); | 1461 EXPECT_EQ("", http_request_.content); |
| 1457 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); | 1462 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); |
| 1458 } | 1463 } |
| 1459 | 1464 |
| 1460 } // namespace google_apis | 1465 } // namespace google_apis |
| OLD | NEW |