OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 static PassRefPtr<JSONObject> buildObjectForHeaders(const HTTPHeaderMap& headers
) | 89 static PassRefPtr<JSONObject> buildObjectForHeaders(const HTTPHeaderMap& headers
) |
90 { | 90 { |
91 RefPtr<JSONObject> headersObject = JSONObject::create(); | 91 RefPtr<JSONObject> headersObject = JSONObject::create(); |
92 HTTPHeaderMap::const_iterator end = headers.end(); | 92 HTTPHeaderMap::const_iterator end = headers.end(); |
93 for (HTTPHeaderMap::const_iterator it = headers.begin(); it != end; ++it) | 93 for (HTTPHeaderMap::const_iterator it = headers.begin(); it != end; ++it) |
94 headersObject->setString(it->key.string(), it->value); | 94 headersObject->setString(it->key.string(), it->value); |
95 return headersObject; | 95 return headersObject; |
96 } | 96 } |
97 | 97 |
98 class InspectorThreadableLoaderClient FINAL : public ThreadableLoaderClient { | 98 class InspectorThreadableLoaderClient final : public ThreadableLoaderClient { |
99 WTF_MAKE_NONCOPYABLE(InspectorThreadableLoaderClient); | 99 WTF_MAKE_NONCOPYABLE(InspectorThreadableLoaderClient); |
100 public: | 100 public: |
101 InspectorThreadableLoaderClient(PassRefPtrWillBeRawPtr<LoadResourceForFronte
ndCallback> callback) | 101 InspectorThreadableLoaderClient(PassRefPtrWillBeRawPtr<LoadResourceForFronte
ndCallback> callback) |
102 : m_callback(callback) | 102 : m_callback(callback) |
103 , m_statusCode(0) { } | 103 , m_statusCode(0) { } |
104 | 104 |
105 virtual ~InspectorThreadableLoaderClient() { } | 105 virtual ~InspectorThreadableLoaderClient() { } |
106 | 106 |
107 virtual void didReceiveResponse(unsigned long identifier, const ResourceResp
onse& response) OVERRIDE | 107 virtual void didReceiveResponse(unsigned long identifier, const ResourceResp
onse& response) override |
108 { | 108 { |
109 WTF::TextEncoding textEncoding(response.textEncodingName()); | 109 WTF::TextEncoding textEncoding(response.textEncodingName()); |
110 bool useDetector = false; | 110 bool useDetector = false; |
111 if (!textEncoding.isValid()) { | 111 if (!textEncoding.isValid()) { |
112 textEncoding = UTF8Encoding(); | 112 textEncoding = UTF8Encoding(); |
113 useDetector = true; | 113 useDetector = true; |
114 } | 114 } |
115 m_decoder = TextResourceDecoder::create("text/plain", textEncoding, useD
etector); | 115 m_decoder = TextResourceDecoder::create("text/plain", textEncoding, useD
etector); |
116 m_statusCode = response.httpStatusCode(); | 116 m_statusCode = response.httpStatusCode(); |
117 m_responseHeaders = response.httpHeaderFields(); | 117 m_responseHeaders = response.httpHeaderFields(); |
118 } | 118 } |
119 | 119 |
120 virtual void didReceiveData(const char* data, unsigned dataLength) OVERRIDE | 120 virtual void didReceiveData(const char* data, unsigned dataLength) override |
121 { | 121 { |
122 if (!dataLength) | 122 if (!dataLength) |
123 return; | 123 return; |
124 | 124 |
125 m_responseText = m_responseText.concatenateWith(m_decoder->decode(data,
dataLength)); | 125 m_responseText = m_responseText.concatenateWith(m_decoder->decode(data,
dataLength)); |
126 } | 126 } |
127 | 127 |
128 virtual void didFinishLoading(unsigned long /*identifier*/, double /*finishT
ime*/) OVERRIDE | 128 virtual void didFinishLoading(unsigned long /*identifier*/, double /*finishT
ime*/) override |
129 { | 129 { |
130 if (m_decoder) | 130 if (m_decoder) |
131 m_responseText = m_responseText.concatenateWith(m_decoder->flush()); | 131 m_responseText = m_responseText.concatenateWith(m_decoder->flush()); |
132 m_callback->sendSuccess(m_statusCode, buildObjectForHeaders(m_responseHe
aders), m_responseText.flattenToString()); | 132 m_callback->sendSuccess(m_statusCode, buildObjectForHeaders(m_responseHe
aders), m_responseText.flattenToString()); |
133 dispose(); | 133 dispose(); |
134 } | 134 } |
135 | 135 |
136 virtual void didFail(const ResourceError&) OVERRIDE | 136 virtual void didFail(const ResourceError&) override |
137 { | 137 { |
138 m_callback->sendFailure("Loading resource for inspector failed"); | 138 m_callback->sendFailure("Loading resource for inspector failed"); |
139 dispose(); | 139 dispose(); |
140 } | 140 } |
141 | 141 |
142 virtual void didFailRedirectCheck() OVERRIDE | 142 virtual void didFailRedirectCheck() override |
143 { | 143 { |
144 m_callback->sendFailure("Loading resource for inspector failed redirect
check"); | 144 m_callback->sendFailure("Loading resource for inspector failed redirect
check"); |
145 dispose(); | 145 dispose(); |
146 } | 146 } |
147 | 147 |
148 void didFailLoaderCreation() | 148 void didFailLoaderCreation() |
149 { | 149 { |
150 m_callback->sendFailure("Couldn't create a loader"); | 150 m_callback->sendFailure("Couldn't create a loader"); |
151 dispose(); | 151 dispose(); |
152 } | 152 } |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish
edReplayXHRFired) | 885 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish
edReplayXHRFired) |
886 { | 886 { |
887 } | 887 } |
888 | 888 |
889 bool InspectorResourceAgent::shouldForceCORSPreflight() | 889 bool InspectorResourceAgent::shouldForceCORSPreflight() |
890 { | 890 { |
891 return m_state->getBoolean(ResourceAgentState::cacheDisabled); | 891 return m_state->getBoolean(ResourceAgentState::cacheDisabled); |
892 } | 892 } |
893 | 893 |
894 } // namespace blink | 894 } // namespace blink |
OLD | NEW |