1// Copyright (c) 2013 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_SIMPLE_SIMPLE_ENTRY_FORMAT_H_ 6#define NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_FORMAT_H_ 7 8 9#include "base/basictypes.h" 10#include "base/port.h" 11#include "net/base/net_export.h" 12 13namespace base { 14class Time; 15} 16 17namespace disk_cache { 18 19const uint64 kSimpleInitialMagicNumber = GG_UINT64_C(0xfcfb6d1ba7725c30); 20const uint64 kSimpleFinalMagicNumber = GG_UINT64_C(0xf4fa6f45970d41d8); 21const uint64 kSimpleSparseRangeMagicNumber = GG_UINT64_C(0xeb97bf016553676b); 22 23// A file containing stream 0 and stream 1 in the Simple cache consists of: 24// - a SimpleFileHeader. 25// - the key. 26// - the data from stream 1. 27// - a SimpleFileEOF record for stream 1. 28// - the data from stream 0. 29// - a SimpleFileEOF record for stream 0. 30 31// A file containing stream 2 in the Simple cache consists of: 32// - a SimpleFileHeader. 33// - the key. 34// - the data. 35// - at the end, a SimpleFileEOF record. 36static const int kSimpleEntryFileCount = 2; 37static const int kSimpleEntryStreamCount = 3; 38 39struct NET_EXPORT_PRIVATE SimpleFileHeader { 40 SimpleFileHeader(); 41 42 uint64 initial_magic_number; 43 uint32 version; 44 uint32 key_length; 45 uint32 key_hash; 46}; 47 48struct NET_EXPORT_PRIVATE SimpleFileEOF { 49 enum Flags { 50 FLAG_HAS_CRC32 = (1U << 0), 51 }; 52 53 SimpleFileEOF(); 54 55 uint64 final_magic_number; 56 uint32 flags; 57 uint32 data_crc32; 58 // |stream_size| is only used in the EOF record for stream 0. 59 uint32 stream_size; 60}; 61 62struct SimpleFileSparseRangeHeader { 63 SimpleFileSparseRangeHeader(); 64 65 uint64 sparse_range_magic_number; 66 int64 offset; 67 int64 length; 68 uint32 data_crc32; 69}; 70 71} // namespace disk_cache 72 73#endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_FORMAT_H_ 74