summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/net_log_parameters.h
blob: d0b0c291baae0117f5b3eef82ddd68e972fa0725 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// 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.

#ifndef NET_DISK_CACHE_NET_LOG_PARAMETERS_H_
#define NET_DISK_CACHE_NET_LOG_PARAMETERS_H_
#pragma once

#include <string>

#include "net/base/net_log.h"

// This file contains a set of NetLog::EventParameters shared by EntryImpls and
// MemEntryImpls.
namespace disk_cache {

// NetLog parameters for the creation of an Entry.  Contains the Entry's name
// and whether it was created or opened.
class EntryCreationParameters : public net::NetLog::EventParameters {
 public:
  EntryCreationParameters(const std::string& key, bool created);
  virtual base::Value* ToValue() const OVERRIDE;

 private:
  const std::string key_;
  const bool created_;

  DISALLOW_COPY_AND_ASSIGN(EntryCreationParameters);
};

// NetLog parameters for non-sparse reading and writing to an Entry.
class ReadWriteDataParameters : public net::NetLog::EventParameters {
 public:
  // For reads, |truncate| must be false.
  ReadWriteDataParameters(int index, int offset, int buf_len, bool truncate);
  virtual base::Value* ToValue() const OVERRIDE;

 private:
  const int index_;
  const int offset_;
  const int buf_len_;
  const bool truncate_;

  DISALLOW_COPY_AND_ASSIGN(ReadWriteDataParameters);
};

// NetLog parameters for when a non-sparse read or write completes.
class ReadWriteCompleteParameters : 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 ReadWriteCompleteParameters(int bytes_copied);
  virtual base::Value* ToValue() const OVERRIDE;

 private:
  const int bytes_copied_;

  DISALLOW_COPY_AND_ASSIGN(ReadWriteCompleteParameters);
};

// NetLog parameters for when a sparse operation is started.
class SparseOperationParameters : public net::NetLog::EventParameters {
 public:
  SparseOperationParameters(int64 offset, int buff_len);
  virtual base::Value* ToValue() const OVERRIDE;

 private:
  const int64 offset_;
  const int buff_len_;
};

// NetLog parameters for when a read or write for a sparse entry's child is
// started.
class SparseReadWriteParameters : public net::NetLog::EventParameters {
 public:
  SparseReadWriteParameters(const net::NetLog::Source& source, int child_len);
  virtual base::Value* ToValue() const OVERRIDE;

 private:
  const net::NetLog::Source source_;
  const int child_len_;
};

// NetLog parameters for when a call to GetAvailableRange returns.
class GetAvailableRangeResultParameters : public net::NetLog::EventParameters {
 public:
  // |start| is ignored when |result| < 0.
  GetAvailableRangeResultParameters(int64 start, int result);
  virtual base::Value* ToValue() const OVERRIDE;

 private:
  const int64 start_;
  const int result_;
};

}  // namespace disk_cache

#endif  // NET_DISK_CACHE_NET_LOG_CACHE_PARAMETERS_H_