Didn't check if the transaction was actually created before using it,
which caused a crash.

The revision associated with the cl: 243568
The cl that caused the issue: cl/122453002

BUG=333132

Review URL: https://codereview.chromium.org/133663003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244174 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index e77a03b1..d483f0c 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -414,9 +414,6 @@
     rv = request_->context()->http_transaction_factory()->CreateTransaction(
         priority_, &transaction_);
 
-    transaction_->SetBeforeNetworkStartCallback(base::Bind(
-        &URLRequestHttpJob::NotifyBeforeNetworkStart, base::Unretained(this)));
-
     if (rv == OK && request_info_.url.SchemeIsWSOrWSS()) {
       // TODO(ricea): Implement WebSocket throttling semantics as defined in
       // RFC6455 Section 4.1.
@@ -431,6 +428,10 @@
     }
 
     if (rv == OK) {
+      transaction_->SetBeforeNetworkStartCallback(
+          base::Bind(&URLRequestHttpJob::NotifyBeforeNetworkStart,
+                     base::Unretained(this)));
+
       if (!throttling_entry_.get() ||
           !throttling_entry_->ShouldRejectRequest(*request_)) {
         rv = transaction_->Start(