Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / net / disk_cache / simple / simple_entry_format.h
blob767efb2ec9c6bd9b1da780eda29301142bdbbf15
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.
5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_FORMAT_H_
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_FORMAT_H_
8 #include <stdint.h>
10 #include "base/basictypes.h"
11 #include "net/base/net_export.h"
13 namespace base {
14 class Time;
17 namespace disk_cache {
19 const uint64 kSimpleInitialMagicNumber = UINT64_C(0xfcfb6d1ba7725c30);
20 const uint64 kSimpleFinalMagicNumber = UINT64_C(0xf4fa6f45970d41d8);
21 const uint64 kSimpleSparseRangeMagicNumber = UINT64_C(0xeb97bf016553676b);
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.
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.
36 static const int kSimpleEntryFileCount = 2;
37 static const int kSimpleEntryStreamCount = 3;
39 struct NET_EXPORT_PRIVATE SimpleFileHeader {
40 SimpleFileHeader();
42 uint64 initial_magic_number;
43 uint32 version;
44 uint32 key_length;
45 uint32 key_hash;
48 struct NET_EXPORT_PRIVATE SimpleFileEOF {
49 enum Flags {
50 FLAG_HAS_CRC32 = (1U << 0),
53 SimpleFileEOF();
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;
62 struct SimpleFileSparseRangeHeader {
63 SimpleFileSparseRangeHeader();
65 uint64 sparse_range_magic_number;
66 int64 offset;
67 int64 length;
68 uint32 data_crc32;
71 } // namespace disk_cache
73 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_FORMAT_H_