OLD | NEW |
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 "chrome/browser/devtools/devtools_network_controller.h" | 5 #include "chrome/browser/devtools/devtools_network_controller.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 request_.reset(new MockHttpRequest(mock_transaction_)); | 87 request_.reset(new MockHttpRequest(mock_transaction_)); |
88 | 88 |
89 if (with_upload) { | 89 if (with_upload) { |
90 upload_data_stream_.reset( | 90 upload_data_stream_.reset( |
91 new net::ChunkedUploadDataStream(kUploadIdentifier)); | 91 new net::ChunkedUploadDataStream(kUploadIdentifier)); |
92 upload_data_stream_->AppendData( | 92 upload_data_stream_->AppendData( |
93 kUploadData, arraysize(kUploadData), true); | 93 kUploadData, arraysize(kUploadData), true); |
94 request_->upload_data_stream = upload_data_stream_.get(); | 94 request_->upload_data_stream = upload_data_stream_.get(); |
95 } | 95 } |
96 | 96 |
97 int rv = transaction_->Start( | 97 int rv = transaction_->Start(request_.get(), completion_callback_, |
98 request_.get(), completion_callback_, net::BoundNetLog()); | 98 net::NetLogWithSource()); |
99 EXPECT_EQ(with_upload, !!transaction_->custom_upload_data_stream_); | 99 EXPECT_EQ(with_upload, !!transaction_->custom_upload_data_stream_); |
100 return rv; | 100 return rv; |
101 } | 101 } |
102 | 102 |
103 int Read() { | 103 int Read() { |
104 return transaction_->Read(buffer_.get(), 64, completion_callback_); | 104 return transaction_->Read(buffer_.get(), 64, completion_callback_); |
105 } | 105 } |
106 | 106 |
107 bool ShouldFail() { | 107 bool ShouldFail() { |
108 if (transaction_->interceptor_) | 108 if (transaction_->interceptor_) |
(...skipping 11 matching lines...) Expand all Loading... |
120 bool HasFailed() { | 120 bool HasFailed() { |
121 return transaction_->failed_; | 121 return transaction_->failed_; |
122 } | 122 } |
123 | 123 |
124 void CancelTransaction() { | 124 void CancelTransaction() { |
125 transaction_.reset(); | 125 transaction_.reset(); |
126 } | 126 } |
127 | 127 |
128 int ReadUploadData() { | 128 int ReadUploadData() { |
129 EXPECT_EQ(net::OK, transaction_->custom_upload_data_stream_->Init( | 129 EXPECT_EQ(net::OK, transaction_->custom_upload_data_stream_->Init( |
130 completion_callback_, net::BoundNetLog())); | 130 completion_callback_, net::NetLogWithSource())); |
131 return transaction_->custom_upload_data_stream_->Read( | 131 return transaction_->custom_upload_data_stream_->Read( |
132 buffer_.get(), 64, completion_callback_); | 132 buffer_.get(), 64, completion_callback_); |
133 } | 133 } |
134 | 134 |
135 ~DevToolsNetworkControllerHelper() { | 135 ~DevToolsNetworkControllerHelper() { |
136 RemoveMockTransaction(&mock_transaction_); | 136 RemoveMockTransaction(&mock_transaction_); |
137 } | 137 } |
138 | 138 |
139 TestCallback* callback() { return &callback_; } | 139 TestCallback* callback() { return &callback_; } |
140 DevToolsNetworkController* controller() { return &controller_; } | 140 DevToolsNetworkController* controller() { return &controller_; } |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 319 |
320 rv = helper.ReadUploadData(); | 320 rv = helper.ReadUploadData(); |
321 EXPECT_EQ(rv, net::ERR_IO_PENDING); | 321 EXPECT_EQ(rv, net::ERR_IO_PENDING); |
322 EXPECT_EQ(callback->run_count(), 1); | 322 EXPECT_EQ(callback->run_count(), 1); |
323 base::RunLoop().RunUntilIdle(); | 323 base::RunLoop().RunUntilIdle(); |
324 EXPECT_EQ(callback->run_count(), 2); | 324 EXPECT_EQ(callback->run_count(), 2); |
325 EXPECT_EQ(callback->value(), static_cast<int>(arraysize(kUploadData))); | 325 EXPECT_EQ(callback->value(), static_cast<int>(arraysize(kUploadData))); |
326 } | 326 } |
327 | 327 |
328 } // namespace test | 328 } // namespace test |
OLD | NEW |