diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-12 23:34:12 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-12 23:34:12 +0000 |
commit | 5e5bbf409e10a1d21037eaf93a4e45af4c211575 (patch) | |
tree | 63d0186980869cb0f0be6d04202a5b0e9845d08c /net | |
parent | 7c128e7c8af54578ee98c661350853835dae8350 (diff) | |
download | chromium_src-5e5bbf409e10a1d21037eaf93a4e45af4c211575.zip chromium_src-5e5bbf409e10a1d21037eaf93a4e45af4c211575.tar.gz chromium_src-5e5bbf409e10a1d21037eaf93a4e45af4c211575.tar.bz2 |
Enhancements to the about://appcache-internals pages.
* added a new page to list the entries in a cache
* added a new page to show an entry's headers and data
BUG=none
TEST=manual
Review URL: http://codereview.chromium.org/7326023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92263 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/url_request/view_cache_helper.cc | 76 | ||||
-rw-r--r-- | net/url_request/view_cache_helper.h | 5 |
2 files changed, 44 insertions, 37 deletions
diff --git a/net/url_request/view_cache_helper.cc b/net/url_request/view_cache_helper.cc index cd722e4..c5fd1f6 100644 --- a/net/url_request/view_cache_helper.cc +++ b/net/url_request/view_cache_helper.cc @@ -24,43 +24,6 @@ namespace net { namespace { -void HexDump(const char *buf, size_t buf_len, std::string* result) { - const size_t kMaxRows = 16; - int offset = 0; - - const unsigned char *p; - while (buf_len) { - base::StringAppendF(result, "%08x: ", offset); - offset += kMaxRows; - - p = (const unsigned char *) buf; - - size_t i; - size_t row_max = std::min(kMaxRows, buf_len); - - // print hex codes: - for (i = 0; i < row_max; ++i) - base::StringAppendF(result, "%02x ", *p++); - for (i = row_max; i < kMaxRows; ++i) - result->append(" "); - - // print ASCII glyphs if possible: - p = (const unsigned char *) buf; - for (i = 0; i < row_max; ++i, ++p) { - if (*p < 0x7F && *p > 0x1F) { - AppendEscapedCharForHTML(*p, result); - } else { - result->push_back('.'); - } - } - - result->push_back('\n'); - - buf += row_max; - buf_len -= row_max; - } -} - std::string FormatEntryInfo(disk_cache::Entry* entry, const std::string& url_prefix) { std::string key = entry->GetKey(); @@ -111,6 +74,45 @@ int ViewCacheHelper::GetContentsHTML(URLRequestContext* context, return GetInfoHTML(std::string(), context, url_prefix, out, callback); } +// static +void ViewCacheHelper::HexDump(const char *buf, size_t buf_len, + std::string* result) { + const size_t kMaxRows = 16; + int offset = 0; + + const unsigned char *p; + while (buf_len) { + base::StringAppendF(result, "%08x: ", offset); + offset += kMaxRows; + + p = (const unsigned char *) buf; + + size_t i; + size_t row_max = std::min(kMaxRows, buf_len); + + // print hex codes: + for (i = 0; i < row_max; ++i) + base::StringAppendF(result, "%02x ", *p++); + for (i = row_max; i < kMaxRows; ++i) + result->append(" "); + + // print ASCII glyphs if possible: + p = (const unsigned char *) buf; + for (i = 0; i < row_max; ++i, ++p) { + if (*p < 0x7F && *p > 0x1F) { + AppendEscapedCharForHTML(*p, result); + } else { + result->push_back('.'); + } + } + + result->push_back('\n'); + + buf += row_max; + buf_len -= row_max; + } +} + //----------------------------------------------------------------------------- int ViewCacheHelper::GetInfoHTML(const std::string& key, diff --git a/net/url_request/view_cache_helper.h b/net/url_request/view_cache_helper.h index ff9d937..18979ea 100644 --- a/net/url_request/view_cache_helper.h +++ b/net/url_request/view_cache_helper.h @@ -45,6 +45,11 @@ class NET_API ViewCacheHelper { std::string* out, CompletionCallback* callback); + // Lower-level helper to produce a textual representation of binary data. + // The results are appended to |result| and can be used in HTML pages + // provided the dump is contained within <pre></pre> tags. + static void HexDump(const char *buf, size_t buf_len, std::string* result); + private: enum State { STATE_NONE, |