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

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

Issue 15829004: Update net/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: license twerk Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_stream_parser_unittest.cc ('k') | net/http/http_vary_data_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_transaction_unittest.h" 5 #include "net/http/http_transaction_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 void TestTransactionConsumer::DidFinish(int result) { 196 void TestTransactionConsumer::DidFinish(int result) {
197 state_ = DONE; 197 state_ = DONE;
198 error_ = result; 198 error_ = result;
199 if (--quit_counter_ == 0) 199 if (--quit_counter_ == 0)
200 base::MessageLoop::current()->Quit(); 200 base::MessageLoop::current()->Quit();
201 } 201 }
202 202
203 void TestTransactionConsumer::Read() { 203 void TestTransactionConsumer::Read() {
204 state_ = READING; 204 state_ = READING;
205 read_buf_ = new net::IOBuffer(1024); 205 read_buf_ = new net::IOBuffer(1024);
206 int result = trans_->Read(read_buf_, 1024, 206 int result = trans_->Read(read_buf_.get(),
207 1024,
207 base::Bind(&TestTransactionConsumer::OnIOComplete, 208 base::Bind(&TestTransactionConsumer::OnIOComplete,
208 base::Unretained(this))); 209 base::Unretained(this)));
209 if (result != net::ERR_IO_PENDING) 210 if (result != net::ERR_IO_PENDING)
210 DidRead(result); 211 DidRead(result);
211 } 212 }
212 213
213 void TestTransactionConsumer::OnIOComplete(int result) { 214 void TestTransactionConsumer::OnIOComplete(int result) {
214 switch (state_) { 215 switch (state_) {
215 case STARTING: 216 case STARTING:
216 DidStart(result); 217 DidStart(result);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 response_.request_time = t->request_time; 268 response_.request_time = t->request_time;
268 269
269 response_.was_cached = false; 270 response_.was_cached = false;
270 response_.network_accessed = true; 271 response_.network_accessed = true;
271 272
272 response_.response_time = base::Time::Now(); 273 response_.response_time = base::Time::Now();
273 if (!t->response_time.is_null()) 274 if (!t->response_time.is_null())
274 response_.response_time = t->response_time; 275 response_.response_time = t->response_time;
275 276
276 response_.headers = new net::HttpResponseHeaders(header_data); 277 response_.headers = new net::HttpResponseHeaders(header_data);
277 response_.vary_data.Init(*request, *response_.headers); 278 response_.vary_data.Init(*request, *response_.headers.get());
278 response_.ssl_info.cert_status = t->cert_status; 279 response_.ssl_info.cert_status = t->cert_status;
279 data_ = resp_data; 280 data_ = resp_data;
280 281
281 if (net_log.net_log()) 282 if (net_log.net_log())
282 socket_log_id_ = net_log.net_log()->NextID(); 283 socket_log_id_ = net_log.net_log()->NextID();
283 284
284 if (test_mode_ & TEST_MODE_SYNC_NET_START) 285 if (test_mode_ & TEST_MODE_SYNC_NET_START)
285 return net::OK; 286 return net::OK;
286 287
287 CallbackLater(callback, net::OK); 288 CallbackLater(callback, net::OK);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 // helpers 420 // helpers
420 421
421 int ReadTransaction(net::HttpTransaction* trans, std::string* result) { 422 int ReadTransaction(net::HttpTransaction* trans, std::string* result) {
422 int rv; 423 int rv;
423 424
424 net::TestCompletionCallback callback; 425 net::TestCompletionCallback callback;
425 426
426 std::string content; 427 std::string content;
427 do { 428 do {
428 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); 429 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256));
429 rv = trans->Read(buf, 256, callback.callback()); 430 rv = trans->Read(buf.get(), 256, callback.callback());
430 if (rv == net::ERR_IO_PENDING) 431 if (rv == net::ERR_IO_PENDING)
431 rv = callback.WaitForResult(); 432 rv = callback.WaitForResult();
432 433
433 if (rv > 0) 434 if (rv > 0)
434 content.append(buf->data(), rv); 435 content.append(buf->data(), rv);
435 else if (rv < 0) 436 else if (rv < 0)
436 return rv; 437 return rv;
437 } while (rv > 0); 438 } while (rv > 0);
438 439
439 result->swap(content); 440 result->swap(content);
440 return net::OK; 441 return net::OK;
441 } 442 }
OLDNEW
« no previous file with comments | « net/http/http_stream_parser_unittest.cc ('k') | net/http/http_vary_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698