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

Side by Side Diff: blimp/net/blimp_message_output_buffer_unittest.cc

Issue 1909143002: Use ConnectionErrorObserver, not callbacks, for error handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "blimp/net/blimp_message_output_buffer.h" 5 #include "blimp/net/blimp_message_output_buffer.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 net::TestCompletionCallback complete_cb_2; 178 net::TestCompletionCallback complete_cb_2;
179 179
180 AddOutputExpectation(input_msg_); 180 AddOutputExpectation(input_msg_);
181 AddOutputExpectation(input_msg_); 181 AddOutputExpectation(input_msg_);
182 182
183 // Accumulate two messages. 183 // Accumulate two messages.
184 buffer_->ProcessMessage(base::WrapUnique(new BlimpMessage(input_msg_)), 184 buffer_->ProcessMessage(base::WrapUnique(new BlimpMessage(input_msg_)),
185 complete_cb_1.callback()); 185 complete_cb_1.callback());
186 ASSERT_EQ(1, buffer_->GetBufferByteSizeForTest()); 186 ASSERT_EQ(1, buffer_->GetBufferByteSizeForTest());
187 187
188 // First write attempt, which fails. 188 // First write attempt, which fails. The output buffer isn't notified of the
189 // connection loss, because the write callback is silently dropped.
189 ASSERT_TRUE(captured_cb_.is_null()); 190 ASSERT_TRUE(captured_cb_.is_null());
190 buffer_->SetOutputProcessor(&output_processor_); 191 buffer_->SetOutputProcessor(&output_processor_);
191 ASSERT_FALSE(captured_cb_.is_null()); 192 ASSERT_FALSE(captured_cb_.is_null());
192 base::ResetAndReturn(&captured_cb_).Run(net::ERR_FAILED);
193 ASSERT_EQ(1, buffer_->GetBufferByteSizeForTest()); 193 ASSERT_EQ(1, buffer_->GetBufferByteSizeForTest());
194 ASSERT_EQ(0, buffer_->GetUnacknowledgedMessageCountForTest()); 194 ASSERT_EQ(0, buffer_->GetUnacknowledgedMessageCountForTest());
195 195
196 // Simulate disconnect. 196 // Simulate disconnect.
197 buffer_->SetOutputProcessor(nullptr); 197 buffer_->SetOutputProcessor(nullptr);
198 198
199 // Reconnect. Should immediately try to write the contents of the buffer. 199 // Reconnect. Should immediately try to write the contents of the buffer.
200 buffer_->SetOutputProcessor(&output_processor_); 200 buffer_->SetOutputProcessor(&output_processor_);
201 ASSERT_FALSE(captured_cb_.is_null()); 201 ASSERT_FALSE(captured_cb_.is_null());
202 base::ResetAndReturn(&captured_cb_).Run(net::OK); 202 base::ResetAndReturn(&captured_cb_).Run(net::OK);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 254
255 // Remote end acknowledges #1, buffer should be empty. 255 // Remote end acknowledges #1, buffer should be empty.
256 buffer_->OnMessageCheckpoint(2); 256 buffer_->OnMessageCheckpoint(2);
257 ASSERT_EQ(0, buffer_->GetBufferByteSizeForTest()); 257 ASSERT_EQ(0, buffer_->GetBufferByteSizeForTest());
258 ASSERT_EQ(0, buffer_->GetUnacknowledgedMessageCountForTest()); 258 ASSERT_EQ(0, buffer_->GetUnacknowledgedMessageCountForTest());
259 EXPECT_EQ(net::OK, complete_cb_2.WaitForResult()); 259 EXPECT_EQ(net::OK, complete_cb_2.WaitForResult());
260 } 260 }
261 261
262 } // namespace 262 } // namespace
263 } // namespace blimp 263 } // namespace blimp
OLDNEW
« blimp/net/blimp_message_output_buffer.cc ('K') | « blimp/net/blimp_message_output_buffer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698