diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-15 19:00:55 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-15 19:00:55 +0200 |
commit | ac768b3e5cce05e463b8ff97243ff13f7119844a (patch) | |
tree | 956b0238fdf668ad0524d40a991fe7335d11dda6 /src/history.c | |
parent | f60a15f58f6ec7ebc08d57eae03ec3701f807080 (diff) |
"about:debug" shows cache information
IssueID #109
Diffstat (limited to 'src/history.c')
-rw-r--r-- | src/history.c | 32 |
1 files changed, 32 insertions, 0 deletions
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) { | |||
86 | return copy; | 86 | return copy; |
87 | } | 87 | } |
88 | 88 | ||
89 | iString *debugInfo_History(const iHistory *d) { | ||
90 | iString *str = new_String(); | ||
91 | format_String(str, | ||
92 | "```\n" | ||
93 | "Idx | Size | SP%% | URL\n" | ||
94 | "----+---------+-----+-----\n"); | ||
95 | size_t totalSize = 0; | ||
96 | iConstForEach(Array, i, &d->recent) { | ||
97 | const iRecentUrl *item = i.value; | ||
98 | appendFormat_String( | ||
99 | str, " %2zu | ", size_Array(&d->recent) - index_ArrayConstIterator(&i) - 1); | ||
100 | if (item->cachedResponse) { | ||
101 | appendFormat_String(str, "%7zu", size_Block(&item->cachedResponse->body)); | ||
102 | totalSize += size_Block(&item->cachedResponse->body); | ||
103 | } | ||
104 | else { | ||
105 | appendFormat_String(str, " --"); | ||
106 | } | ||
107 | appendFormat_String(str, | ||
108 | " | %3d | %s\n", | ||
109 | iRound(100.0f * item->normScrollY), | ||
110 | cstr_String(&item->url)); | ||
111 | } | ||
112 | appendFormat_String(str, "\n```\n"); | ||
113 | appendFormat_String(str, | ||
114 | "Total cached data: %.3f MB\n" | ||
115 | "Navigation position: %zu\n\n", | ||
116 | totalSize / 1.0e6f, | ||
117 | d->recentPos); | ||
118 | return str; | ||
119 | } | ||
120 | |||
89 | void serialize_History(const iHistory *d, iStream *outs) { | 121 | void serialize_History(const iHistory *d, iStream *outs) { |
90 | lock_Mutex(d->mtx); | 122 | lock_Mutex(d->mtx); |
91 | writeU16_Stream(outs, d->recentPos); | 123 | writeU16_Stream(outs, d->recentPos); |