Remove linux_chromium_gn_dbg from the chromium CQ.
[chromium-blink-merge.git] / net / url_request / url_request_status.h
blob44a5d22bf04cdbfe736f08f80e42c22a1111acbe
1 // Copyright (c) 2011 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 #ifndef NET_URL_REQUEST_URL_REQUEST_STATUS_H_
6 #define NET_URL_REQUEST_URL_REQUEST_STATUS_H_
8 #include "net/base/net_export.h"
10 namespace net {
12 // Represents the result of a URL request. It encodes errors and various
13 // types of success.
14 class NET_EXPORT URLRequestStatus {
15 public:
16 enum Status {
17 // Request succeeded, |error_| will be 0.
18 SUCCESS = 0,
20 // An IO request is pending, and the caller will be informed when it is
21 // completed.
22 IO_PENDING,
24 // Request was cancelled programatically.
25 CANCELED,
27 // The request failed for some reason. |error_| may have more information.
28 FAILED,
31 // Creates a successful URLRequestStatus.
32 URLRequestStatus() : status_(SUCCESS), error_(0) {}
34 // Creates a URLRequestStatus with specified status and error parameters. New
35 // consumers should use URLRequestStatus::FromError instead.
36 URLRequestStatus(Status status, int error);
38 // Creates a URLRequestStatus, initializing the status from |error|. OK maps
39 // to SUCCESS, ERR_IO_PENDING maps to IO_PENDING, ERR_ABORTED maps to CANCELED
40 // and all others map to FAILED. Other combinations of status and error are
41 // deprecated. See https://crbug.com/490311.
42 static URLRequestStatus FromError(int error);
44 Status status() const { return status_; }
45 int error() const { return error_; }
47 // Returns true if the status is success, which makes some calling code more
48 // convenient because this is the most common test.
49 bool is_success() const {
50 return status_ == SUCCESS || status_ == IO_PENDING;
53 // Returns true if the request is waiting for IO.
54 bool is_io_pending() const {
55 return status_ == IO_PENDING;
58 private:
59 // Application level status.
60 Status status_;
62 // Error code from the network layer if an error was encountered.
63 int error_;
66 } // namespace net
68 #endif // NET_URL_REQUEST_URL_REQUEST_STATUS_H_