Fix obscure bug with URLRequestHttpJob cancellation.

If URLRequestHttpJob::StartTransactionInternal failed
synchronously, transctaion_ would be NULL and a task to pass
the error to URLRequestHttpJob::OnStartCompleted would be posted.
If the request is cancelled before this task is run, then the
cancellation would write URLRequestStatus and then call
URLRequestHttpJob::Kill, which would do nothing, since the
transaction_ was NULL.  OnStartCompleted would then be run,
overwrite the cancelled status with an error, and then treat
it as a failure.

While not a major bug, overwriting the cancelled status with
the error is weird, and breaks a CHECK aimed at catching real
crashers.

BUG=508900

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

Cr-Commit-Position: refs/heads/master@{#357421}
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 7ff74d2..b34f825 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -278,11 +278,9 @@
 }
 
 void URLRequestHttpJob::Kill() {
-  if (!transaction_.get())
-    return;
-
   weak_factory_.InvalidateWeakPtrs();
-  DestroyTransaction();
+  if (transaction_)
+    DestroyTransaction();
   URLRequestJob::Kill();
 }
 
@@ -483,8 +481,7 @@
 
 void URLRequestHttpJob::StartTransactionInternal() {
   // This should only be called while the request's status is IO_PENDING.
-  // TODO(mmenke):  Switch to DCHECK once https://crbug.com/508900 is fixed.
-  CHECK_EQ(URLRequestStatus::IO_PENDING, request_->status().status());
+  DCHECK_EQ(URLRequestStatus::IO_PENDING, request_->status().status());
 
   // NOTE: This method assumes that request_info_ is already setup properly.
 
@@ -541,13 +538,6 @@
   if (rv == ERR_IO_PENDING)
     return;
 
-  // The transaction should not have been deleted, and the request status should
-  // still be IO_PENDING at this point.
-  // TODO(mmenke):  Remove once https://crbug.com/508900 is fixed.
-  if (rv == OK)
-    CHECK(transaction_);
-  CHECK_EQ(URLRequestStatus::IO_PENDING, request_->status().status());
-
   // The transaction started synchronously, but we need to notify the
   // URLRequest delegate via the message loop.
   base::ThreadTaskRunnerHandle::Get()->PostTask(