From ac768b3e5cce05e463b8ff97243ff13f7119844a Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Fri, 15 Jan 2021 19:00:55 +0200 Subject: "about:debug" shows cache information IssueID #109 --- src/app.c | 25 ++++++++++++++++--------- src/history.c | 32 ++++++++++++++++++++++++++++++++ src/history.h | 2 ++ 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/app.c b/src/app.c index d884d203..8ee09651 100644 --- a/src/app.c +++ b/src/app.c @@ -323,11 +323,10 @@ static void saveState_App_(const iApp *d) { writeData_File(f, magicState_App_, 4); writeU32_File(f, latest_FileVersion); /* version */ iConstForEach(ObjectList, i, iClob(listDocuments_App())) { - if (isInstance_Object(i.object, &Class_DocumentWidget)) { - writeData_File(f, magicTabDocument_App_, 4); - write8_File(f, document_App() == i.object ? 1 : 0); - serializeState_DocumentWidget(i.object, stream_File(f)); - } + iAssert(isInstance_Object(i.object, &Class_DocumentWidget)); + writeData_File(f, magicTabDocument_App_, 4); + write8_File(f, document_App() == i.object ? 1 : 0); + serializeState_DocumentWidget(i.object, stream_File(f)); } } iRelease(f); @@ -500,14 +499,22 @@ const iString *debugInfo_App(void) { iApp *d = &app_; iString *msg = collectNew_String(); format_String(msg, "# Debug information\n"); - appendFormat_String(msg, "## Launch arguments\n"); + appendFormat_String(msg, "## Documents\n"); + iForEach(ObjectList, k, listDocuments_App()) { + iDocumentWidget *doc = k.object; + appendFormat_String(msg, "### Tab %zu: %s\n", + childIndex_Widget(constAs_Widget(doc)->parent, k.object), + cstr_String(bookmarkTitle_DocumentWidget(doc))); + append_String(msg, collect_String(debugInfo_History(history_DocumentWidget(doc)))); + } + appendFormat_String(msg, "## Launch arguments\n```\n"); iConstForEach(StringList, i, args_CommandLine(&d->args)) { - appendFormat_String(msg, "* %zu: %s\n", i.pos, cstr_String(i.value)); + appendFormat_String(msg, "%3zu : %s\n", i.pos, cstr_String(i.value)); } - appendFormat_String(msg, "## Launch commands\n"); + appendFormat_String(msg, "```\n## Launch commands\n"); iConstForEach(StringList, j, d->launchCommands) { appendFormat_String(msg, "%s\n", cstr_String(j.value)); - } + } appendFormat_String(msg, "## MIME hooks\n"); append_String(msg, debugInfo_MimeHooks(d->mimehooks)); return msg; diff --git a/src/history.c b/src/history.c index 562c23bf..202549a9 100644 --- a/src/history.c +++ b/src/history.c @@ -86,6 +86,38 @@ iHistory *copy_History(const iHistory *d) { return copy; } +iString *debugInfo_History(const iHistory *d) { + iString *str = new_String(); + format_String(str, + "```\n" + "Idx | Size | SP%% | URL\n" + "----+---------+-----+-----\n"); + size_t totalSize = 0; + iConstForEach(Array, i, &d->recent) { + const iRecentUrl *item = i.value; + appendFormat_String( + str, " %2zu | ", size_Array(&d->recent) - index_ArrayConstIterator(&i) - 1); + if (item->cachedResponse) { + appendFormat_String(str, "%7zu", size_Block(&item->cachedResponse->body)); + totalSize += size_Block(&item->cachedResponse->body); + } + else { + appendFormat_String(str, " --"); + } + appendFormat_String(str, + " | %3d | %s\n", + iRound(100.0f * item->normScrollY), + cstr_String(&item->url)); + } + appendFormat_String(str, "\n```\n"); + appendFormat_String(str, + "Total cached data: %.3f MB\n" + "Navigation position: %zu\n\n", + totalSize / 1.0e6f, + d->recentPos); + return str; +} + void serialize_History(const iHistory *d, iStream *outs) { lock_Mutex(d->mtx); writeU16_Stream(outs, d->recentPos); diff --git a/src/history.h b/src/history.h index 41005d02..4c6507e3 100644 --- a/src/history.h +++ b/src/history.h @@ -68,3 +68,5 @@ const iRecentUrl * const iGmResponse * cachedResponse_History (const iHistory *); +iString * debugInfo_History (const iHistory *); + -- cgit v1.2.3