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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 static PassRefPtr<JSONObject> buildObjectForHeaders(const HTTPHeaderMap& headers
) | 85 static PassRefPtr<JSONObject> buildObjectForHeaders(const HTTPHeaderMap& headers
) |
86 { | 86 { |
87 RefPtr<JSONObject> headersObject = JSONObject::create(); | 87 RefPtr<JSONObject> headersObject = JSONObject::create(); |
88 HTTPHeaderMap::const_iterator end = headers.end(); | 88 HTTPHeaderMap::const_iterator end = headers.end(); |
89 for (HTTPHeaderMap::const_iterator it = headers.begin(); it != end; ++it) | 89 for (HTTPHeaderMap::const_iterator it = headers.begin(); it != end; ++it) |
90 headersObject->setString(it->key.string(), it->value); | 90 headersObject->setString(it->key.string(), it->value); |
91 return headersObject; | 91 return headersObject; |
92 } | 92 } |
93 | 93 |
94 class InspectorThreadableLoaderClient : public ThreadableLoaderClient { | 94 class InspectorThreadableLoaderClient FINAL : public ThreadableLoaderClient { |
95 WTF_MAKE_NONCOPYABLE(InspectorThreadableLoaderClient); | 95 WTF_MAKE_NONCOPYABLE(InspectorThreadableLoaderClient); |
96 public: | 96 public: |
97 InspectorThreadableLoaderClient(PassRefPtr<LoadResourceForFrontendCallback>
callback) | 97 InspectorThreadableLoaderClient(PassRefPtr<LoadResourceForFrontendCallback>
callback) |
98 : m_callback(callback) | 98 : m_callback(callback) |
99 , m_statusCode(0) { } | 99 , m_statusCode(0) { } |
100 | 100 |
101 virtual ~InspectorThreadableLoaderClient() { } | 101 virtual ~InspectorThreadableLoaderClient() { } |
102 | 102 |
103 virtual void didReceiveResponse(unsigned long identifier, const ResourceResp
onse& response) | 103 virtual void didReceiveResponse(unsigned long identifier, const ResourceResp
onse& response) OVERRIDE |
104 { | 104 { |
105 WTF::TextEncoding textEncoding(response.textEncodingName()); | 105 WTF::TextEncoding textEncoding(response.textEncodingName()); |
106 bool useDetector = false; | 106 bool useDetector = false; |
107 if (!textEncoding.isValid()) { | 107 if (!textEncoding.isValid()) { |
108 textEncoding = UTF8Encoding(); | 108 textEncoding = UTF8Encoding(); |
109 useDetector = true; | 109 useDetector = true; |
110 } | 110 } |
111 m_decoder = TextResourceDecoder::create("text/plain", textEncoding, useD
etector); | 111 m_decoder = TextResourceDecoder::create("text/plain", textEncoding, useD
etector); |
112 m_statusCode = response.httpStatusCode(); | 112 m_statusCode = response.httpStatusCode(); |
113 m_responseHeaders = response.httpHeaderFields(); | 113 m_responseHeaders = response.httpHeaderFields(); |
114 } | 114 } |
115 | 115 |
116 virtual void didReceiveData(const char* data, int dataLength) | 116 virtual void didReceiveData(const char* data, int dataLength) OVERRIDE |
117 { | 117 { |
118 if (!dataLength) | 118 if (!dataLength) |
119 return; | 119 return; |
120 | 120 |
121 if (dataLength == -1) | 121 if (dataLength == -1) |
122 dataLength = strlen(data); | 122 dataLength = strlen(data); |
123 | 123 |
124 m_responseText = m_responseText.concatenateWith(m_decoder->decode(data,
dataLength)); | 124 m_responseText = m_responseText.concatenateWith(m_decoder->decode(data,
dataLength)); |
125 } | 125 } |
126 | 126 |
127 virtual void didFinishLoading(unsigned long /*identifier*/, double /*finishT
ime*/) | 127 virtual void didFinishLoading(unsigned long /*identifier*/, double /*finishT
ime*/) OVERRIDE |
128 { | 128 { |
129 if (m_decoder) | 129 if (m_decoder) |
130 m_responseText = m_responseText.concatenateWith(m_decoder->flush()); | 130 m_responseText = m_responseText.concatenateWith(m_decoder->flush()); |
131 m_callback->sendSuccess(m_statusCode, buildObjectForHeaders(m_responseHe
aders), m_responseText.flattenToString()); | 131 m_callback->sendSuccess(m_statusCode, buildObjectForHeaders(m_responseHe
aders), m_responseText.flattenToString()); |
132 dispose(); | 132 dispose(); |
133 } | 133 } |
134 | 134 |
135 virtual void didFail(const ResourceError&) | 135 virtual void didFail(const ResourceError&) OVERRIDE |
136 { | 136 { |
137 m_callback->sendFailure("Loading resource for inspector failed"); | 137 m_callback->sendFailure("Loading resource for inspector failed"); |
138 dispose(); | 138 dispose(); |
139 } | 139 } |
140 | 140 |
141 virtual void didFailRedirectCheck() | 141 virtual void didFailRedirectCheck() OVERRIDE |
142 { | 142 { |
143 m_callback->sendFailure("Loading resource for inspector failed redirect
check"); | 143 m_callback->sendFailure("Loading resource for inspector failed redirect
check"); |
144 dispose(); | 144 dispose(); |
145 } | 145 } |
146 | 146 |
147 void didFailLoaderCreation() | 147 void didFailLoaderCreation() |
148 { | 148 { |
149 m_callback->sendFailure("Couldn't create a loader"); | 149 m_callback->sendFailure("Couldn't create a loader"); |
150 dispose(); | 150 dispose(); |
151 } | 151 } |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 : InspectorBaseAgent<InspectorResourceAgent>("Network", instrumentingAgents,
state) | 783 : InspectorBaseAgent<InspectorResourceAgent>("Network", instrumentingAgents,
state) |
784 , m_pageAgent(pageAgent) | 784 , m_pageAgent(pageAgent) |
785 , m_client(client) | 785 , m_client(client) |
786 , m_frontend(0) | 786 , m_frontend(0) |
787 , m_resourcesData(adoptPtr(new NetworkResourcesData())) | 787 , m_resourcesData(adoptPtr(new NetworkResourcesData())) |
788 , m_isRecalculatingStyle(false) | 788 , m_isRecalculatingStyle(false) |
789 { | 789 { |
790 } | 790 } |
791 | 791 |
792 } // namespace WebCore | 792 } // namespace WebCore |
OLD | NEW |