diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-08 19:12:15 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-08 19:12:15 +0000 |
commit | 3fd7933a5e06cc4c64bea3e61d1114cb895e3d0e (patch) | |
tree | c5edd75ad837ac0ce2f9a3cbc53a9b1d961bcfee /net/tools | |
parent | a74aa93cf049d625875d215c8cbea46313f827c5 (diff) | |
download | chromium_src-3fd7933a5e06cc4c64bea3e61d1114cb895e3d0e.zip chromium_src-3fd7933a5e06cc4c64bea3e61d1114cb895e3d0e.tar.gz chromium_src-3fd7933a5e06cc4c64bea3e61d1114cb895e3d0e.tar.bz2 |
Revert 51858 - Disk cache: Switch the disk cache to use the cache_thread.
Add an InFlightBackendIO class that handles posting of
cacheoperations back and forth between the IO thread and
the cachethread.
BUG=26730
TEST=unit tests
Review URL: http://codereview.chromium.org/2827043
TBR=rvargas@google.com
Review URL: http://codereview.chromium.org/2944002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51874 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools')
-rw-r--r-- | net/tools/crash_cache/crash_cache.cc | 30 | ||||
-rw-r--r-- | net/tools/dump_cache/upgrade.cc | 45 |
2 files changed, 17 insertions, 58 deletions
diff --git a/net/tools/crash_cache/crash_cache.cc b/net/tools/crash_cache/crash_cache.cc index 1d11013..a26c873 100644 --- a/net/tools/crash_cache/crash_cache.cc +++ b/net/tools/crash_cache/crash_cache.cc @@ -118,14 +118,6 @@ bool CreateTargetFolder(const FilePath& path, RankCrashes action, return file_util::CreateDirectory(*full_path); } -// Makes sure that any pending task is processed. -void FlushQueue(disk_cache::Backend* cache) { - TestCompletionCallback cb; - int rv = - reinterpret_cast<disk_cache::BackendImpl*>(cache)->FlushQueueForTest(&cb); - cb.GetResult(rv); // Ignore the result; -} - // Generates the files for an empty and one item cache. int SimpleInsert(const FilePath& path, RankCrashes action, base::Thread* cache_thread) { @@ -150,7 +142,6 @@ int SimpleInsert(const FilePath& path, RankCrashes action, return GENERIC; entry->Close(); - FlushQueue(cache); DCHECK(action <= disk_cache::INSERT_ONE_3); g_rankings_crash = action; @@ -171,8 +162,7 @@ int SimpleRemove(const FilePath& path, RankCrashes action, TestCompletionCallback cb; disk_cache::Backend* cache; - // Use a simple LRU for eviction. - int rv = disk_cache::CreateCacheBackend(net::MEDIA_CACHE, path, 0, false, + int rv = disk_cache::CreateCacheBackend(net::DISK_CACHE, path, 0, false, cache_thread->message_loop_proxy(), &cache, &cb); if (cb.GetResult(rv) != net::OK || cache->GetEntryCount()) @@ -184,7 +174,6 @@ int SimpleRemove(const FilePath& path, RankCrashes action, return GENERIC; entry->Close(); - FlushQueue(cache); if (action >= disk_cache::REMOVE_TAIL_1) { rv = cache->CreateEntry("some other key", &entry, &cb); @@ -192,7 +181,6 @@ int SimpleRemove(const FilePath& path, RankCrashes action, return GENERIC; entry->Close(); - FlushQueue(cache); } rv = cache->OpenEntry(kCrashEntryName, &entry, &cb); @@ -202,7 +190,6 @@ int SimpleRemove(const FilePath& path, RankCrashes action, g_rankings_crash = action; entry->Doom(); entry->Close(); - FlushQueue(cache); return NOT_REACHED; } @@ -214,8 +201,7 @@ int HeadRemove(const FilePath& path, RankCrashes action, TestCompletionCallback cb; disk_cache::Backend* cache; - // Use a simple LRU for eviction. - int rv = disk_cache::CreateCacheBackend(net::MEDIA_CACHE, path, 0, false, + int rv = disk_cache::CreateCacheBackend(net::DISK_CACHE, path, 0, false, cache_thread->message_loop_proxy(), &cache, &cb); if (cb.GetResult(rv) != net::OK || cache->GetEntryCount()) @@ -227,13 +213,11 @@ int HeadRemove(const FilePath& path, RankCrashes action, return GENERIC; entry->Close(); - FlushQueue(cache); rv = cache->CreateEntry(kCrashEntryName, &entry, &cb); if (cb.GetResult(rv) != net::OK) return GENERIC; entry->Close(); - FlushQueue(cache); rv = cache->OpenEntry(kCrashEntryName, &entry, &cb); if (cb.GetResult(rv) != net::OK) @@ -242,7 +226,6 @@ int HeadRemove(const FilePath& path, RankCrashes action, g_rankings_crash = action; entry->Doom(); entry->Close(); - FlushQueue(cache); return NOT_REACHED; } @@ -258,14 +241,14 @@ int LoadOperations(const FilePath& path, RankCrashes action, if (!cache || !cache->SetMaxSize(0x100000)) return GENERIC; - TestCompletionCallback cb; - int rv = cache->Init(&cb); - if (cb.GetResult(rv) != net::OK || cache->GetEntryCount()) + if (!cache->Init() || cache->GetEntryCount()) return GENERIC; int seed = static_cast<int>(Time::Now().ToInternalValue()); srand(seed); + TestCompletionCallback cb; + int rv; disk_cache::Entry* entry; for (int i = 0; i < 100; i++) { std::string key = GenerateKey(true); @@ -273,13 +256,11 @@ int LoadOperations(const FilePath& path, RankCrashes action, if (cb.GetResult(rv) != net::OK) return GENERIC; entry->Close(); - FlushQueue(cache); if (50 == i && action >= disk_cache::REMOVE_LOAD_1) { rv = cache->CreateEntry(kCrashEntryName, &entry, &cb); if (cb.GetResult(rv) != net::OK) return GENERIC; entry->Close(); - FlushQueue(cache); } } @@ -299,7 +280,6 @@ int LoadOperations(const FilePath& path, RankCrashes action, entry->Doom(); entry->Close(); - FlushQueue(cache); return NOT_REACHED; } diff --git a/net/tools/dump_cache/upgrade.cc b/net/tools/dump_cache/upgrade.cc index 60099b2..5a3cd67 100644 --- a/net/tools/dump_cache/upgrade.cc +++ b/net/tools/dump_cache/upgrade.cc @@ -104,8 +104,7 @@ enum { RESULT_OK = 0, RESULT_UNKNOWN_COMMAND, RESULT_INVALID_PARAMETER, - RESULT_NAME_OVERFLOW, - RESULT_PENDING // This error code is NOT expected by the master process. + RESULT_NAME_OVERFLOW }; // ----------------------------------------------------------------------- @@ -576,7 +575,6 @@ class SlaveSM : public BaseSM { void DoGetNextEntry(); void DoGetPrevEntry(); int32 GetEntryFromList(); - void DoGetEntryComplete(int result); void DoCloseEntry(); void DoGetKey(); void DoGetUseTimes(); @@ -587,19 +585,16 @@ class SlaveSM : public BaseSM { void Fail(); void* iterator_; - Message msg_; // Used for DoReadDataComplete and DoGetEntryComplete. + Message msg_; // Only used for DoReadDataComplete. net::CompletionCallbackImpl<SlaveSM> read_callback_; - net::CompletionCallbackImpl<SlaveSM> next_callback_; scoped_ptr<disk_cache::BackendImpl> cache_; }; SlaveSM::SlaveSM(const std::wstring& path, HANDLE channel) : BaseSM(channel), iterator_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST( - read_callback_(this, &SlaveSM::DoReadDataComplete)), - ALLOW_THIS_IN_INITIALIZER_LIST( - next_callback_(this, &SlaveSM::DoGetEntryComplete)) { + read_callback_(this, &SlaveSM::DoReadDataComplete)) { disk_cache::Backend* cache; TestCompletionCallback cb; int rv = disk_cache::CreateCacheBackend(net::DISK_CACHE, @@ -677,9 +672,6 @@ bool SlaveSM::DoInit() { DEBUGMSG("\t\t\tSlave DoInit\n"); DCHECK(state_ == SLAVE_INITIAL); state_ = SLAVE_WAITING; - if (!cache_.get()) - return false; - return ReceiveMsg(); } @@ -708,11 +700,6 @@ void SlaveSM::DoGetPrevEntry() { msg.result = RESULT_UNKNOWN_COMMAND; } else { msg.result = GetEntryFromList(); - if (msg.result == RESULT_PENDING) { - // We are not done yet. - msg_ = msg; - return; - } msg.long_arg1 = reinterpret_cast<int64>(entry_); } SendMsg(msg); @@ -728,31 +715,23 @@ int32 SlaveSM::GetEntryFromList() { if (entry_) entry_->Close(); - int rv; + bool ret; if (input_->msg.command == GET_NEXT_ENTRY) { - rv = cache_->OpenNextEntry(&iterator_, - reinterpret_cast<disk_cache::Entry**>(&entry_), - &next_callback_); + ret = cache_->OpenNextEntry(&iterator_, + reinterpret_cast<disk_cache::Entry**>(&entry_)); } else { DCHECK(input_->msg.command == GET_PREV_ENTRY); - rv = cache_->OpenPrevEntry(&iterator_, - reinterpret_cast<disk_cache::Entry**>(&entry_), - &next_callback_); + ret = cache_->OpenPrevEntry(&iterator_, + reinterpret_cast<disk_cache::Entry**>(&entry_)); } - DCHECK_EQ(net::ERR_IO_PENDING, rv); - return RESULT_PENDING; -} -void SlaveSM::DoGetEntryComplete(int result) { - DEBUGMSG("\t\t\tSlave DoGetEntryComplete\n"); - if (result != net::OK) { + if (!ret) entry_ = NULL; + + if (!entry_) DEBUGMSG("\t\t\tSlave end of list\n"); - } - msg_.result = RESULT_OK; - msg_.long_arg1 = reinterpret_cast<int64>(entry_); - SendMsg(msg_); + return RESULT_OK; } void SlaveSM::DoCloseEntry() { |