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

Side by Side Diff: net/server/http_server_unittest.cc

Issue 509563003: Remove implicit conversions from scoped_refptr to T* in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « net/filter/sdch_filter.cc ('k') | net/socket_stream/socket_stream.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 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 <algorithm> 5 #include <algorithm>
6 #include <utility> 6 #include <utility>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 void OnWrite(int result) { 141 void OnWrite(int result) {
142 ASSERT_GT(result, 0); 142 ASSERT_GT(result, 0);
143 write_buffer_->DidConsume(result); 143 write_buffer_->DidConsume(result);
144 if (write_buffer_->BytesRemaining()) 144 if (write_buffer_->BytesRemaining())
145 Write(); 145 Write();
146 } 146 }
147 147
148 void ReadInternal(const net::CompletionCallback& callback) { 148 void ReadInternal(const net::CompletionCallback& callback) {
149 read_buffer_ = new IOBufferWithSize(kMaxExpectedResponseLength); 149 read_buffer_ = new IOBufferWithSize(kMaxExpectedResponseLength);
150 int result = socket_->Read(read_buffer_, 150 int result =
151 kMaxExpectedResponseLength, 151 socket_->Read(read_buffer_.get(), kMaxExpectedResponseLength, callback);
152 callback);
153 if (result != ERR_IO_PENDING) 152 if (result != ERR_IO_PENDING)
154 callback.Run(result); 153 callback.Run(result);
155 } 154 }
156 155
157 bool IsCompleteResponse(const std::string& response) { 156 bool IsCompleteResponse(const std::string& response) {
158 // Check end of headers first. 157 // Check end of headers first.
159 int end_of_headers = HttpUtil::LocateEndOfHeaders(response.data(), 158 int end_of_headers = HttpUtil::LocateEndOfHeaders(response.data(),
160 response.size()); 159 response.size());
161 if (end_of_headers < 0) 160 if (end_of_headers < 0)
162 return false; 161 return false;
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 return ERR_NOT_IMPLEMENTED; 525 return ERR_NOT_IMPLEMENTED;
527 } 526 }
528 virtual int SetReceiveBufferSize(int32 size) OVERRIDE { 527 virtual int SetReceiveBufferSize(int32 size) OVERRIDE {
529 return ERR_NOT_IMPLEMENTED; 528 return ERR_NOT_IMPLEMENTED;
530 } 529 }
531 virtual int SetSendBufferSize(int32 size) OVERRIDE { 530 virtual int SetSendBufferSize(int32 size) OVERRIDE {
532 return ERR_NOT_IMPLEMENTED; 531 return ERR_NOT_IMPLEMENTED;
533 } 532 }
534 533
535 void DidRead(const char* data, int data_len) { 534 void DidRead(const char* data, int data_len) {
536 if (!read_buf_) { 535 if (!read_buf_.get()) {
537 pending_read_data_.append(data, data_len); 536 pending_read_data_.append(data, data_len);
538 return; 537 return;
539 } 538 }
540 int read_len = std::min(data_len, read_buf_len_); 539 int read_len = std::min(data_len, read_buf_len_);
541 memcpy(read_buf_->data(), data, read_len); 540 memcpy(read_buf_->data(), data, read_len);
542 pending_read_data_.assign(data + read_len, data_len - read_len); 541 pending_read_data_.assign(data + read_len, data_len - read_len);
543 read_buf_ = NULL; 542 read_buf_ = NULL;
544 read_buf_len_ = 0; 543 read_buf_len_ = 0;
545 base::ResetAndReturn(&read_callback_).Run(read_len); 544 base::ResetAndReturn(&read_callback_).Run(read_len);
546 } 545 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 613
615 ASSERT_EQ(client_connection_id, GetConnectionId(2)); 614 ASSERT_EQ(client_connection_id, GetConnectionId(2));
616 server_->Send200(client_connection_id, "Content for /test3", "text/plain"); 615 server_->Send200(client_connection_id, "Content for /test3", "text/plain");
617 std::string response3; 616 std::string response3;
618 ASSERT_TRUE(client.ReadResponse(&response3)); 617 ASSERT_TRUE(client.ReadResponse(&response3));
619 ASSERT_TRUE(StartsWithASCII(response3, "HTTP/1.1 200 OK", true)); 618 ASSERT_TRUE(StartsWithASCII(response3, "HTTP/1.1 200 OK", true));
620 ASSERT_TRUE(EndsWith(response3, "Content for /test3", true)); 619 ASSERT_TRUE(EndsWith(response3, "Content for /test3", true));
621 } 620 }
622 621
623 } // namespace net 622 } // namespace net
OLDNEW
« no previous file with comments | « net/filter/sdch_filter.cc ('k') | net/socket_stream/socket_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698