OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/blob/view_blob_internals_job.h" | 5 #include "webkit/blob/view_blob_internals_job.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
9 #include "base/i18n/number_formatting.h" | 9 #include "base/i18n/number_formatting.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 net::URLRequestSimpleJob::Kill(); | 128 net::URLRequestSimpleJob::Kill(); |
129 method_factory_.RevokeAll(); | 129 method_factory_.RevokeAll(); |
130 } | 130 } |
131 | 131 |
132 void ViewBlobInternalsJob::DoWorkAsync() { | 132 void ViewBlobInternalsJob::DoWorkAsync() { |
133 if (request_->url().has_query() && | 133 if (request_->url().has_query() && |
134 StartsWithASCII(request_->url().query(), "remove=", true)) { | 134 StartsWithASCII(request_->url().query(), "remove=", true)) { |
135 std::string blob_url = request_->url().query().substr(strlen("remove=")); | 135 std::string blob_url = request_->url().query().substr(strlen("remove=")); |
136 blob_url = net::UnescapeURLComponent(blob_url, | 136 blob_url = net::UnescapeURLComponent(blob_url, |
137 UnescapeRule::NORMAL | UnescapeRule::URL_SPECIAL_CHARS); | 137 UnescapeRule::NORMAL | UnescapeRule::URL_SPECIAL_CHARS); |
138 blob_storage_controller_->UnregisterBlobUrl(GURL(blob_url)); | 138 blob_storage_controller_->RemoveBlob(GURL(blob_url)); |
139 } | 139 } |
140 | 140 |
141 StartAsync(); | 141 StartAsync(); |
142 } | 142 } |
143 | 143 |
144 bool ViewBlobInternalsJob::GetData(std::string* mime_type, | 144 bool ViewBlobInternalsJob::GetData(std::string* mime_type, |
145 std::string* charset, | 145 std::string* charset, |
146 std::string* data) const { | 146 std::string* data) const { |
147 mime_type->assign("text/html"); | 147 mime_type->assign("text/html"); |
148 charset->assign("UTF-8"); | 148 charset->assign("UTF-8"); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 UTF16ToUTF8(base::FormatNumber(blob_data.items().size())), out); | 183 UTF16ToUTF8(base::FormatNumber(blob_data.items().size())), out); |
184 } | 184 } |
185 | 185 |
186 for (size_t i = 0; i < blob_data.items().size(); ++i) { | 186 for (size_t i = 0; i < blob_data.items().size(); ++i) { |
187 if (has_multi_items) { | 187 if (has_multi_items) { |
188 AddHTMLListItem(kIndex, UTF16ToUTF8(base::FormatNumber(i)), out); | 188 AddHTMLListItem(kIndex, UTF16ToUTF8(base::FormatNumber(i)), out); |
189 StartHTMLList(out); | 189 StartHTMLList(out); |
190 } | 190 } |
191 const BlobData::Item& item = blob_data.items().at(i); | 191 const BlobData::Item& item = blob_data.items().at(i); |
192 | 192 |
193 switch (item.type()) { | 193 switch (item.type) { |
194 case BlobData::TYPE_DATA: | 194 case BlobData::TYPE_DATA: |
| 195 case BlobData::TYPE_DATA_EXTERNAL: |
195 AddHTMLListItem(kType, "data", out); | 196 AddHTMLListItem(kType, "data", out); |
196 break; | 197 break; |
197 case BlobData::TYPE_FILE: | 198 case BlobData::TYPE_FILE: |
198 AddHTMLListItem(kType, "file", out); | 199 AddHTMLListItem(kType, "file", out); |
199 AddHTMLListItem(kPath, | 200 AddHTMLListItem(kPath, |
200 #if defined(OS_WIN) | 201 #if defined(OS_WIN) |
201 net::EscapeForHTML(WideToUTF8(item.file_path().value())), | 202 net::EscapeForHTML(WideToUTF8(item.file_path.value())), |
202 #else | 203 #else |
203 net::EscapeForHTML(item.file_path().value()), | 204 net::EscapeForHTML(item.file_path.value()), |
204 #endif | 205 #endif |
205 out); | 206 out); |
206 if (!item.expected_modification_time().is_null()) { | 207 if (!item.expected_modification_time.is_null()) { |
207 AddHTMLListItem(kModificationTime, UTF16ToUTF8( | 208 AddHTMLListItem(kModificationTime, UTF16ToUTF8( |
208 TimeFormatFriendlyDateAndTime(item.expected_modification_time())), | 209 TimeFormatFriendlyDateAndTime(item.expected_modification_time)), |
209 out); | 210 out); |
210 } | 211 } |
211 break; | 212 break; |
212 case BlobData::TYPE_BLOB: | 213 case BlobData::TYPE_BLOB: |
213 AddHTMLListItem(kType, "blob", out); | 214 AddHTMLListItem(kType, "blob", out); |
214 AddHTMLListItem(kURL, item.blob_url().spec(), out); | 215 AddHTMLListItem(kURL, item.blob_url.spec(), out); |
215 break; | 216 break; |
216 } | 217 } |
217 if (item.offset()) { | 218 if (item.offset) { |
218 AddHTMLListItem(kOffset, UTF16ToUTF8(base::FormatNumber( | 219 AddHTMLListItem(kOffset, UTF16ToUTF8(base::FormatNumber( |
219 static_cast<int64>(item.offset()))), out); | 220 static_cast<int64>(item.offset))), out); |
220 } | 221 } |
221 if (static_cast<int64>(item.length()) != -1) { | 222 if (static_cast<int64>(item.length) != -1) { |
222 AddHTMLListItem(kLength, UTF16ToUTF8(base::FormatNumber( | 223 AddHTMLListItem(kLength, UTF16ToUTF8(base::FormatNumber( |
223 static_cast<int64>(item.length()))), out); | 224 static_cast<int64>(item.length))), out); |
224 } | 225 } |
225 | 226 |
226 if (has_multi_items) | 227 if (has_multi_items) |
227 EndHTMLList(out); | 228 EndHTMLList(out); |
228 } | 229 } |
229 | 230 |
230 EndHTMLList(out); | 231 EndHTMLList(out); |
231 } | 232 } |
232 | 233 |
233 } // namespace webkit_blob | 234 } // namespace webkit_blob |
OLD | NEW |