Index: net/http/http_stream_factory_test_util.cc |
diff --git a/net/http/http_stream_factory_test_util.cc b/net/http/http_stream_factory_test_util.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4d0e78aca323d31b1d11cc569ba23994433bd226 |
--- /dev/null |
+++ b/net/http/http_stream_factory_test_util.cc |
@@ -0,0 +1,33 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "net/http/http_stream_factory_test_util.h" |
+ |
+#include "base/message_loop/message_loop.h" |
+ |
+namespace net { |
+ |
+MockHttpStreamFactoryImplForPreconnect::MockHttpStreamFactoryImplForPreconnect( |
+ HttpNetworkSession* session, |
+ bool for_websockets) |
+ : HttpStreamFactoryImpl(session, for_websockets), |
+ preconnect_done_(false), |
+ waiting_for_preconnect_(false) { |
+} |
+ |
+void MockHttpStreamFactoryImplForPreconnect::WaitForPreconnects() { |
+ while (!preconnect_done_) { |
+ waiting_for_preconnect_ = true; |
+ base::MessageLoop::current()->Run(); |
mmenke
2014/03/14 16:38:06
optional: Maybe switch to using a RunLoop, while
davidben
2014/03/14 18:35:03
Done.
|
+ waiting_for_preconnect_ = false; |
+ } |
+} |
+ |
+void MockHttpStreamFactoryImplForPreconnect::OnPreconnectsCompleteInternal() { |
+ preconnect_done_ = true; |
+ if (waiting_for_preconnect_) |
+ base::MessageLoop::current()->Quit(); |
+} |
+ |
+} // namespace net |