summaryrefslogtreecommitdiffstats
path: root/net/tools/dump_cache/upgrade.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-03 23:55:52 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-03 23:55:52 +0000
commit8333732ae08ccab0bd9d3916dc4796c1b35800a2 (patch)
tree8dac1e8c05ff781df504556c0e20e0718806717b /net/tools/dump_cache/upgrade.cc
parentf253006b157f9c917fba21a7312290aaa2e889e7 (diff)
downloadchromium_src-8333732ae08ccab0bd9d3916dc4796c1b35800a2.zip
chromium_src-8333732ae08ccab0bd9d3916dc4796c1b35800a2.tar.gz
chromium_src-8333732ae08ccab0bd9d3916dc4796c1b35800a2.tar.bz2
upgrade cache tool: Improve the handling of errors so that
we ignore as much as possible without aborting the whole process. R=nsylvain Review URL: http://codereview.chromium.org/12925 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6334 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools/dump_cache/upgrade.cc')
-rw-r--r--net/tools/dump_cache/upgrade.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/net/tools/dump_cache/upgrade.cc b/net/tools/dump_cache/upgrade.cc
index 1495b95..c715f14 100644
--- a/net/tools/dump_cache/upgrade.cc
+++ b/net/tools/dump_cache/upgrade.cc
@@ -331,17 +331,22 @@ void MasterSM::DoGetKey(int bytes_read) {
DEBUGMSG("Master DoGetKey\n");
DCHECK(state_ == MASTER_GET_KEY);
DCHECK(input_->msg.command == GET_KEY);
- if (input_->msg.result == RESULT_NAME_OVERFLOW)
+ if (input_->msg.result == RESULT_NAME_OVERFLOW) {
// The key is too long. Just move on.
+ printf("Skipping entry (name too long)\n");
return SendGetPrevEntry();
+ }
if (input_->msg.result != RESULT_OK)
return Fail();
std::string key(input_->buffer);
DCHECK(key.size() == input_->msg.buffer_bytes - 1);
- if (!cache_->CreateEntry(key, reinterpret_cast<disk_cache::Entry**>(&entry_)))
- return Fail();
+ if (!cache_->CreateEntry(key,
+ reinterpret_cast<disk_cache::Entry**>(&entry_))) {
+ printf("Skipping entry \"%s\" (name conflict!)\n", key.c_str());
+ return SendGetPrevEntry();
+ }
if (key.size() < 60) {
DEBUGMSG("Entry \"%s\" created\n", key.c_str());
@@ -433,6 +438,12 @@ void MasterSM::DoReadData(int bytes_read) {
return Fail();
int read_size = input_->msg.buffer_bytes;
+ if (!read_size) {
+ printf("Read failed, entry \"%s\" truncated!\n", entry_->GetKey().c_str());
+ bytes_remaining_ = 0;
+ return SendReadData();
+ }
+
if (read_size != entry_->WriteData(stream_, offset_, input_->buffer,
read_size, NULL, false))
return Fail();