diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-17 21:59:39 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-17 21:59:39 +0000 |
commit | 3f73cd3125ed49700efa501a330eebc322421433 (patch) | |
tree | e1133de7529df3507f9003db310b515bdc45afac /net/tools | |
parent | a03c3d75111333c6f34ee8e6c2f3bac3208f4a13 (diff) | |
download | chromium_src-3f73cd3125ed49700efa501a330eebc322421433.zip chromium_src-3f73cd3125ed49700efa501a330eebc322421433.tar.gz chromium_src-3f73cd3125ed49700efa501a330eebc322421433.tar.bz2 |
Disk Cache: Remove deprecated methods from the disk cache interface.
BUG=26730
TEST=current tests
Review URL: http://codereview.chromium.org/2869005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50147 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools')
-rw-r--r-- | net/tools/dump_cache/cache_dumper.cc | 17 | ||||
-rw-r--r-- | net/tools/dump_cache/cache_dumper.h | 15 | ||||
-rw-r--r-- | net/tools/dump_cache/upgrade.cc | 17 |
3 files changed, 34 insertions, 15 deletions
diff --git a/net/tools/dump_cache/cache_dumper.cc b/net/tools/dump_cache/cache_dumper.cc index 71720af..f573b2a 100644 --- a/net/tools/dump_cache/cache_dumper.cc +++ b/net/tools/dump_cache/cache_dumper.cc @@ -5,15 +5,17 @@ #include "net/tools/dump_cache/cache_dumper.h" #include "net/base/io_buffer.h" +#include "net/base/net_errors.h" #include "net/disk_cache/entry_impl.h" #include "net/http/http_cache.h" #include "net/http/http_response_headers.h" #include "net/http/http_response_info.h" #include "net/tools/dump_cache/url_to_filename_encoder.h" -bool CacheDumper::CreateEntry(const std::string& key, - disk_cache::Entry** entry) { - return cache_->CreateEntry(key, entry); +int CacheDumper::CreateEntry(const std::string& key, + disk_cache::Entry** entry, + net::CompletionCallback* callback) { + return cache_->CreateEntry(key, entry, callback); } int CacheDumper::WriteEntry(disk_cache::Entry* entry, int index, int offset, @@ -61,8 +63,9 @@ bool SafeCreateDirectory(const std::wstring& path) { #endif } -bool DiskDumper::CreateEntry(const std::string& key, - disk_cache::Entry** entry) { +int DiskDumper::CreateEntry(const std::string& key, + disk_cache::Entry** entry, + net::CompletionCallback* callback) { FilePath path(path_); // The URL may not start with a valid protocol; search for it. int urlpos = key.find("http"); @@ -94,10 +97,10 @@ bool DiskDumper::CreateEntry(const std::string& key, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if (entry_ == INVALID_HANDLE_VALUE) wprintf(L"CreateFileW (%s) failed: %d\n", file.c_str(), GetLastError()); - return entry_ != INVALID_HANDLE_VALUE; + return (entry_ != INVALID_HANDLE_VALUE) ? net::OK : net::ERR_FAILED; #else entry_ = file_util::OpenFile(entry_path_, "w+"); - return entry_ != NULL; + return (entry_ != NULL) ? net::OK : net::ERR_FAILED; #endif } diff --git a/net/tools/dump_cache/cache_dumper.h b/net/tools/dump_cache/cache_dumper.h index 1af8573..d2e6034 100644 --- a/net/tools/dump_cache/cache_dumper.h +++ b/net/tools/dump_cache/cache_dumper.h @@ -26,12 +26,13 @@ class CacheDumpWriter { // Creates an entry to be written. // On success, populates the |entry|. - // Returns true on success, false otherwise. - virtual bool CreateEntry(const std::string& key, - disk_cache::Entry** entry) = 0; + // Returns a net error code. + virtual int CreateEntry(const std::string& key, + disk_cache::Entry** entry, + net::CompletionCallback* callback) = 0; // Write to the current entry. - // Returns true on success, false otherwise. + // Returns a net error code. virtual int WriteEntry(disk_cache::Entry* entry, int stream, int offset, net::IOBuffer* buf, int buf_len, net::CompletionCallback* callback) = 0; @@ -46,7 +47,8 @@ class CacheDumper : public CacheDumpWriter { public: explicit CacheDumper(disk_cache::Backend* cache) : cache_(cache) {} - virtual bool CreateEntry(const std::string& key, disk_cache::Entry** entry); + virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry, + net::CompletionCallback* callback); virtual int WriteEntry(disk_cache::Entry* entry, int stream, int offset, net::IOBuffer* buf, int buf_len, net::CompletionCallback* callback); @@ -63,7 +65,8 @@ class DiskDumper : public CacheDumpWriter { explicit DiskDumper(const std::wstring& path) : path_(path), entry_(NULL) { file_util::CreateDirectory(FilePath(path)); } - virtual bool CreateEntry(const std::string& key, disk_cache::Entry** entry); + virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry, + net::CompletionCallback* callback); virtual int WriteEntry(disk_cache::Entry* entry, int stream, int offset, net::IOBuffer* buf, int buf_len, net::CompletionCallback* callback); diff --git a/net/tools/dump_cache/upgrade.cc b/net/tools/dump_cache/upgrade.cc index 4f565fe..5a3cd67 100644 --- a/net/tools/dump_cache/upgrade.cc +++ b/net/tools/dump_cache/upgrade.cc @@ -210,6 +210,8 @@ class MasterSM : public BaseSM { MasterSM(const std::wstring& path, HANDLE channel, bool dump_to_disk) : BaseSM(channel), path_(path), dump_to_disk_(dump_to_disk), ALLOW_THIS_IN_INITIALIZER_LIST( + create_callback_(this, &MasterSM::DoCreateEntryComplete)), + ALLOW_THIS_IN_INITIALIZER_LIST( write_callback_(this, &MasterSM::DoReadDataComplete)) { } virtual ~MasterSM() { @@ -236,6 +238,7 @@ class MasterSM : public BaseSM { void SendGetPrevEntry(); void DoGetEntry(); void DoGetKey(int bytes_read); + void DoCreateEntryComplete(int result); void DoGetUseTimes(); void SendGetDataSize(); void DoGetDataSize(); @@ -259,6 +262,7 @@ class MasterSM : public BaseSM { CacheDumpWriter* writer_; const std::wstring& path_; bool dump_to_disk_; + net::CompletionCallbackImpl<MasterSM> create_callback_; net::CompletionCallbackImpl<MasterSM> write_callback_; }; @@ -388,8 +392,17 @@ void MasterSM::DoGetKey(int bytes_read) { std::string key(input_->buffer); DCHECK(key.size() == static_cast<size_t>(input_->msg.buffer_bytes - 1)); - if (!writer_->CreateEntry(key, - reinterpret_cast<disk_cache::Entry**>(&entry_))) { + int rv = writer_->CreateEntry(key, + reinterpret_cast<disk_cache::Entry**>(&entry_), + &create_callback_); + + if (rv != net::ERR_IO_PENDING) + DoCreateEntryComplete(rv); +} + +void MasterSM::DoCreateEntryComplete(int result) { + std::string key(input_->buffer); + if (result != net::OK) { printf("Skipping entry \"%s\": %d\n", key.c_str(), GetLastError()); return SendGetPrevEntry(); } |