| Index: net/disk_cache/entry_impl.cc
 | 
| ===================================================================
 | 
| --- net/disk_cache/entry_impl.cc	(revision 78400)
 | 
| +++ net/disk_cache/entry_impl.cc	(working copy)
 | 
| @@ -7,13 +7,13 @@
 | 
|  #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"
 | 
|  #include "net/disk_cache/bitmap.h"
 | 
|  #include "net/disk_cache/cache_util.h"
 | 
|  #include "net/disk_cache/histogram_macros.h"
 | 
| +#include "net/disk_cache/net_log_parameters.h"
 | 
|  #include "net/disk_cache/sparse_control.h"
 | 
|  
 | 
|  using base::Time;
 | 
| @@ -25,82 +25,6 @@
 | 
|  // 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 {
 | 
| @@ -125,7 +49,7 @@
 | 
|    net::CompletionCallback* callback_;
 | 
|    scoped_refptr<net::IOBuffer> buf_;
 | 
|    TimeTicks start_;
 | 
| -  net::NetLog::EventType end_event_type_;
 | 
| +  const net::NetLog::EventType end_event_type_;
 | 
|  
 | 
|    DISALLOW_COPY_AND_ASSIGN(SyncCallback);
 | 
|  };
 | 
| @@ -136,7 +60,8 @@
 | 
|      if (entry_->net_log().IsLoggingAllEvents()) {
 | 
|        entry_->net_log().EndEvent(
 | 
|            end_event_type_,
 | 
| -          make_scoped_refptr(new FileIOCompleteParameters(bytes_copied)));
 | 
| +          make_scoped_refptr(
 | 
| +              new disk_cache::ReadWriteCompleteParameters(bytes_copied)));
 | 
|      }
 | 
|      entry_->ReportIOTime(disk_cache::EntryImpl::kAsyncIO, start_);
 | 
|      callback_->Run(bytes_copied);
 | 
| @@ -386,17 +311,17 @@
 | 
|                              int buf_len, CompletionCallback* callback) {
 | 
|    if (net_log_.IsLoggingAllEvents()) {
 | 
|      net_log_.BeginEvent(
 | 
| -        net::NetLog::TYPE_DISK_CACHE_READ_DATA,
 | 
| +        net::NetLog::TYPE_ENTRY_READ_DATA,
 | 
|          make_scoped_refptr(
 | 
| -            new ReadWriteDataParams(index, offset, buf_len, false)));
 | 
| +            new ReadWriteDataParameters(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)));
 | 
| +        net::NetLog::TYPE_ENTRY_READ_DATA,
 | 
| +        make_scoped_refptr(new ReadWriteCompleteParameters(result)));
 | 
|    }
 | 
|    return result;
 | 
|  }
 | 
| @@ -406,9 +331,9 @@
 | 
|                               bool truncate) {
 | 
|    if (net_log_.IsLoggingAllEvents()) {
 | 
|      net_log_.BeginEvent(
 | 
| -        net::NetLog::TYPE_DISK_CACHE_WRITE_DATA,
 | 
| +        net::NetLog::TYPE_ENTRY_WRITE_DATA,
 | 
|          make_scoped_refptr(
 | 
| -            new ReadWriteDataParams(index, offset, buf_len, truncate)));
 | 
| +            new ReadWriteDataParameters(index, offset, buf_len, truncate)));
 | 
|    }
 | 
|  
 | 
|    int result = InternalWriteData(index, offset, buf, buf_len, callback,
 | 
| @@ -416,8 +341,8 @@
 | 
|  
 | 
|    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)));
 | 
| +        net::NetLog::TYPE_ENTRY_WRITE_DATA,
 | 
| +        make_scoped_refptr(new ReadWriteCompleteParameters(result)));
 | 
|    }
 | 
|    return result;
 | 
|  }
 | 
| @@ -531,7 +456,7 @@
 | 
|  }
 | 
|  
 | 
|  void EntryImpl::InternalDoom() {
 | 
| -  net_log_.AddEvent(net::NetLog::TYPE_DISK_CACHE_DOOM, NULL);
 | 
| +  net_log_.AddEvent(net::NetLog::TYPE_ENTRY_DOOM, NULL);
 | 
|    DCHECK(node_.HasData());
 | 
|    if (!node_.Data()->dirty) {
 | 
|      node_.Data()->dirty = backend_->GetCurrentEntryId();
 | 
| @@ -692,7 +617,7 @@
 | 
|    net_log_ = net::BoundNetLog::Make(
 | 
|        net_log, net::NetLog::SOURCE_DISK_CACHE_ENTRY);
 | 
|    net_log_.BeginEvent(
 | 
| -      net::NetLog::TYPE_DISK_CACHE_ENTRY,
 | 
| +      net::NetLog::TYPE_DISK_CACHE_ENTRY_IMPL,
 | 
|        make_scoped_refptr(new EntryCreationParameters(GetKey(), created)));
 | 
|  }
 | 
|  
 | 
| @@ -859,7 +784,7 @@
 | 
|    if (doomed_) {
 | 
|      DeleteEntryData(true);
 | 
|    } else {
 | 
| -    net_log_.AddEvent(net::NetLog::TYPE_DISK_CACHE_CLOSE, NULL);
 | 
| +    net_log_.AddEvent(net::NetLog::TYPE_ENTRY_CLOSE, NULL);
 | 
|      bool ret = true;
 | 
|      for (int index = 0; index < kNumStreams; index++) {
 | 
|        if (user_buffers_[index].get()) {
 | 
| @@ -885,7 +810,7 @@
 | 
|    }
 | 
|  
 | 
|    Trace("~EntryImpl out 0x%p", reinterpret_cast<void*>(this));
 | 
| -  net_log_.EndEvent(net::NetLog::TYPE_DISK_CACHE_ENTRY, NULL);
 | 
| +  net_log_.EndEvent(net::NetLog::TYPE_DISK_CACHE_ENTRY_IMPL, NULL);
 | 
|    backend_->OnEntryDestroyEnd();
 | 
|  }
 | 
|  
 | 
| @@ -944,7 +869,7 @@
 | 
|    SyncCallback* io_callback = NULL;
 | 
|    if (callback) {
 | 
|      io_callback = new SyncCallback(this, buf, callback,
 | 
| -                                   net::NetLog::TYPE_DISK_CACHE_READ_DATA);
 | 
| +                                   net::NetLog::TYPE_ENTRY_READ_DATA);
 | 
|    }
 | 
|  
 | 
|    bool completed;
 | 
| @@ -1038,7 +963,7 @@
 | 
|    SyncCallback* io_callback = NULL;
 | 
|    if (callback) {
 | 
|      io_callback = new SyncCallback(this, buf, callback,
 | 
| -                                   net::NetLog::TYPE_DISK_CACHE_WRITE_DATA);
 | 
| +                                   net::NetLog::TYPE_ENTRY_WRITE_DATA);
 | 
|    }
 | 
|  
 | 
|    bool completed;
 | 
| 
 |