Disable NaClBrowserTestPnacl.Crash on Linux due to flakiness
[chromium-blink-merge.git] / net / url_request / url_request_status.h
blob521a3d45f5fa94b043e9c4a12ac7a5bce99386f2
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.
4 //
5 // This file's dependencies should be kept to a minimum so that it can be
6 // included in WebKit code that doesn't rely on much of common.
8 #ifndef NET_URL_REQUEST_URL_REQUEST_STATUS_H_
9 #define NET_URL_REQUEST_URL_REQUEST_STATUS_H_
11 namespace net {
13 // Represents the result of a URL request. It encodes errors and various
14 // types of success.
15 class URLRequestStatus {
16 public:
17 enum Status {
18 // Request succeeded, |error_| will be 0.
19 SUCCESS = 0,
21 // An IO request is pending, and the caller will be informed when it is
22 // completed.
23 IO_PENDING,
25 // Request was cancelled programatically.
26 CANCELED,
28 // The request failed for some reason. |error_| may have more information.
29 FAILED,
32 URLRequestStatus() : status_(SUCCESS), error_(0) {}
33 URLRequestStatus(Status s, int e) : status_(s), error_(e) {}
35 Status status() const { return status_; }
36 void set_status(Status s) { status_ = s; }
38 int error() const { return error_; }
39 void set_error(int e) { error_ = e; }
41 // Returns true if the status is success, which makes some calling code more
42 // convenient because this is the most common test.
43 bool is_success() const {
44 return status_ == SUCCESS || status_ == IO_PENDING;
47 // Returns true if the request is waiting for IO.
48 bool is_io_pending() const {
49 return status_ == IO_PENDING;
52 private:
53 // Application level status.
54 Status status_;
56 // Error code from the network layer if an error was encountered.
57 int error_;
60 } // namespace net
62 #endif // NET_URL_REQUEST_URL_REQUEST_STATUS_H_