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

Unified Diff: net/http/http_stream_factory_test_util.cc

Issue 1941083002: JobController 1: Adding a new class HttpStreamFactoryImpl::JobController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge unittests to this CL Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
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..e58e8793cd856ae509ed0f75d3df2b05fad4fc7b
--- /dev/null
+++ b/net/http/http_stream_factory_test_util.cc
@@ -0,0 +1,125 @@
+// Copyright (c) 2016 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 "net/proxy/proxy_info.h"
+
+namespace net {
+TestHttpStreamRequestDelegate::TestHttpStreamRequestDelegate() {}
+
+TestHttpStreamRequestDelegate::~TestHttpStreamRequestDelegate() {}
+
+TestHttpStreamFactoryImplJob::TestHttpStreamFactoryImplJob(
+ HttpStreamFactoryImpl::Job::Delegate* delegate,
+ HttpStreamFactoryImpl::JobType job_type,
+ HttpNetworkSession* session,
+ const HttpRequestInfo& request_info,
+ RequestPriority priority,
+ const SSLConfig& server_ssl_config,
+ const SSLConfig& proxy_ssl_config,
+ HostPortPair destination,
+ GURL origin_url,
+ NetLog* net_log)
+ : HttpStreamFactoryImpl::Job(delegate,
+ job_type,
+ session,
+ request_info,
+ priority,
+ server_ssl_config,
+ proxy_ssl_config,
+ destination,
+ origin_url,
+ net_log) {}
+
+TestHttpStreamFactoryImplJob::TestHttpStreamFactoryImplJob(
+ HttpStreamFactoryImpl::Job::Delegate* delegate,
+ HttpStreamFactoryImpl::JobType job_type,
+ HttpNetworkSession* session,
+ const HttpRequestInfo& request_info,
+ RequestPriority priority,
+ const SSLConfig& server_ssl_config,
+ const SSLConfig& proxy_ssl_config,
+ HostPortPair destination,
+ GURL origin_url,
+ AlternativeService alternative_service,
+ NetLog* net_log)
+ : HttpStreamFactoryImpl::Job(delegate,
+ job_type,
+ session,
+ request_info,
+ priority,
+ server_ssl_config,
+ proxy_ssl_config,
+ destination,
+ origin_url,
+ alternative_service,
+ net_log) {}
+
+TestHttpStreamFactoryImplJob::~TestHttpStreamFactoryImplJob() {}
+
+TestJobControllerPeer::TestJobControllerPeer(
+ NextProto protocol,
+ TestHttpStreamRequestDelegate* request_delegate)
+ : session_deps_(protocol, ProxyService::CreateDirect()),
+ request_delegate_(request_delegate),
+ main_job_(nullptr),
+ alternative_job_(nullptr) {
+ session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_);
+ factory_ =
+ static_cast<HttpStreamFactoryImpl*>(session_->http_stream_factory());
+ job_controller_ = new HttpStreamFactoryImpl::JobController(
+ factory_, request_delegate_, session_.get());
+ factory_->job_controller_set_.insert(base::WrapUnique(job_controller_));
+}
+
+TestJobControllerPeer::~TestJobControllerPeer() {}
+
+void TestJobControllerPeer::CreateRequest(HttpRequestInfo request_info) {
+ request_.reset(new HttpStreamFactoryImpl::Request(
+ request_info.url, job_controller_, request_delegate_, nullptr,
+ BoundNetLog(), HttpStreamFactoryImpl::Request::HTTP_STREAM));
+ job_controller_->request_ = request_.get();
+}
+
+GURL TestJobControllerPeer::ApplyHostMappingRules(const GURL& url,
+ HostPortPair* endpoint) {
+ return job_controller_->ApplyHostMappingRules(url, endpoint);
+}
+
+void TestJobControllerPeer::ClearMainJob() {
+ factory_->request_map_.erase(job_controller_->main_job_.get());
+ job_controller_->main_job_.reset();
+}
+
+void TestJobControllerPeer::SetMainJob(HttpStreamFactoryImpl::Job* main_job) {
+ job_controller_->main_job_.reset(main_job);
+ job_controller_->AttachJob(main_job);
+}
+
+void TestJobControllerPeer::SetAlternativeJob(
+ HttpStreamFactoryImpl::Job* alternative_job) {
+ job_controller_->alternative_job_.reset(alternative_job);
+ job_controller_->AttachJob(alternative_job);
+}
+
+void TestJobControllerPeer::OnStreamFailed(HttpStreamFactoryImpl::Job* job,
+ int status,
+ const SSLConfig& used_ssl_config,
+ SSLFailureState ssl_failure_state) {
+ job_controller_->OnStreamFailed(job, status, used_ssl_config,
+ ssl_failure_state);
+}
+
+void TestJobControllerPeer::OnStreamReady(HttpStreamFactoryImpl::Job* job,
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info) {
+ job_controller_->OnStreamReady(job, used_ssl_config, used_proxy_info);
+}
+
+void TestJobControllerPeer::MaybeNotifyFactoryOfCompletion() {
+ job_controller_->MaybeNotifyFactoryOfCompletion();
+}
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698