Home | History | Annotate | Download | only in disk_cache
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef NET_DISK_CACHE_NET_LOG_PARAMETERS_H_
      6 #define NET_DISK_CACHE_NET_LOG_PARAMETERS_H_
      7 #pragma once
      8 
      9 #include <string>
     10 
     11 #include "net/base/net_log.h"
     12 
     13 // This file contains a set of NetLog::EventParameters shared by EntryImpls and
     14 // MemEntryImpls.
     15 namespace disk_cache {
     16 
     17 // NetLog parameters for the creation of an Entry.  Contains the Entry's name
     18 // and whether it was created or opened.
     19 class EntryCreationParameters : public net::NetLog::EventParameters {
     20  public:
     21   EntryCreationParameters(const std::string& key, bool created);
     22   virtual Value* ToValue() const;
     23 
     24  private:
     25   const std::string key_;
     26   const bool created_;
     27 
     28   DISALLOW_COPY_AND_ASSIGN(EntryCreationParameters);
     29 };
     30 
     31 // NetLog parameters for non-sparse reading and writing to an Entry.
     32 class ReadWriteDataParameters : public net::NetLog::EventParameters {
     33  public:
     34   // For reads, |truncate| must be false.
     35   ReadWriteDataParameters(int index, int offset, int buf_len, bool truncate);
     36   virtual Value* ToValue() const;
     37 
     38  private:
     39   const int index_;
     40   const int offset_;
     41   const int buf_len_;
     42   const bool truncate_;
     43 
     44   DISALLOW_COPY_AND_ASSIGN(ReadWriteDataParameters);
     45 };
     46 
     47 // NetLog parameters for when a non-sparse read or write completes.
     48 class ReadWriteCompleteParameters : public net::NetLog::EventParameters {
     49  public:
     50   // |bytes_copied| is either the number of bytes copied or a network error
     51   // code.  |bytes_copied| must not be ERR_IO_PENDING, as it's not a valid
     52   // result for an operation.
     53   explicit ReadWriteCompleteParameters(int bytes_copied);
     54   virtual Value* ToValue() const;
     55 
     56  private:
     57   const int bytes_copied_;
     58 
     59   DISALLOW_COPY_AND_ASSIGN(ReadWriteCompleteParameters);
     60 };
     61 
     62 // NetLog parameters for when a sparse operation is started.
     63 class SparseOperationParameters : public net::NetLog::EventParameters {
     64  public:
     65   SparseOperationParameters(int64 offset, int buff_len);
     66   virtual Value* ToValue() const;
     67 
     68  private:
     69   const int64 offset_;
     70   const int buff_len_;
     71 };
     72 
     73 // NetLog parameters for when a read or write for a sparse entry's child is
     74 // started.
     75 class SparseReadWriteParameters : public net::NetLog::EventParameters {
     76  public:
     77   SparseReadWriteParameters(const net::NetLog::Source& source, int child_len);
     78   virtual Value* ToValue() const;
     79 
     80  private:
     81   const net::NetLog::Source source_;
     82   const int child_len_;
     83 };
     84 
     85 // NetLog parameters for when a call to GetAvailableRange returns.
     86 class GetAvailableRangeResultParameters : public net::NetLog::EventParameters {
     87  public:
     88   // |start| is ignored when |result| < 0.
     89   GetAvailableRangeResultParameters(int64 start, int result);
     90   virtual Value* ToValue() const;
     91 
     92  private:
     93   const int64 start_;
     94   const int result_;
     95 };
     96 
     97 }  // namespace disk_cache
     98 
     99 #endif  // NET_DISK_CACHE_NET_LOG_CACHE_PARAMETERS_H_
    100