Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: third_party/WebKit/Source/platform/network/ResourceError.h

Issue 2746113002: platform/loader: move network/Resource* to loader/fetch (Closed)
Patch Set: git rebase master Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 #ifndef ResourceError_h
28 #define ResourceError_h
29
30 #include "net/base/net_errors.h"
31 #include "platform/PlatformExport.h"
32 #include "wtf/Allocator.h"
33 #include "wtf/text/WTFString.h"
34 #include <iosfwd>
35
36 namespace blink {
37
38 enum class ResourceRequestBlockedReason;
39
40 // Used for errors that won't be exposed to clients.
41 PLATFORM_EXPORT extern const char errorDomainBlinkInternal[];
42
43 class PLATFORM_EXPORT ResourceError final {
44 DISALLOW_NEW();
45
46 public:
47 enum Error {
48 ACCESS_DENIED = net::ERR_ACCESS_DENIED,
49 BLOCKED_BY_XSS_AUDITOR = net::ERR_BLOCKED_BY_XSS_AUDITOR
50 };
51
52 static ResourceError cancelledError(const String& failingURL);
53 static ResourceError cancelledDueToAccessCheckError(
54 const String& failingURL,
55 ResourceRequestBlockedReason);
56
57 // Only for Blink internal usage.
58 static ResourceError cacheMissError(const String& failingURL);
59
60 ResourceError()
61 : m_errorCode(0),
62 m_isNull(true),
63 m_isCancellation(false),
64 m_isAccessCheck(false),
65 m_isTimeout(false),
66 m_staleCopyInCache(false),
67 m_wasIgnoredByHandler(false),
68 m_isCacheMiss(false),
69 m_shouldCollapseInitiator(false) {}
70
71 ResourceError(const String& domain,
72 int errorCode,
73 const String& failingURL,
74 const String& localizedDescription)
75 : m_domain(domain),
76 m_errorCode(errorCode),
77 m_failingURL(failingURL),
78 m_localizedDescription(localizedDescription),
79 m_isNull(false),
80 m_isCancellation(false),
81 m_isAccessCheck(false),
82 m_isTimeout(false),
83 m_staleCopyInCache(false),
84 m_wasIgnoredByHandler(false),
85 m_isCacheMiss(false),
86 m_shouldCollapseInitiator(false) {}
87
88 // Makes a deep copy. Useful for when you need to use a ResourceError on
89 // another thread.
90 ResourceError copy() const;
91
92 bool isNull() const { return m_isNull; }
93
94 const String& domain() const { return m_domain; }
95 int errorCode() const { return m_errorCode; }
96 const String& failingURL() const { return m_failingURL; }
97 const String& localizedDescription() const { return m_localizedDescription; }
98
99 void setIsCancellation(bool isCancellation) {
100 m_isCancellation = isCancellation;
101 }
102 bool isCancellation() const { return m_isCancellation; }
103
104 void setIsAccessCheck(bool isAccessCheck) { m_isAccessCheck = isAccessCheck; }
105 bool isAccessCheck() const { return m_isAccessCheck; }
106
107 void setIsTimeout(bool isTimeout) { m_isTimeout = isTimeout; }
108 bool isTimeout() const { return m_isTimeout; }
109 void setStaleCopyInCache(bool staleCopyInCache) {
110 m_staleCopyInCache = staleCopyInCache;
111 }
112 bool staleCopyInCache() const { return m_staleCopyInCache; }
113
114 void setWasIgnoredByHandler(bool ignoredByHandler) {
115 m_wasIgnoredByHandler = ignoredByHandler;
116 }
117 bool wasIgnoredByHandler() const { return m_wasIgnoredByHandler; }
118
119 void setIsCacheMiss(bool isCacheMiss) { m_isCacheMiss = isCacheMiss; }
120 bool isCacheMiss() const { return m_isCacheMiss; }
121 bool wasBlockedByResponse() const {
122 return m_errorCode == net::ERR_BLOCKED_BY_RESPONSE;
123 }
124
125 void setShouldCollapseInitiator(bool shouldCollapseInitiator) {
126 m_shouldCollapseInitiator = shouldCollapseInitiator;
127 }
128 bool shouldCollapseInitiator() const { return m_shouldCollapseInitiator; }
129
130 static bool compare(const ResourceError&, const ResourceError&);
131
132 private:
133 String m_domain;
134 int m_errorCode;
135 String m_failingURL;
136 String m_localizedDescription;
137 bool m_isNull;
138 bool m_isCancellation;
139 bool m_isAccessCheck;
140 bool m_isTimeout;
141 bool m_staleCopyInCache;
142 bool m_wasIgnoredByHandler;
143 bool m_isCacheMiss;
144 bool m_shouldCollapseInitiator;
145 };
146
147 inline bool operator==(const ResourceError& a, const ResourceError& b) {
148 return ResourceError::compare(a, b);
149 }
150 inline bool operator!=(const ResourceError& a, const ResourceError& b) {
151 return !(a == b);
152 }
153
154 // Pretty printer for gtest. Declared here to avoid ODR violations.
155 std::ostream& operator<<(std::ostream&, const ResourceError&);
156
157 } // namespace blink
158
159 #endif // ResourceError_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698