1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/url_request/url_request_status.h"
7 #include "base/logging.h"
8 #include "net/base/net_errors.h"
12 URLRequestStatus::URLRequestStatus(Status status
, int error
)
13 : status_(status
), error_(error
) {
14 // URLRequestStatus should get folded into error. However, it is possible to
15 // create URLRequestStatuses with inconsistent |status_| and |error_|
16 // fields. As callers are cleaned up, these assertions avoid regressing any
17 // invariants that have been established.
19 // https://crbug.com/490311
23 DCHECK_EQ(OK
, error_
);
26 // TODO(davidben): Switch all IO_PENDING status to ERR_IO_PENDING.
27 DCHECK(error_
== 0 || error_
== ERR_IO_PENDING
);
31 DCHECK_NE(OK
, error_
);
32 DCHECK_NE(ERR_IO_PENDING
, error_
);
37 URLRequestStatus
URLRequestStatus::FromError(int error
) {
39 return URLRequestStatus(SUCCESS
, OK
);
40 } else if (error
== ERR_IO_PENDING
) {
41 return URLRequestStatus(IO_PENDING
, ERR_IO_PENDING
);
42 } else if (error
== ERR_ABORTED
) {
43 return URLRequestStatus(CANCELED
, ERR_ABORTED
);
45 return URLRequestStatus(FAILED
, error
);