Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_FORMAT_H_ | 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_FORMAT_H_ |
| 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_FORMAT_H_ | 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_FORMAT_H_ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/port.h" | 10 #include "base/port.h" |
| 11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
| 12 | 12 |
| 13 namespace base { | 13 namespace base { |
| 14 class Time; | 14 class Time; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace disk_cache { | 17 namespace disk_cache { |
| 18 | 18 |
| 19 const uint64 kSimpleInitialMagicNumber = GG_UINT64_C(0xfcfb6d1ba7725c30); | 19 const uint64 kSimpleInitialMagicNumber = GG_UINT64_C(0xfcfb6d1ba7725c30); |
| 20 const uint64 kSimpleFinalMagicNumber = GG_UINT64_C(0xf4fa6f45970d41d8); | 20 const uint64 kSimpleFinalMagicNumber = GG_UINT64_C(0xf4fa6f45970d41d8); |
| 21 | 21 |
| 22 // A file in the Simple cache consists of a SimpleFileHeader followed | 22 // A file containing stream 0 and stream 1 in the Simple cache consists of: |
| 23 // by data. | 23 // - a SimpleFileHeader. |
| 24 // - the key. | |
| 25 // - the data from stream 1. | |
| 26 // - a SimpleFileEOF record for stream 1. | |
| 27 // - the data from stream 0. | |
| 28 // - a SimpleFileEOF record for stream 0. | |
| 24 | 29 |
| 25 // A file in the Simple cache consists of: | 30 // A file containing stream 2 in the Simple cache consists of: |
| 26 // - a SimpleFileHeader. | 31 // - a SimpleFileHeader. |
| 27 // - the key. | 32 // - the key. |
| 28 // - the data. | 33 // - the data. |
| 29 // - at the end, a SimpleFileEOF record. | 34 // - at the end, a SimpleFileEOF record. |
| 30 const uint32 kSimpleVersion = 4; | 35 const uint32 kSimpleVersion = 5; |
| 31 | 36 |
| 32 static const int kSimpleEntryFileCount = 3; | 37 static const int kSimpleEntryFileCount = 2; |
| 38 static const int kSimpleEntryStreamCount = 3; | |
| 33 | 39 |
| 34 struct NET_EXPORT_PRIVATE SimpleFileHeader { | 40 struct NET_EXPORT_PRIVATE SimpleFileHeader { |
| 35 SimpleFileHeader(); | 41 SimpleFileHeader(); |
| 36 | 42 |
| 37 uint64 initial_magic_number; | 43 uint64 initial_magic_number; |
| 38 uint32 version; | 44 uint32 version; |
| 39 uint32 key_length; | 45 uint32 key_length; |
| 40 uint32 key_hash; | 46 uint32 key_hash; |
| 47 // Only used in the file containing stream 0 and stream 1. For stream 2, the | |
| 48 // size is computed from the file size. | |
| 49 uint32 stream_0_size; | |
|
gavinp
2013/09/10 22:20:49
I'm not sure that storing explicit sizes is great.
clamy
2013/09/11 12:46:21
I don't really like the idea of having an offset t
gavinp
2013/09/11 14:22:10
If we write stream 1 size, we're rewriting the hea
clamy
2013/09/16 15:01:17
Done.
| |
| 50 uint32 stream_1_size; | |
| 41 }; | 51 }; |
| 42 | 52 |
| 43 struct SimpleFileEOF { | 53 struct SimpleFileEOF { |
| 44 enum Flags { | 54 enum Flags { |
| 45 FLAG_HAS_CRC32 = (1U << 0), | 55 FLAG_HAS_CRC32 = (1U << 0), |
| 46 }; | 56 }; |
| 47 | 57 |
| 48 SimpleFileEOF(); | 58 SimpleFileEOF(); |
| 49 | 59 |
| 50 uint64 final_magic_number; | 60 uint64 final_magic_number; |
| 51 uint32 flags; | 61 uint32 flags; |
| 52 uint32 data_crc32; | 62 uint32 data_crc32; |
| 53 }; | 63 }; |
| 54 | 64 |
| 55 } // namespace disk_cache | 65 } // namespace disk_cache |
| 56 | 66 |
| 57 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_FORMAT_H_ | 67 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_FORMAT_H_ |
| OLD | NEW |