Index: net/url_request/url_request_status.cc |
diff --git a/net/url_request/url_request_status.cc b/net/url_request/url_request_status.cc |
index c4643f260b8605827df9661379cbdc2967261926..2a6a2fae861c202a51fc677558a7f3584c286373 100644 |
--- a/net/url_request/url_request_status.cc |
+++ b/net/url_request/url_request_status.cc |
@@ -4,10 +4,36 @@ |
#include "net/url_request/url_request_status.h" |
+#include "base/logging.h" |
#include "net/base/net_errors.h" |
namespace net { |
+URLRequestStatus::URLRequestStatus(Status status, int error) |
+ : status_(status), error_(error) { |
+ // URLRequestStatus should get folded into error. However, it is possible to |
+ // create URLRequestStatuses with inconsistent |status_| and |error_| |
+ // fields. As callers are cleaned up, these assertions avoid regressing any |
+ // invariants that have been established. |
+ // |
+ // https://crbug.com/490311 |
+ DCHECK_GE(0, error_); |
+ switch (status_) { |
+ case SUCCESS: |
+ DCHECK_EQ(OK, error_); |
+ break; |
+ case IO_PENDING: |
+ // TODO(davidben): Switch all IO_PENDING status to ERR_IO_PENDING. |
+ DCHECK(error_ == 0 || error_ == ERR_IO_PENDING); |
+ break; |
+ case CANCELED: |
+ case FAILED: |
+ DCHECK_NE(OK, error_); |
+ DCHECK_NE(ERR_IO_PENDING, error_); |
+ break; |
+ } |
+} |
+ |
URLRequestStatus URLRequestStatus::FromError(int error) { |
if (error == OK) { |
return URLRequestStatus(SUCCESS, OK); |