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

Unified Diff: storage/browser/blob/view_blob_internals_job.cc

Issue 1985383002: Logging and check fail crbug/612358 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleaned up logging Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: storage/browser/blob/view_blob_internals_job.cc
diff --git a/storage/browser/blob/view_blob_internals_job.cc b/storage/browser/blob/view_blob_internals_job.cc
index 287f9943939374bd71c3c3a8935d8394c3b346ca..e6043ba6747bc10042b44eb3d1c8d990bb2b64e6 100644
--- a/storage/browser/blob/view_blob_internals_job.cc
+++ b/storage/browser/blob/view_blob_internals_job.cc
@@ -27,11 +27,14 @@
#include "storage/browser/blob/blob_storage_registry.h"
#include "storage/browser/blob/internal_blob_data.h"
+using BlobState = storage::BlobStorageRegistry::BlobState;
+
namespace {
const char kEmptyBlobStorageMessage[] = "No available blob data.";
const char kContentType[] = "Content Type: ";
const char kContentDisposition[] = "Content Disposition: ";
+const char kState[] = "State: ";
const char kCount[] = "Count: ";
const char kIndex[] = "Index: ";
const char kType[] = "Type: ";
@@ -59,6 +62,17 @@ void StartHTML(std::string* out) {
"</head><body>\n\n");
}
+std::string BlobStateToString(BlobState state) {
+ switch(state) {
+ case BlobState::PENDING:
+ return "Pending";
+ case BlobState::COMPLETE:
+ return "Complete";
+ case BlobState::BROKEN:
+ return "Broken";
+ }
+}
+
void EndHTML(std::string* out) {
out->append("\n</body></html>");
}
@@ -155,10 +169,12 @@ void ViewBlobInternalsJob::GenerateHTML(std::string* out) const {
blob_storage_context_->registry_.blob_map_.begin();
iter != blob_storage_context_->registry_.blob_map_.end(); ++iter) {
AddHTMLBoldText(iter->first, out);
- GenerateHTMLForBlobData(*iter->second->data, iter->second->content_type,
+ CHECK(iter->second);
+ GenerateHTMLForBlobData(*iter->second, iter->second->content_type,
iter->second->content_disposition,
iter->second->refcount, out);
}
+
if (!blob_storage_context_->registry_.url_to_uuid_.empty()) {
AddHorizontalRule(out);
for (BlobStorageRegistry::URLMap::const_iterator iter =
@@ -173,7 +189,7 @@ void ViewBlobInternalsJob::GenerateHTML(std::string* out) const {
}
void ViewBlobInternalsJob::GenerateHTMLForBlobData(
- const InternalBlobData& blob_data,
+ const BlobStorageRegistry::Entry& entry,
const std::string& content_type,
const std::string& content_disposition,
int refcount,
@@ -186,63 +202,74 @@ void ViewBlobInternalsJob::GenerateHTMLForBlobData(
if (!content_disposition.empty())
AddHTMLListItem(kContentDisposition, content_disposition, out);
- bool has_multi_items = blob_data.items().size() > 1;
+ InternalBlobData* blob_data = entry.data.get();
+
+ AddHTMLListItem(kState, BlobStateToString(entry.state), out);
+
+ if (!blob_data) {
+ EndHTMLList(out);
+ return;
+ }
+
+ bool has_multi_items = blob_data->items().size() > 1;
if (has_multi_items) {
AddHTMLListItem(kCount,
- base::UTF16ToUTF8(base::FormatNumber(blob_data.items().size())), out);
+ base::UTF16ToUTF8(base::FormatNumber(blob_data->items().size())), out);
}
- for (size_t i = 0; i < blob_data.items().size(); ++i) {
+ for (size_t i = 0; i < blob_data->items().size(); ++i) {
if (has_multi_items) {
AddHTMLListItem(kIndex, base::UTF16ToUTF8(base::FormatNumber(i)), out);
StartHTMLList(out);
}
- const BlobDataItem& item = *(blob_data.items().at(i)->item());
+ BlobDataItem* item = blob_data->items().at(i)->item().get();
+ CHECK(item);
- switch (item.type()) {
+ switch (item->type()) {
case DataElement::TYPE_BYTES:
AddHTMLListItem(kType, "data", out);
break;
case DataElement::TYPE_FILE:
AddHTMLListItem(kType, "file", out);
AddHTMLListItem(kPath,
- net::EscapeForHTML(item.path().AsUTF8Unsafe()),
+ net::EscapeForHTML(item->path().AsUTF8Unsafe()),
out);
- if (!item.expected_modification_time().is_null()) {
+ if (!item->expected_modification_time().is_null()) {
AddHTMLListItem(kModificationTime, base::UTF16ToUTF8(
- TimeFormatFriendlyDateAndTime(item.expected_modification_time())),
+ TimeFormatFriendlyDateAndTime(item->expected_modification_time())),
out);
}
break;
case DataElement::TYPE_BLOB:
- NOTREACHED(); // Should be flattened in the storage context.
+ AddHTMLListItem(kType, "pending blob", out);
break;
case DataElement::TYPE_FILE_FILESYSTEM:
AddHTMLListItem(kType, "filesystem", out);
- AddHTMLListItem(kURL, item.filesystem_url().spec(), out);
- if (!item.expected_modification_time().is_null()) {
+ AddHTMLListItem(kURL, item->filesystem_url().spec(), out);
+ if (!item->expected_modification_time().is_null()) {
AddHTMLListItem(kModificationTime, base::UTF16ToUTF8(
- TimeFormatFriendlyDateAndTime(item.expected_modification_time())),
+ TimeFormatFriendlyDateAndTime(item->expected_modification_time())),
out);
}
break;
case DataElement::TYPE_DISK_CACHE_ENTRY:
AddHTMLListItem(kType, "disk cache entry", out);
- AddHTMLListItem(kURL, item.disk_cache_entry()->GetKey(), out);
+ AddHTMLListItem(kURL, item->disk_cache_entry()->GetKey(), out);
break;
case DataElement::TYPE_BYTES_DESCRIPTION:
+ AddHTMLListItem(kType, "pending data", out);
case DataElement::TYPE_UNKNOWN:
NOTREACHED();
break;
}
- if (item.offset()) {
+ if (item->offset()) {
AddHTMLListItem(kOffset, base::UTF16ToUTF8(base::FormatNumber(
- static_cast<int64_t>(item.offset()))),
+ static_cast<int64_t>(item->offset()))),
out);
}
- if (static_cast<int64_t>(item.length()) != -1) {
+ if (static_cast<int64_t>(item->length()) != -1) {
AddHTMLListItem(kLength, base::UTF16ToUTF8(base::FormatNumber(
- static_cast<int64_t>(item.length()))),
+ static_cast<int64_t>(item->length()))),
out);
}

Powered by Google App Engine
This is Rietveld 408576698