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

Side by Side Diff: net/test/url_request/mock_url_request_delegate.cc

Issue 2788583006: Delete content::MockURLRequestDelegate. (Closed)
Patch Set: Created 3 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/fileapi/mock_url_request_delegate.h" 5 #include "net/test/url_request/mock_url_request_delegate.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace { 13 namespace {
14 const int kBufferSize = 1024; 14 const int kBufferSize = 1024;
15 } 15 }
16 16
17 namespace content { 17 namespace content {
18 18
19 MockURLRequestDelegate::MockURLRequestDelegate() 19 MockURLRequestDelegate::MockURLRequestDelegate()
20 : io_buffer_(new net::IOBuffer(kBufferSize)), 20 : io_buffer_(new net::IOBuffer(kBufferSize)),
21 request_status_(net::ERR_IO_PENDING) {} 21 request_status_(net::ERR_IO_PENDING) {}
22 22
23 MockURLRequestDelegate::~MockURLRequestDelegate() { 23 MockURLRequestDelegate::~MockURLRequestDelegate() {}
24 }
25 24
26 void MockURLRequestDelegate::OnResponseStarted(net::URLRequest* request, 25 void MockURLRequestDelegate::OnResponseStarted(net::URLRequest* request,
27 int net_error) { 26 int net_error) {
28 DCHECK_NE(net::ERR_IO_PENDING, net_error); 27 DCHECK_NE(net::ERR_IO_PENDING, net_error);
29 28
30 request_status_ = net_error; 29 request_status_ = net_error;
31 30
32 if (net_error == net::OK) { 31 if (net_error == net::OK) {
33 EXPECT_TRUE(request->response_headers()); 32 EXPECT_TRUE(request->response_headers());
34 metadata_ = request->response_info().metadata; 33 metadata_ = request->response_info().metadata;
(...skipping 29 matching lines...) Expand all
64 RequestComplete(); 63 RequestComplete();
65 return; 64 return;
66 } 65 }
67 66
68 ReceiveData(request, bytes_read); 67 ReceiveData(request, bytes_read);
69 } 68 }
70 69
71 void MockURLRequestDelegate::ReceiveData(net::URLRequest* request, 70 void MockURLRequestDelegate::ReceiveData(net::URLRequest* request,
72 int bytes_read) { 71 int bytes_read) {
73 if (bytes_read > 0) { 72 if (bytes_read > 0) {
74 response_data_.append(io_buffer_->data(), 73 response_data_.append(io_buffer_->data(), static_cast<size_t>(bytes_read));
75 static_cast<size_t>(bytes_read));
76 ReadSome(request); 74 ReadSome(request);
77 } else { 75 } else {
78 RequestComplete(); 76 RequestComplete();
79 } 77 }
80 } 78 }
81 79
82 void MockURLRequestDelegate::RequestComplete() { 80 void MockURLRequestDelegate::RequestComplete() {
83 base::MessageLoop::current()->QuitWhenIdle(); 81 base::MessageLoop::current()->QuitWhenIdle();
84 } 82 }
85 83
86 } // namespace 84 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698