diff options
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/net_errors.cc | 16 | ||||
-rw-r--r-- | net/base/net_errors.h | 7 |
2 files changed, 21 insertions, 2 deletions
diff --git a/net/base/net_errors.cc b/net/base/net_errors.cc index 623c071..8ac6b89 100644 --- a/net/base/net_errors.cc +++ b/net/base/net_errors.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -44,4 +44,18 @@ std::vector<int> GetAllErrorCodesForUma() { kAllErrorCodes, arraysize(kAllErrorCodes)); } +Error PlatformFileErrorToNetError( + base::PlatformFileError file_error) { + switch (file_error) { + case base::PLATFORM_FILE_OK: + return net::OK; + case base::PLATFORM_FILE_ERROR_NOT_FOUND: + return net::ERR_FILE_NOT_FOUND; + case base::PLATFORM_FILE_ERROR_ACCESS_DENIED: + return net::ERR_ACCESS_DENIED; + default: + return net::ERR_FAILED; + } +} + } // namespace net diff --git a/net/base/net_errors.h b/net/base/net_errors.h index 12344e7..6c30775 100644 --- a/net/base/net_errors.h +++ b/net/base/net_errors.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,6 +8,7 @@ #include <vector> #include "base/basictypes.h" +#include "base/platform_file.h" #include "net/base/net_export.h" namespace net { @@ -50,6 +51,10 @@ NET_EXPORT Error MapSystemError(int os_error); // error code that is not followed immediately by a valid error code. std::vector<int> GetAllErrorCodesForUma(); +// A convenient function to translate platform file error to net error code. +NET_EXPORT Error PlatformFileErrorToNetError( + base::PlatformFileError file_error); + } // namespace net #endif // NET_BASE_NET_ERRORS_H__ |