| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #define ResourceError_h | 28 #define ResourceError_h |
| 29 | 29 |
| 30 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
| 31 #include "platform/PlatformExport.h" | 31 #include "platform/PlatformExport.h" |
| 32 #include "wtf/Allocator.h" | 32 #include "wtf/Allocator.h" |
| 33 #include "wtf/text/WTFString.h" | 33 #include "wtf/text/WTFString.h" |
| 34 #include <iosfwd> | 34 #include <iosfwd> |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 enum class ResourceRequestBlockedReason; |
| 39 |
| 38 // Used for errors that won't be exposed to clients. | 40 // Used for errors that won't be exposed to clients. |
| 39 PLATFORM_EXPORT extern const char errorDomainBlinkInternal[]; | 41 PLATFORM_EXPORT extern const char errorDomainBlinkInternal[]; |
| 40 | 42 |
| 41 class PLATFORM_EXPORT ResourceError final { | 43 class PLATFORM_EXPORT ResourceError final { |
| 42 DISALLOW_NEW(); | 44 DISALLOW_NEW(); |
| 43 | 45 |
| 44 public: | 46 public: |
| 45 enum Error { | 47 enum Error { |
| 46 ACCESS_DENIED = net::ERR_ACCESS_DENIED, | 48 ACCESS_DENIED = net::ERR_ACCESS_DENIED, |
| 47 BLOCKED_BY_XSS_AUDITOR = net::ERR_BLOCKED_BY_XSS_AUDITOR | 49 BLOCKED_BY_XSS_AUDITOR = net::ERR_BLOCKED_BY_XSS_AUDITOR |
| 48 }; | 50 }; |
| 49 | 51 |
| 50 static ResourceError cancelledError(const String& failingURL); | 52 static ResourceError cancelledError(const String& failingURL); |
| 51 static ResourceError cancelledDueToAccessCheckError(const String& failingURL); | 53 static ResourceError cancelledDueToAccessCheckError( |
| 54 const String& failingURL, |
| 55 ResourceRequestBlockedReason); |
| 52 | 56 |
| 53 // Only for Blink internal usage. | 57 // Only for Blink internal usage. |
| 54 static ResourceError cacheMissError(const String& failingURL); | 58 static ResourceError cacheMissError(const String& failingURL); |
| 55 | 59 |
| 56 ResourceError() | 60 ResourceError() |
| 57 : m_errorCode(0), | 61 : m_errorCode(0), |
| 58 m_isNull(true), | 62 m_isNull(true), |
| 59 m_isCancellation(false), | 63 m_isCancellation(false), |
| 60 m_isAccessCheck(false), | 64 m_isAccessCheck(false), |
| 61 m_isTimeout(false), | 65 m_isTimeout(false), |
| 62 m_staleCopyInCache(false), | 66 m_staleCopyInCache(false), |
| 63 m_wasIgnoredByHandler(false), | 67 m_wasIgnoredByHandler(false), |
| 64 m_isCacheMiss(false) {} | 68 m_isCacheMiss(false), |
| 69 m_shouldCollapseInitiator(false) {} |
| 65 | 70 |
| 66 ResourceError(const String& domain, | 71 ResourceError(const String& domain, |
| 67 int errorCode, | 72 int errorCode, |
| 68 const String& failingURL, | 73 const String& failingURL, |
| 69 const String& localizedDescription) | 74 const String& localizedDescription) |
| 70 : m_domain(domain), | 75 : m_domain(domain), |
| 71 m_errorCode(errorCode), | 76 m_errorCode(errorCode), |
| 72 m_failingURL(failingURL), | 77 m_failingURL(failingURL), |
| 73 m_localizedDescription(localizedDescription), | 78 m_localizedDescription(localizedDescription), |
| 74 m_isNull(false), | 79 m_isNull(false), |
| 75 m_isCancellation(false), | 80 m_isCancellation(false), |
| 76 m_isAccessCheck(false), | 81 m_isAccessCheck(false), |
| 77 m_isTimeout(false), | 82 m_isTimeout(false), |
| 78 m_staleCopyInCache(false), | 83 m_staleCopyInCache(false), |
| 79 m_wasIgnoredByHandler(false), | 84 m_wasIgnoredByHandler(false), |
| 80 m_isCacheMiss(false) {} | 85 m_isCacheMiss(false), |
| 86 m_shouldCollapseInitiator(false) {} |
| 81 | 87 |
| 82 // Makes a deep copy. Useful for when you need to use a ResourceError on | 88 // Makes a deep copy. Useful for when you need to use a ResourceError on |
| 83 // another thread. | 89 // another thread. |
| 84 ResourceError copy() const; | 90 ResourceError copy() const; |
| 85 | 91 |
| 86 bool isNull() const { return m_isNull; } | 92 bool isNull() const { return m_isNull; } |
| 87 | 93 |
| 88 const String& domain() const { return m_domain; } | 94 const String& domain() const { return m_domain; } |
| 89 int errorCode() const { return m_errorCode; } | 95 int errorCode() const { return m_errorCode; } |
| 90 const String& failingURL() const { return m_failingURL; } | 96 const String& failingURL() const { return m_failingURL; } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 106 bool staleCopyInCache() const { return m_staleCopyInCache; } | 112 bool staleCopyInCache() const { return m_staleCopyInCache; } |
| 107 | 113 |
| 108 void setWasIgnoredByHandler(bool ignoredByHandler) { | 114 void setWasIgnoredByHandler(bool ignoredByHandler) { |
| 109 m_wasIgnoredByHandler = ignoredByHandler; | 115 m_wasIgnoredByHandler = ignoredByHandler; |
| 110 } | 116 } |
| 111 bool wasIgnoredByHandler() const { return m_wasIgnoredByHandler; } | 117 bool wasIgnoredByHandler() const { return m_wasIgnoredByHandler; } |
| 112 | 118 |
| 113 void setIsCacheMiss(bool isCacheMiss) { m_isCacheMiss = isCacheMiss; } | 119 void setIsCacheMiss(bool isCacheMiss) { m_isCacheMiss = isCacheMiss; } |
| 114 bool isCacheMiss() const { return m_isCacheMiss; } | 120 bool isCacheMiss() const { return m_isCacheMiss; } |
| 115 | 121 |
| 122 void setShouldCollapseInitiator(bool shouldCollapseInitiator) { |
| 123 m_shouldCollapseInitiator = shouldCollapseInitiator; |
| 124 } |
| 125 bool shouldCollapseInitiator() const { return m_shouldCollapseInitiator; } |
| 126 |
| 116 static bool compare(const ResourceError&, const ResourceError&); | 127 static bool compare(const ResourceError&, const ResourceError&); |
| 117 | 128 |
| 118 private: | 129 private: |
| 119 String m_domain; | 130 String m_domain; |
| 120 int m_errorCode; | 131 int m_errorCode; |
| 121 String m_failingURL; | 132 String m_failingURL; |
| 122 String m_localizedDescription; | 133 String m_localizedDescription; |
| 123 bool m_isNull; | 134 bool m_isNull; |
| 124 bool m_isCancellation; | 135 bool m_isCancellation; |
| 125 bool m_isAccessCheck; | 136 bool m_isAccessCheck; |
| 126 bool m_isTimeout; | 137 bool m_isTimeout; |
| 127 bool m_staleCopyInCache; | 138 bool m_staleCopyInCache; |
| 128 bool m_wasIgnoredByHandler; | 139 bool m_wasIgnoredByHandler; |
| 129 bool m_isCacheMiss; | 140 bool m_isCacheMiss; |
| 141 bool m_shouldCollapseInitiator; |
| 130 }; | 142 }; |
| 131 | 143 |
| 132 inline bool operator==(const ResourceError& a, const ResourceError& b) { | 144 inline bool operator==(const ResourceError& a, const ResourceError& b) { |
| 133 return ResourceError::compare(a, b); | 145 return ResourceError::compare(a, b); |
| 134 } | 146 } |
| 135 inline bool operator!=(const ResourceError& a, const ResourceError& b) { | 147 inline bool operator!=(const ResourceError& a, const ResourceError& b) { |
| 136 return !(a == b); | 148 return !(a == b); |
| 137 } | 149 } |
| 138 | 150 |
| 139 // Pretty printer for gtest. Declared here to avoid ODR violations. | 151 // Pretty printer for gtest. Declared here to avoid ODR violations. |
| 140 std::ostream& operator<<(std::ostream&, const ResourceError&); | 152 std::ostream& operator<<(std::ostream&, const ResourceError&); |
| 141 | 153 |
| 142 } // namespace blink | 154 } // namespace blink |
| 143 | 155 |
| 144 #endif // ResourceError_h | 156 #endif // ResourceError_h |
| OLD | NEW |