summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/net_log_parameters.cc
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-17 18:53:02 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-17 18:53:02 +0000
commit9eb8cdff6c4e93d2609ee9a12cbd6b3dfa8b7d7f (patch)
treea3024687f2041d1f464aeb073d289c1bb7daae74 /net/disk_cache/net_log_parameters.cc
parentd767b2c624529faef3bf78230f8873e91b244868 (diff)
downloadchromium_src-9eb8cdff6c4e93d2609ee9a12cbd6b3dfa8b7d7f.zip
chromium_src-9eb8cdff6c4e93d2609ee9a12cbd6b3dfa8b7d7f.tar.gz
chromium_src-9eb8cdff6c4e93d2609ee9a12cbd6b3dfa8b7d7f.tar.bz2
Adds memory cache logging, and updates disk cache logging.
Memory and disk cache use the same set of events, with the same parameters (Though the disk cache has a couple events the memory cache does not). Most disk cache events were renamed so as to no longer imply a connection to the disk cache, and all disk cache-related NetLog parameter class definitions were moved to a new file, since they're shared by both entry type. BUG=59382 TEST=none Review URL: http://codereview.chromium.org/6613027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78572 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/net_log_parameters.cc')
-rw-r--r--net/disk_cache/net_log_parameters.cc100
1 files changed, 100 insertions, 0 deletions
diff --git a/net/disk_cache/net_log_parameters.cc b/net/disk_cache/net_log_parameters.cc
new file mode 100644
index 0000000..76d79d7
--- /dev/null
+++ b/net/disk_cache/net_log_parameters.cc
@@ -0,0 +1,100 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/disk_cache/net_log_parameters.h"
+
+#include "base/logging.h"
+#include "base/string_number_conversions.h"
+#include "base/values.h"
+#include "net/base/net_errors.h"
+
+namespace disk_cache {
+
+EntryCreationParameters::EntryCreationParameters(
+ const std::string& key, bool created)
+ : key_(key), created_(created) {
+}
+
+Value* EntryCreationParameters::ToValue() const {
+ DictionaryValue* dict = new DictionaryValue();
+ dict->SetString("key", key_);
+ dict->SetBoolean("created", created_);
+ return dict;
+}
+
+ReadWriteDataParameters::ReadWriteDataParameters(
+ int index, int offset, int buf_len, bool truncate)
+ : index_(index), offset_(offset), buf_len_(buf_len), truncate_(truncate) {
+}
+
+Value* ReadWriteDataParameters::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;
+}
+
+
+// NetLog parameters logged when non-sparse reads and writes complete.
+ReadWriteCompleteParameters::ReadWriteCompleteParameters(int bytes_copied)
+ : bytes_copied_(bytes_copied) {
+}
+
+Value* ReadWriteCompleteParameters::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;
+}
+
+SparseOperationParameters::SparseOperationParameters(
+ int64 offset, int buff_len)
+ : offset_(offset), buff_len_(buff_len) {
+}
+
+Value* SparseOperationParameters::ToValue() const {
+ DictionaryValue* dict = new DictionaryValue();
+ // Values can only be created with at most 32-bit integers. Using a string
+ // instead circumvents that restriction.
+ dict->SetString("offset", base::Int64ToString(offset_));
+ dict->SetInteger("buff_len", buff_len_);
+ return dict;
+}
+
+SparseReadWriteParameters::SparseReadWriteParameters(
+ const net::NetLog::Source& source, int child_len)
+ : source_(source), child_len_(child_len) {
+}
+
+Value* SparseReadWriteParameters::ToValue() const {
+ DictionaryValue* dict = new DictionaryValue();
+ dict->Set("source_dependency", source_.ToValue());
+ dict->SetInteger("child_len", child_len_);
+ return dict;
+}
+
+GetAvailableRangeResultParameters::GetAvailableRangeResultParameters(
+ int64 start, int result)
+ : start_(start), result_(result) {
+}
+
+Value* GetAvailableRangeResultParameters::ToValue() const {
+ DictionaryValue* dict = new DictionaryValue();
+ if (result_ > 0) {
+ dict->SetInteger("length", result_);
+ dict->SetString("start", base::Int64ToString(start_));
+ } else {
+ dict->SetInteger("net_error", result_);
+ }
+ return dict;
+}
+
+} // namespace disk_cache