OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/loader/upload_data_stream_builder.h" | 5 #include "content/browser/loader/upload_data_stream_builder.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 base::Time time1, time2; | 102 base::Time time1, time2; |
103 base::Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", &time1); | 103 base::Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", &time1); |
104 base::Time::FromString("Mon, 14 Nov 1994, 11:30:49 GMT", &time2); | 104 base::Time::FromString("Mon, 14 Nov 1994, 11:30:49 GMT", &time2); |
105 | 105 |
106 BlobStorageContext blob_storage_context; | 106 BlobStorageContext blob_storage_context; |
107 | 107 |
108 const std::string blob_id0("id-0"); | 108 const std::string blob_id0("id-0"); |
109 scoped_ptr<BlobDataBuilder> blob_data_builder( | 109 scoped_ptr<BlobDataBuilder> blob_data_builder( |
110 new BlobDataBuilder(blob_id0)); | 110 new BlobDataBuilder(blob_id0)); |
111 scoped_ptr<BlobDataHandle> handle1 = | 111 scoped_ptr<BlobDataHandle> handle1 = |
112 blob_storage_context.AddFinishedBlob(*blob_data_builder.get()); | 112 blob_storage_context.AddFinishedBlob(blob_data_builder.get()); |
113 | 113 |
114 const std::string blob_id1("id-1"); | 114 const std::string blob_id1("id-1"); |
115 blob_data_builder.reset(new BlobDataBuilder(blob_id1)); | 115 blob_data_builder.reset( |
116 blob_data_builder->AppendData("BlobData"); | 116 BlobDataBuilder::Create(blob_id1) |
117 blob_data_builder->AppendFile( | 117 ->AppendData("BlobData") |
118 base::FilePath(FILE_PATH_LITERAL("BlobFile.txt")), 0, 20, time1); | 118 ->AppendFile(base::FilePath(FILE_PATH_LITERAL("BlobFile.txt")), 0, |
| 119 20, time1)); |
119 scoped_ptr<BlobDataHandle> handle2 = | 120 scoped_ptr<BlobDataHandle> handle2 = |
120 blob_storage_context.AddFinishedBlob(*blob_data_builder.get()); | 121 blob_storage_context.AddFinishedBlob(blob_data_builder.get()); |
121 | 122 |
122 // Setup upload data elements for comparison. | 123 // Setup upload data elements for comparison. |
123 auto blob_data = blob_data_builder->BuildSnapshot(); | 124 auto blob_data = blob_data_builder->BuildSnapshot(); |
124 ResourceRequestBody::Element blob_element1, blob_element2; | 125 ResourceRequestBody::Element blob_element1, blob_element2; |
125 blob_element1.SetToBytes( | 126 blob_element1.SetToBytes( |
126 blob_data->items().at(0)->bytes() + | 127 blob_data->items().at(0)->bytes() + |
127 static_cast<int>(blob_data->items().at(0)->offset()), | 128 static_cast<int>(blob_data->items().at(0)->offset()), |
128 static_cast<int>(blob_data->items().at(0)->length())); | 129 static_cast<int>(blob_data->items().at(0)->length())); |
129 blob_element2.SetToFilePathRange( | 130 blob_element2.SetToFilePathRange( |
130 blob_data->items().at(1)->path(), blob_data->items().at(1)->offset(), | 131 blob_data->items().at(1)->path(), blob_data->items().at(1)->offset(), |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 EXPECT_TRUE(AreElementsEqual( | 310 EXPECT_TRUE(AreElementsEqual( |
310 *(*upload->GetElementReaders())[6], blob_element2)); | 311 *(*upload->GetElementReaders())[6], blob_element2)); |
311 EXPECT_TRUE(AreElementsEqual( | 312 EXPECT_TRUE(AreElementsEqual( |
312 *(*upload->GetElementReaders())[7], upload_element2)); | 313 *(*upload->GetElementReaders())[7], upload_element2)); |
313 } | 314 } |
314 // Clean up for ASAN. | 315 // Clean up for ASAN. |
315 base::RunLoop().RunUntilIdle(); | 316 base::RunLoop().RunUntilIdle(); |
316 } | 317 } |
317 | 318 |
318 } // namespace content | 319 } // namespace content |
OLD | NEW |