diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-07 00:39:04 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-07 00:39:04 +0000 |
commit | a6ec0897e904792a60a12a58b26dd2214dbcfa39 (patch) | |
tree | c0040197acf7510b074af818ef8335b832e22e25 /net/disk_cache | |
parent | 1b4209f4c56fbdb6fe72aca508e8aa1c534964d4 (diff) | |
download | chromium_src-a6ec0897e904792a60a12a58b26dd2214dbcfa39.zip chromium_src-a6ec0897e904792a60a12a58b26dd2214dbcfa39.tar.gz chromium_src-a6ec0897e904792a60a12a58b26dd2214dbcfa39.tar.bz2 |
Revert r70628. It broke Linux valgrind bots. See for example
http://build.chromium.org/p/chromium.memory/builders/Linux%20Tests%20%28valgrind%29%281%29/builds/963
First pass at adding http/backend cache events to the NetLog.
Adds sources and events for ActiveCacheEntry and EntryImpl
objects, as well as adding cache read/write events to
HttpCacheTransactions. Most new read/write events are
only logged when NetLog logging mode is set to log all events.
Also, net-internals now merges begin and end events that have
parameters, as long as only one of them has parameters.
I think this increases readability, at the cost of making
it a little more difficult to follow timings with just the "st"
values.
BUG=59382
TEST=none yet, other than updates to existing tests.
Originally applied: http://src.chromium.org/viewvc/chrome?view=rev&revision=70618
Reverted: http://src.chromium.org/viewvc/chrome?view=rev&revision=70619
Fixed and trying again...
Review URL: http://codereview.chromium.org/6125001
BUG=none
TEST=linux valgrind goes green.
Review URL: http://codereview.chromium.org/6142003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70688 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r-- | net/disk_cache/backend_impl.cc | 29 | ||||
-rw-r--r-- | net/disk_cache/backend_impl.h | 14 | ||||
-rw-r--r-- | net/disk_cache/backend_unittest.cc | 22 | ||||
-rw-r--r-- | net/disk_cache/disk_cache.h | 4 | ||||
-rw-r--r-- | net/disk_cache/disk_cache_perftest.cc | 4 | ||||
-rw-r--r-- | net/disk_cache/disk_cache_test_base.cc | 6 | ||||
-rw-r--r-- | net/disk_cache/disk_cache_test_util.cc | 2 | ||||
-rw-r--r-- | net/disk_cache/entry_impl.cc | 165 | ||||
-rw-r--r-- | net/disk_cache/entry_impl.h | 18 | ||||
-rw-r--r-- | net/disk_cache/sparse_control.cc | 53 | ||||
-rw-r--r-- | net/disk_cache/stress_cache.cc | 2 |
11 files changed, 41 insertions, 278 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc index 223c970..58a6e9e 100644 --- a/net/disk_cache/backend_impl.cc +++ b/net/disk_cache/backend_impl.cc @@ -194,12 +194,11 @@ class CacheCreator { public: CacheCreator(const FilePath& path, bool force, int max_bytes, net::CacheType type, uint32 flags, - base::MessageLoopProxy* thread, net::NetLog* net_log, - disk_cache::Backend** backend, + base::MessageLoopProxy* thread, disk_cache::Backend** backend, net::CompletionCallback* callback) : path_(path), force_(force), retry_(false), max_bytes_(max_bytes), type_(type), flags_(flags), thread_(thread), backend_(backend), - callback_(callback), cache_(NULL), net_log_(net_log), + callback_(callback), cache_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST( my_callback_(this, &CacheCreator::OnIOComplete)) { } @@ -224,14 +223,13 @@ class CacheCreator { disk_cache::Backend** backend_; net::CompletionCallback* callback_; disk_cache::BackendImpl* cache_; - net::NetLog* net_log_; net::CompletionCallbackImpl<CacheCreator> my_callback_; DISALLOW_COPY_AND_ASSIGN(CacheCreator); }; int CacheCreator::Run() { - cache_ = new disk_cache::BackendImpl(path_, thread_, net_log_); + cache_ = new disk_cache::BackendImpl(path_, thread_); cache_->SetMaxSize(max_bytes_); cache_->SetType(type_); cache_->SetFlags(flags_); @@ -297,8 +295,7 @@ namespace disk_cache { int CreateCacheBackend(net::CacheType type, const FilePath& path, int max_bytes, bool force, base::MessageLoopProxy* thread, - net::NetLog* net_log, Backend** backend, - CompletionCallback* callback) { + Backend** backend, CompletionCallback* callback) { DCHECK(callback); if (type == net::MEMORY_CACHE) { *backend = MemBackendImpl::CreateBackend(max_bytes); @@ -307,7 +304,7 @@ int CreateCacheBackend(net::CacheType type, const FilePath& path, int max_bytes, DCHECK(thread); return BackendImpl::CreateBackend(path, force, max_bytes, type, kNone, thread, - net_log, backend, callback); + backend, callback); } // Returns the preferred maximum number of bytes for the cache given the @@ -354,12 +351,11 @@ int PreferedCacheSize(int64 available) { int BackendImpl::CreateBackend(const FilePath& full_path, bool force, int max_bytes, net::CacheType type, uint32 flags, base::MessageLoopProxy* thread, - net::NetLog* net_log, Backend** backend, + Backend** backend, CompletionCallback* callback) { DCHECK(callback); CacheCreator* creator = new CacheCreator(full_path, force, max_bytes, type, - flags, thread, net_log, backend, - callback); + flags, thread, backend, callback); // This object will self-destroy when finished. return creator->Run(); } @@ -370,8 +366,7 @@ int BackendImpl::Init(CompletionCallback* callback) { } BackendImpl::BackendImpl(const FilePath& path, - base::MessageLoopProxy* cache_thread, - net::NetLog* net_log) + base::MessageLoopProxy* cache_thread) : ALLOW_THIS_IN_INITIALIZER_LIST(background_queue_(this, cache_thread)), path_(path), block_files_(path), @@ -388,7 +383,6 @@ BackendImpl::BackendImpl(const FilePath& path, new_eviction_(false), first_timer_(true), throttle_requests_(false), - net_log_(net_log), done_(true, false), ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(ptr_factory_(this)) { @@ -396,8 +390,7 @@ BackendImpl::BackendImpl(const FilePath& path, BackendImpl::BackendImpl(const FilePath& path, uint32 mask, - base::MessageLoopProxy* cache_thread, - net::NetLog* net_log) + base::MessageLoopProxy* cache_thread) : ALLOW_THIS_IN_INITIALIZER_LIST(background_queue_(this, cache_thread)), path_(path), block_files_(path), @@ -414,7 +407,6 @@ BackendImpl::BackendImpl(const FilePath& path, new_eviction_(false), first_timer_(true), throttle_requests_(false), - net_log_(net_log), done_(true, false), ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(ptr_factory_(this)) { @@ -856,8 +848,6 @@ EntryImpl* BackendImpl::CreateEntryImpl(const std::string& key) { return NULL; } - cache_entry->BeginLogging(net_log_, true); - // We are not failing the operation; let's add this to the map. open_entries_[entry_address.value()] = cache_entry; @@ -1547,7 +1537,6 @@ int BackendImpl::NewEntry(Addr address, EntryImpl** entry, bool* dirty) { open_entries_[address.value()] = cache_entry; } - cache_entry->BeginLogging(net_log_, false); cache_entry.swap(entry); return 0; } diff --git a/net/disk_cache/backend_impl.h b/net/disk_cache/backend_impl.h index b481525..5637fbd 100644 --- a/net/disk_cache/backend_impl.h +++ b/net/disk_cache/backend_impl.h @@ -19,10 +19,6 @@ #include "net/disk_cache/stats.h" #include "net/disk_cache/trace.h" -namespace net { -class NetLog; -} // namespace net - namespace disk_cache { enum BackendFlags { @@ -42,11 +38,10 @@ enum BackendFlags { class BackendImpl : public Backend { friend class Eviction; public: - BackendImpl(const FilePath& path, base::MessageLoopProxy* cache_thread, - net::NetLog* net_log); + BackendImpl(const FilePath& path, base::MessageLoopProxy* cache_thread); // mask can be used to limit the usable size of the hash table, for testing. BackendImpl(const FilePath& path, uint32 mask, - base::MessageLoopProxy* cache_thread, net::NetLog* net_log); + base::MessageLoopProxy* cache_thread); ~BackendImpl(); // Returns a new backend with the desired flags. See the declaration of @@ -54,8 +49,7 @@ class BackendImpl : public Backend { static int CreateBackend(const FilePath& full_path, bool force, int max_bytes, net::CacheType type, uint32 flags, base::MessageLoopProxy* thread, - net::NetLog* net_log, Backend** backend, - CompletionCallback* callback); + Backend** backend, CompletionCallback* callback); // Performs general initialization for this current instance of the cache. int Init(CompletionCallback* callback); @@ -363,8 +357,6 @@ class BackendImpl : public Backend { bool first_timer_; // True if the timer has not been called. bool throttle_requests_; - net::NetLog* net_log_; - Stats stats_; // Usage statistcs. base::RepeatingTimer<BackendImpl> timer_; // Usage timer. base::WaitableEvent done_; // Signals the end of background work. diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc index eaa00eb..9077996 100644 --- a/net/disk_cache/backend_unittest.cc +++ b/net/disk_cache/backend_unittest.cc @@ -195,7 +195,7 @@ TEST_F(DiskCacheTest, CreateBackend) { disk_cache::Backend* cache = NULL; int rv = disk_cache::BackendImpl::CreateBackend( path, false, 0, net::DISK_CACHE, disk_cache::kNoRandom, - cache_thread.message_loop_proxy(), NULL, &cache, &cb); + cache_thread.message_loop_proxy(), &cache, &cb); ASSERT_EQ(net::OK, cb.GetResult(rv)); ASSERT_TRUE(cache); delete cache; @@ -208,14 +208,14 @@ TEST_F(DiskCacheTest, CreateBackend) { // Now test the public API. rv = disk_cache::CreateCacheBackend(net::DISK_CACHE, path, 0, false, cache_thread.message_loop_proxy(), - NULL, &cache, &cb); + &cache, &cb); ASSERT_EQ(net::OK, cb.GetResult(rv)); ASSERT_TRUE(cache); delete cache; cache = NULL; rv = disk_cache::CreateCacheBackend(net::MEMORY_CACHE, FilePath(), 0, false, - NULL, NULL, &cache, &cb); + NULL, &cache, &cb); ASSERT_EQ(net::OK, cb.GetResult(rv)); ASSERT_TRUE(cache); delete cache; @@ -260,8 +260,7 @@ TEST_F(DiskCacheTest, ShutdownWithPendingIO) { disk_cache::Backend* cache; int rv = disk_cache::BackendImpl::CreateBackend( path, false, 0, net::DISK_CACHE, disk_cache::kNoRandom, - base::MessageLoopProxy::CreateForCurrentThread(), NULL, - &cache, &cb); + base::MessageLoopProxy::CreateForCurrentThread(), &cache, &cb); ASSERT_EQ(net::OK, cb.GetResult(rv)); disk_cache::EntryImpl* entry; @@ -312,7 +311,7 @@ TEST_F(DiskCacheTest, ShutdownWithPendingIO2) { disk_cache::Backend* cache; int rv = disk_cache::BackendImpl::CreateBackend( path, false, 0, net::DISK_CACHE, disk_cache::kNoRandom, - cache_thread.message_loop_proxy(), NULL, &cache, &cb); + cache_thread.message_loop_proxy(), &cache, &cb); ASSERT_EQ(net::OK, cb.GetResult(rv)); disk_cache::Entry* entry; @@ -349,7 +348,7 @@ TEST_F(DiskCacheTest, TruncatedIndex) { disk_cache::Backend* backend = NULL; int rv = disk_cache::BackendImpl::CreateBackend( path, false, 0, net::DISK_CACHE, disk_cache::kNone, - cache_thread.message_loop_proxy(), NULL, &backend, &cb); + cache_thread.message_loop_proxy(), &backend, &cb); ASSERT_NE(net::OK, cb.GetResult(rv)); ASSERT_TRUE(backend == NULL); @@ -1279,7 +1278,7 @@ TEST_F(DiskCacheTest, DeleteOld) { disk_cache::Backend* cache; int rv = disk_cache::BackendImpl::CreateBackend( path, true, 0, net::DISK_CACHE, disk_cache::kNoRandom, - cache_thread.message_loop_proxy(), NULL, &cache, &cb); + cache_thread.message_loop_proxy(), &cache, &cb); ASSERT_EQ(net::OK, cb.GetResult(rv)); MessageLoopHelper helper; @@ -1652,8 +1651,7 @@ TEST_F(DiskCacheTest, Backend_UsageStats) { ASSERT_TRUE(DeleteCache(path)); scoped_ptr<disk_cache::BackendImpl> cache; cache.reset(new disk_cache::BackendImpl( - path, base::MessageLoopProxy::CreateForCurrentThread(), - NULL)); + path, base::MessageLoopProxy::CreateForCurrentThread())); ASSERT_TRUE(NULL != cache.get()); cache->SetUnitTestMode(); ASSERT_EQ(net::OK, cache->SyncInit()); @@ -1771,11 +1769,11 @@ TEST_F(DiskCacheTest, MultipleInstances) { int rv = disk_cache::BackendImpl::CreateBackend( store1.path(), false, 0, net::DISK_CACHE, disk_cache::kNone, - cache_thread.message_loop_proxy(), NULL, &cache[0], &cb); + cache_thread.message_loop_proxy(), &cache[0], &cb); ASSERT_EQ(net::OK, cb.GetResult(rv)); rv = disk_cache::BackendImpl::CreateBackend( store2.path(), false, 0, net::MEDIA_CACHE, disk_cache::kNone, - cache_thread.message_loop_proxy(), NULL, &cache[1], &cb); + cache_thread.message_loop_proxy(), &cache[1], &cb); ASSERT_EQ(net::OK, cb.GetResult(rv)); ASSERT_TRUE(cache[0] != NULL && cache[1] != NULL); diff --git a/net/disk_cache/disk_cache.h b/net/disk_cache/disk_cache.h index 18dd447..59efe06 100644 --- a/net/disk_cache/disk_cache.h +++ b/net/disk_cache/disk_cache.h @@ -25,7 +25,6 @@ class MessageLoopProxy; namespace net { class IOBuffer; -class NetLog; } namespace disk_cache { @@ -51,8 +50,7 @@ typedef net::CompletionCallback CompletionCallback; // completes (the callback is notified). int CreateCacheBackend(net::CacheType type, const FilePath& path, int max_bytes, bool force, base::MessageLoopProxy* thread, - net::NetLog* net_log, Backend** backend, - CompletionCallback* callback); + Backend** backend, CompletionCallback* callback); // The root interface for a disk cache instance. class Backend { diff --git a/net/disk_cache/disk_cache_perftest.cc b/net/disk_cache/disk_cache_perftest.cc index 14f15c6..241fc04 100644 --- a/net/disk_cache/disk_cache_perftest.cc +++ b/net/disk_cache/disk_cache_perftest.cc @@ -169,7 +169,7 @@ TEST_F(DiskCacheTest, CacheBackendPerformance) { disk_cache::Backend* cache; int rv = disk_cache::CreateCacheBackend( net::DISK_CACHE, test_cache.path(), 0, false, - cache_thread.message_loop_proxy(), NULL, &cache, &cb); + cache_thread.message_loop_proxy(), &cache, &cb); ASSERT_EQ(net::OK, cb.GetResult(rv)); @@ -198,7 +198,7 @@ TEST_F(DiskCacheTest, CacheBackendPerformance) { rv = disk_cache::CreateCacheBackend(net::DISK_CACHE, test_cache.path(), 0, false, cache_thread.message_loop_proxy(), - NULL, &cache, &cb); + &cache, &cb); ASSERT_EQ(net::OK, cb.GetResult(rv)); ret = TimeRead(num_entries, cache, entries, true); diff --git a/net/disk_cache/disk_cache_test_base.cc b/net/disk_cache/disk_cache_test_base.cc index 6c9b91c..cffe3fa 100644 --- a/net/disk_cache/disk_cache_test_base.cc +++ b/net/disk_cache/disk_cache_test_base.cc @@ -75,7 +75,7 @@ void DiskCacheTestWithCache::InitDiskCache() { TestCompletionCallback cb; int rv = disk_cache::BackendImpl::CreateBackend( path, force_creation_, size_, type_, - disk_cache::kNoRandom, thread, NULL, &cache_, &cb); + disk_cache::kNoRandom, thread, &cache_, &cb); ASSERT_EQ(net::OK, cb.GetResult(rv)); } @@ -84,9 +84,9 @@ void DiskCacheTestWithCache::InitDiskCacheImpl(const FilePath& path) { use_current_thread_ ? base::MessageLoopProxy::CreateForCurrentThread() : cache_thread_.message_loop_proxy(); if (mask_) - cache_impl_ = new disk_cache::BackendImpl(path, mask_, thread, NULL); + cache_impl_ = new disk_cache::BackendImpl(path, mask_, thread); else - cache_impl_ = new disk_cache::BackendImpl(path, thread, NULL); + cache_impl_ = new disk_cache::BackendImpl(path, thread); cache_ = cache_impl_; ASSERT_TRUE(NULL != cache_); diff --git a/net/disk_cache/disk_cache_test_util.cc b/net/disk_cache/disk_cache_test_util.cc index ed16db0..76690e6 100644 --- a/net/disk_cache/disk_cache_test_util.cc +++ b/net/disk_cache/disk_cache_test_util.cc @@ -94,7 +94,7 @@ bool CopyTestCache(const std::string& name) { bool CheckCacheIntegrity(const FilePath& path, bool new_eviction) { scoped_ptr<disk_cache::BackendImpl> cache(new disk_cache::BackendImpl( - path, base::MessageLoopProxy::CreateForCurrentThread(), NULL)); + path, base::MessageLoopProxy::CreateForCurrentThread())); if (!cache.get()) return false; if (new_eviction) diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc index 3cb895f..e5e6482 100644 --- a/net/disk_cache/entry_impl.cc +++ b/net/disk_cache/entry_impl.cc @@ -7,7 +7,6 @@ #include "base/message_loop.h" #include "base/metrics/histogram.h" #include "base/string_util.h" -#include "base/values.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "net/disk_cache/backend_impl.h" @@ -25,93 +24,14 @@ namespace { // Index for the file used to store the key, if any (files_[kKeyFileIndex]). const int kKeyFileIndex = 3; -// NetLog parameters for the creation of an EntryImpl. Contains an entry's name -// and whether it was created or opened. -class EntryCreationParameters : public net::NetLog::EventParameters { - public: - EntryCreationParameters(const std::string& key, bool created) - : key_(key), created_(created) { - } - - Value* ToValue() const { - DictionaryValue* dict = new DictionaryValue(); - dict->SetString("key", key_); - dict->SetBoolean("created", created_); - return dict; - } - - private: - const std::string key_; - const bool created_; - - DISALLOW_COPY_AND_ASSIGN(EntryCreationParameters); -}; - -// NetLog parameters for non-sparse reading and writing to an EntryImpl. -class ReadWriteDataParams : public net::NetLog::EventParameters { - public: - // For reads, |truncate| must be false. - ReadWriteDataParams(int index, int offset, int buf_len, bool truncate) - : index_(index), offset_(offset), buf_len_(buf_len), truncate_(truncate) { - } - - Value* ToValue() const { - DictionaryValue* dict = new DictionaryValue(); - dict->SetInteger("index", index_); - dict->SetInteger("offset", offset_); - dict->SetInteger("buf_len", buf_len_); - if (truncate_) - dict->SetBoolean("truncate", truncate_); - return dict; - } - - private: - const int index_; - const int offset_; - const int buf_len_; - const bool truncate_; - - DISALLOW_COPY_AND_ASSIGN(ReadWriteDataParams); -}; - -// NetLog parameters logged when non-sparse reads and writes complete. -class FileIOCompleteParameters : public net::NetLog::EventParameters { - public: - // |bytes_copied| is either the number of bytes copied or a network error - // code. |bytes_copied| must not be ERR_IO_PENDING, as it's not a valid - // result for an operation. - explicit FileIOCompleteParameters(int bytes_copied) - : bytes_copied_(bytes_copied) { - } - - Value* ToValue() const { - DCHECK_NE(bytes_copied_, net::ERR_IO_PENDING); - DictionaryValue* dict = new DictionaryValue(); - if (bytes_copied_ < 0) { - dict->SetInteger("net_error", bytes_copied_); - } else { - dict->SetInteger("bytes_copied", bytes_copied_); - } - return dict; - } - - private: - const int bytes_copied_; - - DISALLOW_COPY_AND_ASSIGN(FileIOCompleteParameters); -}; - // This class implements FileIOCallback to buffer the callback from a file IO // operation from the actual net class. class SyncCallback: public disk_cache::FileIOCallback { public: - // |end_event_type| is the event type to log on completion. Logs nothing on - // discard, or when the NetLog is not set to log all events. SyncCallback(disk_cache::EntryImpl* entry, net::IOBuffer* buffer, - net::CompletionCallback* callback, - net::NetLog::EventType end_event_type) + net::CompletionCallback* callback ) : entry_(entry), callback_(callback), buf_(buffer), - start_(TimeTicks::Now()), end_event_type_(end_event_type) { + start_(TimeTicks::Now()) { entry->AddRef(); entry->IncrementIoCount(); } @@ -119,13 +39,11 @@ class SyncCallback: public disk_cache::FileIOCallback { virtual void OnFileIOComplete(int bytes_copied); void Discard(); - private: disk_cache::EntryImpl* entry_; net::CompletionCallback* callback_; scoped_refptr<net::IOBuffer> buf_; TimeTicks start_; - net::NetLog::EventType end_event_type_; DISALLOW_COPY_AND_ASSIGN(SyncCallback); }; @@ -133,11 +51,6 @@ class SyncCallback: public disk_cache::FileIOCallback { void SyncCallback::OnFileIOComplete(int bytes_copied) { entry_->DecrementIoCount(); if (callback_) { - if (entry_->net_log().IsLoggingAllEvents()) { - entry_->net_log().EndEvent( - end_event_type_, - make_scoped_refptr(new FileIOCompleteParameters(bytes_copied))); - } entry_->ReportIOTime(disk_cache::EntryImpl::kAsyncIO, start_); callback_->Run(bytes_copied); } @@ -395,7 +308,6 @@ EntryImpl::~EntryImpl() { if (doomed_) { DeleteEntryData(true); } else { - net_log_.AddEvent(net::NetLog::TYPE_DISK_CACHE_CLOSE, NULL); bool ret = true; for (int index = 0; index < kNumStreams; index++) { if (user_buffers_[index].get()) { @@ -421,7 +333,6 @@ EntryImpl::~EntryImpl() { } Trace("~EntryImpl out 0x%p", reinterpret_cast<void*>(this)); - net_log_.EndEvent(net::NetLog::TYPE_DISK_CACHE_ENTRY, NULL); backend_->OnEntryDestroyEnd(); } @@ -576,46 +487,6 @@ void EntryImpl::DoomImpl() { int EntryImpl::ReadDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, CompletionCallback* callback) { - if (net_log_.IsLoggingAllEvents()) { - net_log_.BeginEvent( - net::NetLog::TYPE_DISK_CACHE_READ_DATA, - make_scoped_refptr( - new ReadWriteDataParams(index, offset, buf_len, false))); - } - - int result = InternalReadData(index, offset, buf, buf_len, callback); - - if (result != net::ERR_IO_PENDING && net_log_.IsLoggingAllEvents()) { - net_log_.EndEvent( - net::NetLog::TYPE_DISK_CACHE_READ_DATA, - make_scoped_refptr(new FileIOCompleteParameters(result))); - } - return result; -} - -int EntryImpl::WriteDataImpl(int index, int offset, net::IOBuffer* buf, - int buf_len, CompletionCallback* callback, - bool truncate) { - if (net_log_.IsLoggingAllEvents()) { - net_log_.BeginEvent( - net::NetLog::TYPE_DISK_CACHE_WRITE_DATA, - make_scoped_refptr( - new ReadWriteDataParams(index, offset, buf_len, truncate))); - } - - int result = InternalWriteData(index, offset, buf, buf_len, callback, - truncate); - - if (result != net::ERR_IO_PENDING && net_log_.IsLoggingAllEvents()) { - net_log_.EndEvent( - net::NetLog::TYPE_DISK_CACHE_WRITE_DATA, - make_scoped_refptr(new FileIOCompleteParameters(result))); - } - return result; -} - -int EntryImpl::InternalReadData(int index, int offset, net::IOBuffer* buf, - int buf_len, CompletionCallback* callback) { DCHECK(node_.Data()->dirty || read_only_); DVLOG(2) << "Read from " << index << " at " << offset << " : " << buf_len; if (index < 0 || index >= kNumStreams) @@ -665,10 +536,8 @@ int EntryImpl::InternalReadData(int index, int offset, net::IOBuffer* buf, } SyncCallback* io_callback = NULL; - if (callback) { - io_callback = new SyncCallback(this, buf, callback, - net::NetLog::TYPE_DISK_CACHE_READ_DATA); - } + if (callback) + io_callback = new SyncCallback(this, buf, callback); bool completed; if (!file->Read(buf->data(), buf_len, file_offset, io_callback, &completed)) { @@ -684,9 +553,9 @@ int EntryImpl::InternalReadData(int index, int offset, net::IOBuffer* buf, return (completed || !callback) ? buf_len : net::ERR_IO_PENDING; } -int EntryImpl::InternalWriteData(int index, int offset, net::IOBuffer* buf, - int buf_len, CompletionCallback* callback, - bool truncate) { +int EntryImpl::WriteDataImpl(int index, int offset, net::IOBuffer* buf, + int buf_len, CompletionCallback* callback, + bool truncate) { DCHECK(node_.Data()->dirty || read_only_); DVLOG(2) << "Write to " << index << " at " << offset << " : " << buf_len; if (index < 0 || index >= kNumStreams) @@ -759,10 +628,8 @@ int EntryImpl::InternalWriteData(int index, int offset, net::IOBuffer* buf, return 0; SyncCallback* io_callback = NULL; - if (callback) { - io_callback = new SyncCallback(this, buf, callback, - net::NetLog::TYPE_DISK_CACHE_WRITE_DATA); - } + if (callback) + io_callback = new SyncCallback(this, buf, callback); bool completed; if (!file->Write(buf->data(), buf_len, file_offset, io_callback, @@ -890,7 +757,6 @@ bool EntryImpl::IsSameEntry(const std::string& key, uint32 hash) { } void EntryImpl::InternalDoom() { - net_log_.AddEvent(net::NetLog::TYPE_DISK_CACHE_DOOM, NULL); DCHECK(node_.HasData()); if (!node_.Data()->dirty) { node_.Data()->dirty = backend_->GetCurrentEntryId(); @@ -1048,19 +914,6 @@ void EntryImpl::ReportIOTime(Operation op, const base::TimeTicks& start) { } } -void EntryImpl::BeginLogging(net::NetLog* net_log, bool created) { - DCHECK(!net_log_.net_log()); - net_log_ = net::BoundNetLog::Make( - net_log, net::NetLog::SOURCE_DISK_CACHE_ENTRY); - net_log_.BeginEvent( - net::NetLog::TYPE_DISK_CACHE_ENTRY, - make_scoped_refptr(new EntryCreationParameters(GetKey(), created))); -} - -const net::BoundNetLog& EntryImpl::net_log() const { - return net_log_; -} - // ------------------------------------------------------------------------ bool EntryImpl::CreateDataBlock(int index, int size) { diff --git a/net/disk_cache/entry_impl.h b/net/disk_cache/entry_impl.h index d24e861..e27f23a 100644 --- a/net/disk_cache/entry_impl.h +++ b/net/disk_cache/entry_impl.h @@ -7,7 +7,6 @@ #pragma once #include "base/scoped_ptr.h" -#include "net/base/net_log.h" #include "net/disk_cache/disk_cache.h" #include "net/disk_cache/storage_block.h" #include "net/disk_cache/storage_block-inl.h" @@ -130,14 +129,6 @@ class EntryImpl : public Entry, public base::RefCounted<EntryImpl> { // Generates a histogram for the time spent working on this operation. void ReportIOTime(Operation op, const base::TimeTicks& start); - // Logs a begin event and enables logging for the EntryImpl. Will also cause - // an end event to be logged on destruction. The EntryImpl must have its key - // initialized before this is called. |created| is true if the Entry was - // created rather than opened. - void BeginLogging(net::NetLog* net_log, bool created); - - const net::BoundNetLog& net_log() const; - private: enum { kNumStreams = 3 @@ -146,13 +137,6 @@ class EntryImpl : public Entry, public base::RefCounted<EntryImpl> { ~EntryImpl(); - // Do all the work for ReadDataImpl and WriteDataImpl. Implemented as - // separate functions to make logging of results simpler. - int InternalReadData(int index, int offset, net::IOBuffer* buf, - int buf_len, CompletionCallback* callback); - int InternalWriteData(int index, int offset, net::IOBuffer* buf, int buf_len, - CompletionCallback* callback, bool truncate); - // Initializes the storage for an internal or external data block. bool CreateDataBlock(int index, int size); @@ -236,8 +220,6 @@ class EntryImpl : public Entry, public base::RefCounted<EntryImpl> { bool read_only_; // True if not yet writing. scoped_ptr<SparseControl> sparse_; // Support for sparse entries. - net::BoundNetLog net_log_; - DISALLOW_COPY_AND_ASSIGN(EntryImpl); }; diff --git a/net/disk_cache/sparse_control.cc b/net/disk_cache/sparse_control.cc index ebc8250..32f44ab 100644 --- a/net/disk_cache/sparse_control.cc +++ b/net/disk_cache/sparse_control.cc @@ -138,30 +138,6 @@ void ChildrenDeleter::DeleteChildren() { this, &ChildrenDeleter::DeleteChildren)); } -// Logs the end event for |operation|, if all events are being logged. -void LogOperationEnd(const net::BoundNetLog& net_log, - disk_cache::SparseControl::SparseOperation operation, - int result) { - if (net_log.IsLoggingAllEvents()) { - net::NetLog::EventType event_type; - switch (operation) { - case disk_cache::SparseControl::kReadOperation: - event_type = net::NetLog::TYPE_SPARSE_CONTROL_READ; - break; - case disk_cache::SparseControl::kWriteOperation: - event_type = net::NetLog::TYPE_SPARSE_CONTROL_WRITE; - break; - case disk_cache::SparseControl::kGetRangeOperation: - event_type = net::NetLog::TYPE_SPARSE_CONTROL_GET_RANGE; - break; - default: - NOTREACHED(); - return; - } - net_log.EndEventWithNetErrorCode(event_type, result); - } -} - } // namespace. namespace disk_cache { @@ -247,7 +223,6 @@ int SparseControl::StartIO(SparseOperation op, int64 offset, net::IOBuffer* buf, finished_ = false; abort_ = false; - entry_->net_log().BeginEvent(net::NetLog::TYPE_SPARSE_CONTROL, NULL); DoChildrenIO(); if (!pending_) { @@ -635,11 +610,8 @@ void SparseControl::InitChildData() { void SparseControl::DoChildrenIO() { while (DoChildIO()) continue; - if (finished_) { - entry_->net_log().EndEvent(net::NetLog::TYPE_SPARSE_CONTROL, NULL); - if (pending_) - DoUserCallback(); - } + if (pending_ && finished_) + DoUserCallback(); } bool SparseControl::DoChildIO() { @@ -660,32 +632,14 @@ bool SparseControl::DoChildIO() { int rv = 0; switch (operation_) { case kReadOperation: - if (entry_->net_log().IsLoggingAllEvents()) { - entry_->net_log().BeginEvent( - net::NetLog::TYPE_SPARSE_CONTROL_READ, - make_scoped_refptr(new net::NetLogSourceParameter( - "source_dependency", - child_->net_log().source()))); - } rv = child_->ReadDataImpl(kSparseData, child_offset_, user_buf_, child_len_, callback); break; case kWriteOperation: - if (entry_->net_log().IsLoggingAllEvents()) { - entry_->net_log().BeginEvent( - net::NetLog::TYPE_SPARSE_CONTROL_WRITE, - make_scoped_refptr(new net::NetLogSourceParameter( - "source_dependency", - child_->net_log().source()))); - } rv = child_->WriteDataImpl(kSparseData, child_offset_, user_buf_, child_len_, callback, false); break; case kGetRangeOperation: - if (entry_->net_log().IsLoggingAllEvents()) { - entry_->net_log().BeginEvent(net::NetLog::TYPE_SPARSE_CONTROL_GET_RANGE, - NULL); - } rv = DoGetAvailableRange(); break; default: @@ -758,7 +712,6 @@ int SparseControl::DoGetAvailableRange() { } void SparseControl::DoChildIOCompleted(int result) { - LogOperationEnd(entry_->net_log(), operation_, result); if (result < 0) { // We fail the whole operation if we encounter an error. result_ = result; @@ -784,8 +737,6 @@ void SparseControl::OnChildIOCompleted(int result) { // We'll return the current result of the operation, which may be less than // the bytes to read or write, but the user cancelled the operation. abort_ = false; - entry_->net_log().AddEvent(net::NetLog::TYPE_CANCELLED, NULL); - entry_->net_log().EndEvent(net::NetLog::TYPE_SPARSE_CONTROL, NULL); DoUserCallback(); return DoAbortCallbacks(); } diff --git a/net/disk_cache/stress_cache.cc b/net/disk_cache/stress_cache.cc index ee2db24..41a98c9 100644 --- a/net/disk_cache/stress_cache.cc +++ b/net/disk_cache/stress_cache.cc @@ -104,7 +104,7 @@ void StressTheCache(int iteration) { int rv = disk_cache::BackendImpl::CreateBackend( path, false, cache_size, net::DISK_CACHE, disk_cache::kNoLoadProtection | disk_cache::kNoRandom, - cache_thread.message_loop_proxy(), NULL, &cache, &cb); + cache_thread.message_loop_proxy(), &cache, &cb); if (cb.GetResult(rv) != net::OK) { printf("Unable to initialize cache.\n"); |