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

Side by Side Diff: content/browser/loader/upload_data_stream_builder_unittest.cc

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: one more fix, content bound_net_log_ Created 4 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
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 upload = UploadDataStreamBuilder::Build( 131 upload = UploadDataStreamBuilder::Build(
132 request_body.get(), &blob_storage_context, NULL, 132 request_body.get(), &blob_storage_context, NULL,
133 base::ThreadTaskRunnerHandle::Get().get()); 133 base::ThreadTaskRunnerHandle::Get().get());
134 ASSERT_TRUE(upload->GetElementReaders()); 134 ASSERT_TRUE(upload->GetElementReaders());
135 const auto& readers = *upload->GetElementReaders(); 135 const auto& readers = *upload->GetElementReaders();
136 ASSERT_EQ(3U, readers.size()); 136 ASSERT_EQ(3U, readers.size());
137 137
138 net::TestCompletionCallback init_callback; 138 net::TestCompletionCallback init_callback;
139 ASSERT_EQ(net::ERR_IO_PENDING, 139 ASSERT_EQ(net::ERR_IO_PENDING,
140 upload->Init(init_callback.callback(), net::BoundNetLog())); 140 upload->Init(init_callback.callback(), net::NetLogWithSource()));
141 EXPECT_EQ(net::OK, init_callback.WaitForResult()); 141 EXPECT_EQ(net::OK, init_callback.WaitForResult());
142 142
143 EXPECT_EQ(kZeroLength, upload->size()); 143 EXPECT_EQ(kZeroLength, upload->size());
144 144
145 // Purposely (try to) read more than what is in the stream. If we try to 145 // Purposely (try to) read more than what is in the stream. If we try to
146 // read zero bytes then UploadDataStream::Read will fail a DCHECK. 146 // read zero bytes then UploadDataStream::Read will fail a DCHECK.
147 int kBufferLength = kZeroLength + 1; 147 int kBufferLength = kZeroLength + 1;
148 std::unique_ptr<char[]> buffer(new char[kBufferLength]); 148 std::unique_ptr<char[]> buffer(new char[kBufferLength]);
149 scoped_refptr<net::IOBuffer> io_buffer = 149 scoped_refptr<net::IOBuffer> io_buffer =
150 new net::WrappedIOBuffer(buffer.get()); 150 new net::WrappedIOBuffer(buffer.get());
(...skipping 27 matching lines...) Expand all
178 request_body->AppendBlob(kBlob); 178 request_body->AppendBlob(kBlob);
179 request_body->set_identifier(kIdentifier); 179 request_body->set_identifier(kIdentifier);
180 180
181 std::unique_ptr<net::UploadDataStream> upload( 181 std::unique_ptr<net::UploadDataStream> upload(
182 UploadDataStreamBuilder::Build( 182 UploadDataStreamBuilder::Build(
183 request_body.get(), &blob_storage_context, nullptr, 183 request_body.get(), &blob_storage_context, nullptr,
184 base::ThreadTaskRunnerHandle::Get().get())); 184 base::ThreadTaskRunnerHandle::Get().get()));
185 185
186 net::TestCompletionCallback init_callback; 186 net::TestCompletionCallback init_callback;
187 ASSERT_EQ(net::OK, 187 ASSERT_EQ(net::OK,
188 upload->Init(init_callback.callback(), net::BoundNetLog())); 188 upload->Init(init_callback.callback(), net::NetLogWithSource()));
189 189
190 // Read part of the data. 190 // Read part of the data.
191 const int kBufferLength = 4; 191 const int kBufferLength = 4;
192 scoped_refptr<net::IOBufferWithSize> buffer( 192 scoped_refptr<net::IOBufferWithSize> buffer(
193 new net::IOBufferWithSize(kBufferLength)); 193 new net::IOBufferWithSize(kBufferLength));
194 net::TestCompletionCallback read_callback; 194 net::TestCompletionCallback read_callback;
195 int result = 195 int result =
196 upload->Read(buffer.get(), buffer->size(), read_callback.callback()); 196 upload->Read(buffer.get(), buffer->size(), read_callback.callback());
197 EXPECT_EQ(kBufferLength, read_callback.GetResult(result)); 197 EXPECT_EQ(kBufferLength, read_callback.GetResult(result));
198 EXPECT_EQ(0, 198 EXPECT_EQ(0,
199 std::memcmp(kBlobData.c_str(), buffer->data(), buffer->size())); 199 std::memcmp(kBlobData.c_str(), buffer->data(), buffer->size()));
200 200
201 // Reset. 201 // Reset.
202 ASSERT_EQ(net::OK, 202 ASSERT_EQ(net::OK,
203 upload->Init(init_callback.callback(), net::BoundNetLog())); 203 upload->Init(init_callback.callback(), net::NetLogWithSource()));
204 204
205 // Read all the data. 205 // Read all the data.
206 buffer = new net::IOBufferWithSize(kBlobDataLength); 206 buffer = new net::IOBufferWithSize(kBlobDataLength);
207 result = 207 result =
208 upload->Read(buffer.get(), buffer->size(), read_callback.callback()); 208 upload->Read(buffer.get(), buffer->size(), read_callback.callback());
209 EXPECT_EQ(kBlobDataLength, read_callback.GetResult(result)); 209 EXPECT_EQ(kBlobDataLength, read_callback.GetResult(result));
210 EXPECT_EQ(0, 210 EXPECT_EQ(0,
211 std::memcmp(kBlobData.c_str(), buffer->data(), buffer->size())); 211 std::memcmp(kBlobData.c_str(), buffer->data(), buffer->size()));
212 } 212 }
213 // Clean up for ASAN. 213 // Clean up for ASAN.
214 base::RunLoop().RunUntilIdle(); 214 base::RunLoop().RunUntilIdle();
215 } 215 }
216 } // namespace content 216 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698