| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "storage/browser/blob/view_blob_internals_job.h" | 5 #include "storage/browser/blob/view_blob_internals_job.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 } | 173 } |
| 174 | 174 |
| 175 int ViewBlobInternalsJob::GetData( | 175 int ViewBlobInternalsJob::GetData( |
| 176 std::string* mime_type, | 176 std::string* mime_type, |
| 177 std::string* charset, | 177 std::string* charset, |
| 178 std::string* data, | 178 std::string* data, |
| 179 const net::CompletionCallback& callback) const { | 179 const net::CompletionCallback& callback) const { |
| 180 mime_type->assign("text/html"); | 180 mime_type->assign("text/html"); |
| 181 charset->assign("UTF-8"); | 181 charset->assign("UTF-8"); |
| 182 | 182 |
| 183 data->clear(); | 183 *data = GenerateHTML(blob_storage_context_); |
| 184 StartHTML(data); | |
| 185 if (blob_storage_context_->registry().blob_map_.empty()) | |
| 186 data->append(kEmptyBlobStorageMessage); | |
| 187 else | |
| 188 GenerateHTML(data); | |
| 189 EndHTML(data); | |
| 190 return net::OK; | 184 return net::OK; |
| 191 } | 185 } |
| 192 | 186 |
| 193 void ViewBlobInternalsJob::GenerateHTML(std::string* out) const { | 187 std::string ViewBlobInternalsJob::GenerateHTML( |
| 194 for (auto iter = blob_storage_context_->registry().blob_map_.begin(); | 188 BlobStorageContext* blob_storage_context) { |
| 195 iter != blob_storage_context_->registry().blob_map_.end(); ++iter) { | 189 std::string out; |
| 196 AddHTMLBoldText(iter->first, out); | 190 StartHTML(&out); |
| 197 GenerateHTMLForBlobData(*iter->second, iter->second->content_type(), | 191 if (blob_storage_context->registry().blob_map_.empty()) { |
| 198 iter->second->content_disposition(), | 192 out.append(kEmptyBlobStorageMessage); |
| 199 iter->second->refcount(), out); | 193 } else { |
| 200 } | 194 for (auto iter = blob_storage_context->registry().blob_map_.begin(); |
| 201 if (!blob_storage_context_->registry().url_to_uuid_.empty()) { | 195 iter != blob_storage_context->registry().blob_map_.end(); ++iter) { |
| 202 AddHorizontalRule(out); | 196 AddHTMLBoldText(iter->first, &out); |
| 203 for (auto iter = blob_storage_context_->registry().url_to_uuid_.begin(); | 197 GenerateHTMLForBlobData(*iter->second, iter->second->content_type(), |
| 204 iter != blob_storage_context_->registry().url_to_uuid_.end(); ++iter) { | 198 iter->second->content_disposition(), |
| 205 AddHTMLBoldText(iter->first.spec(), out); | 199 iter->second->refcount(), &out); |
| 206 StartHTMLList(out); | 200 } |
| 207 AddHTMLListItem(kUUID, iter->second, out); | 201 if (!blob_storage_context->registry().url_to_uuid_.empty()) { |
| 208 EndHTMLList(out); | 202 AddHorizontalRule(&out); |
| 203 for (auto iter = blob_storage_context->registry().url_to_uuid_.begin(); |
| 204 iter != blob_storage_context->registry().url_to_uuid_.end(); |
| 205 ++iter) { |
| 206 AddHTMLBoldText(iter->first.spec(), &out); |
| 207 StartHTMLList(&out); |
| 208 AddHTMLListItem(kUUID, iter->second, &out); |
| 209 EndHTMLList(&out); |
| 210 } |
| 209 } | 211 } |
| 210 } | 212 } |
| 213 EndHTML(&out); |
| 214 return out; |
| 211 } | 215 } |
| 212 | 216 |
| 213 void ViewBlobInternalsJob::GenerateHTMLForBlobData( | 217 void ViewBlobInternalsJob::GenerateHTMLForBlobData( |
| 214 const BlobEntry& blob_data, | 218 const BlobEntry& blob_data, |
| 215 const std::string& content_type, | 219 const std::string& content_type, |
| 216 const std::string& content_disposition, | 220 const std::string& content_disposition, |
| 217 int refcount, | 221 int refcount, |
| 218 std::string* out) { | 222 std::string* out) { |
| 219 StartHTMLList(out); | 223 StartHTMLList(out); |
| 220 | 224 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 } | 291 } |
| 288 | 292 |
| 289 if (has_multi_items) | 293 if (has_multi_items) |
| 290 EndHTMLList(out); | 294 EndHTMLList(out); |
| 291 } | 295 } |
| 292 | 296 |
| 293 EndHTMLList(out); | 297 EndHTMLList(out); |
| 294 } | 298 } |
| 295 | 299 |
| 296 } // namespace storage | 300 } // namespace storage |
| OLD | NEW |