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

Side by Side Diff: net/http/http_stream_parser_unittest.cc

Issue 657013003: Use scoped_ptr::Pass instead of scoped_ptr::PassAs<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « net/http/http_stream_factory_impl_unittest.cc ('k') | net/ocsp/nss_ocsp_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/http/http_stream_parser.h" 5 #include "net/http/http_stream_parser.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 scoped_ptr<DeterministicMockTCPClientSocket> transport( 229 scoped_ptr<DeterministicMockTCPClientSocket> transport(
230 new DeterministicMockTCPClientSocket(NULL, &data)); 230 new DeterministicMockTCPClientSocket(NULL, &data));
231 data.set_delegate(transport->AsWeakPtr()); 231 data.set_delegate(transport->AsWeakPtr());
232 232
233 TestCompletionCallback callback; 233 TestCompletionCallback callback;
234 int rv = transport->Connect(callback.callback()); 234 int rv = transport->Connect(callback.callback());
235 rv = callback.GetResult(rv); 235 rv = callback.GetResult(rv);
236 ASSERT_EQ(OK, rv); 236 ASSERT_EQ(OK, rv);
237 237
238 scoped_ptr<ClientSocketHandle> socket_handle(new ClientSocketHandle); 238 scoped_ptr<ClientSocketHandle> socket_handle(new ClientSocketHandle);
239 socket_handle->SetSocket(transport.PassAs<StreamSocket>()); 239 socket_handle->SetSocket(transport.Pass());
240 240
241 HttpRequestInfo request_info; 241 HttpRequestInfo request_info;
242 request_info.method = "GET"; 242 request_info.method = "GET";
243 request_info.url = GURL("http://localhost"); 243 request_info.url = GURL("http://localhost");
244 request_info.load_flags = LOAD_NORMAL; 244 request_info.load_flags = LOAD_NORMAL;
245 request_info.upload_data_stream = &upload_stream; 245 request_info.upload_data_stream = &upload_stream;
246 246
247 scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); 247 scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer);
248 HttpStreamParser parser( 248 HttpStreamParser parser(
249 socket_handle.get(), &request_info, read_buffer.get(), BoundNetLog()); 249 socket_handle.get(), &request_info, read_buffer.get(), BoundNetLog());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 scoped_ptr<DeterministicMockTCPClientSocket> transport( 384 scoped_ptr<DeterministicMockTCPClientSocket> transport(
385 new DeterministicMockTCPClientSocket(NULL, &data)); 385 new DeterministicMockTCPClientSocket(NULL, &data));
386 data.set_delegate(transport->AsWeakPtr()); 386 data.set_delegate(transport->AsWeakPtr());
387 387
388 TestCompletionCallback callback; 388 TestCompletionCallback callback;
389 int rv = transport->Connect(callback.callback()); 389 int rv = transport->Connect(callback.callback());
390 rv = callback.GetResult(rv); 390 rv = callback.GetResult(rv);
391 ASSERT_EQ(OK, rv); 391 ASSERT_EQ(OK, rv);
392 392
393 scoped_ptr<ClientSocketHandle> socket_handle(new ClientSocketHandle); 393 scoped_ptr<ClientSocketHandle> socket_handle(new ClientSocketHandle);
394 socket_handle->SetSocket(transport.PassAs<StreamSocket>()); 394 socket_handle->SetSocket(transport.Pass());
395 395
396 HttpRequestInfo request_info; 396 HttpRequestInfo request_info;
397 request_info.method = "GET"; 397 request_info.method = "GET";
398 if (protocol == HTTP) { 398 if (protocol == HTTP) {
399 request_info.url = GURL("http://localhost"); 399 request_info.url = GURL("http://localhost");
400 } else { 400 } else {
401 request_info.url = GURL("https://localhost"); 401 request_info.url = GURL("https://localhost");
402 } 402 }
403 request_info.load_flags = LOAD_NORMAL; 403 request_info.load_flags = LOAD_NORMAL;
404 404
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 scoped_ptr<DeterministicMockTCPClientSocket> transport( 453 scoped_ptr<DeterministicMockTCPClientSocket> transport(
454 new DeterministicMockTCPClientSocket(NULL, &data)); 454 new DeterministicMockTCPClientSocket(NULL, &data));
455 data.set_delegate(transport->AsWeakPtr()); 455 data.set_delegate(transport->AsWeakPtr());
456 456
457 TestCompletionCallback callback; 457 TestCompletionCallback callback;
458 int rv = transport->Connect(callback.callback()); 458 int rv = transport->Connect(callback.callback());
459 rv = callback.GetResult(rv); 459 rv = callback.GetResult(rv);
460 ASSERT_EQ(OK, rv); 460 ASSERT_EQ(OK, rv);
461 461
462 scoped_ptr<ClientSocketHandle> socket_handle(new ClientSocketHandle); 462 scoped_ptr<ClientSocketHandle> socket_handle(new ClientSocketHandle);
463 socket_handle->SetSocket(transport.PassAs<StreamSocket>()); 463 socket_handle->SetSocket(transport.Pass());
464 464
465 HttpRequestInfo request_info; 465 HttpRequestInfo request_info;
466 request_info.method = "GET"; 466 request_info.method = "GET";
467 request_info.url = GURL("http://localhost"); 467 request_info.url = GURL("http://localhost");
468 request_info.load_flags = LOAD_NORMAL; 468 request_info.load_flags = LOAD_NORMAL;
469 469
470 scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); 470 scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer);
471 HttpStreamParser parser( 471 HttpStreamParser parser(
472 socket_handle.get(), &request_info, read_buffer.get(), BoundNetLog()); 472 socket_handle.get(), &request_info, read_buffer.get(), BoundNetLog());
473 473
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 data_->SetStop(reads_.size() + writes_.size()); 523 data_->SetStop(reads_.size() + writes_.size());
524 524
525 transport_.reset(new DeterministicMockTCPClientSocket(NULL, data_.get())); 525 transport_.reset(new DeterministicMockTCPClientSocket(NULL, data_.get()));
526 data_->set_delegate(transport_->AsWeakPtr()); 526 data_->set_delegate(transport_->AsWeakPtr());
527 527
528 TestCompletionCallback callback; 528 TestCompletionCallback callback;
529 int rv = transport_->Connect(callback.callback()); 529 int rv = transport_->Connect(callback.callback());
530 rv = callback.GetResult(rv); 530 rv = callback.GetResult(rv);
531 ASSERT_EQ(OK, rv); 531 ASSERT_EQ(OK, rv);
532 532
533 socket_handle_->SetSocket(transport_.PassAs<StreamSocket>()); 533 socket_handle_->SetSocket(transport_.Pass());
534 534
535 request_info_.method = "GET"; 535 request_info_.method = "GET";
536 request_info_.url = GURL("http://localhost"); 536 request_info_.url = GURL("http://localhost");
537 request_info_.load_flags = LOAD_NORMAL; 537 request_info_.load_flags = LOAD_NORMAL;
538 538
539 parser_.reset(new HttpStreamParser( 539 parser_.reset(new HttpStreamParser(
540 socket_handle_.get(), &request_info_, read_buffer(), BoundNetLog())); 540 socket_handle_.get(), &request_info_, read_buffer(), BoundNetLog()));
541 541
542 rv = parser_->SendRequest("GET / HTTP/1.1\r\n", request_headers_, 542 rv = parser_->SendRequest("GET / HTTP/1.1\r\n", request_headers_,
543 &response_info_, callback.callback()); 543 &response_info_, callback.callback());
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 arraysize(writes)); 828 arraysize(writes));
829 data.set_connect_data(MockConnect(SYNCHRONOUS, OK)); 829 data.set_connect_data(MockConnect(SYNCHRONOUS, OK));
830 830
831 scoped_ptr<MockTCPClientSocket> transport( 831 scoped_ptr<MockTCPClientSocket> transport(
832 new MockTCPClientSocket(AddressList(), NULL, &data)); 832 new MockTCPClientSocket(AddressList(), NULL, &data));
833 833
834 TestCompletionCallback callback; 834 TestCompletionCallback callback;
835 ASSERT_EQ(OK, transport->Connect(callback.callback())); 835 ASSERT_EQ(OK, transport->Connect(callback.callback()));
836 836
837 scoped_ptr<ClientSocketHandle> socket_handle(new ClientSocketHandle); 837 scoped_ptr<ClientSocketHandle> socket_handle(new ClientSocketHandle);
838 socket_handle->SetSocket(transport.PassAs<StreamSocket>()); 838 socket_handle->SetSocket(transport.Pass());
839 839
840 scoped_ptr<HttpRequestInfo> request_info(new HttpRequestInfo()); 840 scoped_ptr<HttpRequestInfo> request_info(new HttpRequestInfo());
841 request_info->method = "GET"; 841 request_info->method = "GET";
842 request_info->url = GURL("http://somewhere/foo.html"); 842 request_info->url = GURL("http://somewhere/foo.html");
843 843
844 scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); 844 scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer);
845 HttpStreamParser parser(socket_handle.get(), request_info.get(), 845 HttpStreamParser parser(socket_handle.get(), request_info.get(),
846 read_buffer.get(), BoundNetLog()); 846 read_buffer.get(), BoundNetLog());
847 847
848 scoped_ptr<HttpRequestHeaders> request_headers(new HttpRequestHeaders()); 848 scoped_ptr<HttpRequestHeaders> request_headers(new HttpRequestHeaders());
849 scoped_ptr<HttpResponseInfo> response_info(new HttpResponseInfo()); 849 scoped_ptr<HttpResponseInfo> response_info(new HttpResponseInfo());
850 ASSERT_EQ(OK, parser.SendRequest("GET /foo.html HTTP/1.1\r\n", 850 ASSERT_EQ(OK, parser.SendRequest("GET /foo.html HTTP/1.1\r\n",
851 *request_headers, response_info.get(), callback.callback())); 851 *request_headers, response_info.get(), callback.callback()));
852 ASSERT_EQ(OK, parser.ReadResponseHeaders(callback.callback())); 852 ASSERT_EQ(OK, parser.ReadResponseHeaders(callback.callback()));
853 853
854 // If the object that owns the HttpStreamParser is deleted, it takes the 854 // If the object that owns the HttpStreamParser is deleted, it takes the
855 // objects passed to the HttpStreamParser with it. 855 // objects passed to the HttpStreamParser with it.
856 request_info.reset(); 856 request_info.reset();
857 request_headers.reset(); 857 request_headers.reset();
858 response_info.reset(); 858 response_info.reset();
859 859
860 scoped_refptr<IOBuffer> body_buffer(new IOBuffer(kBodySize)); 860 scoped_refptr<IOBuffer> body_buffer(new IOBuffer(kBodySize));
861 ASSERT_EQ(kBodySize, parser.ReadResponseBody( 861 ASSERT_EQ(kBodySize, parser.ReadResponseBody(
862 body_buffer.get(), kBodySize, callback.callback())); 862 body_buffer.get(), kBodySize, callback.callback()));
863 } 863 }
864 864
865 } // namespace 865 } // namespace
866 866
867 } // namespace net 867 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl_unittest.cc ('k') | net/ocsp/nss_ocsp_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698