File: data_pack_literal.cc

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (124 lines) | stat: -rw-r--r-- 6,385 bytes parent folder | download | duplicates (8)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/base/resource/data_pack_literal.h"
#include "ui/base/resource/resource_bundle.h"

namespace ui {

const uint8_t kSamplePakContentsV4[] = {
    0x04, 0x00, 0x00, 0x00,              // header(version
    0x04, 0x00, 0x00, 0x00,              //        no. entries
    0x01,                                //        encoding)
    0x01, 0x00, 0x27, 0x00, 0x00, 0x00,  // index entry 1
    0x04, 0x00, 0x27, 0x00, 0x00, 0x00,  // index entry 4
    0x06, 0x00, 0x33, 0x00, 0x00, 0x00,  // index entry 6
    0x0a, 0x00, 0x3f, 0x00, 0x00, 0x00,  // index entry 10
    0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,  // extra entry for the size of last
    't',  'h',  'i',  's',  ' ',  'i',  's', ' ', 'i', 'd', ' ', '4',
    't',  'h',  'i',  's',  ' ',  'i',  's', ' ', 'i', 'd', ' ', '6'};

const size_t kSamplePakSizeV4 = sizeof(kSamplePakContentsV4);

const uint8_t kSampleCompressPakContentsV5[] = {
    0x05, 0x00, 0x00, 0x00,              // version
    0x01, 0x00, 0x00, 0x00,              // encoding + padding
    0x03, 0x00, 0x01, 0x00,              // num_resources, num_aliases
    0x04, 0x00, 0x28, 0x00, 0x00, 0x00,  // index entry 4
    0x06, 0x00, 0x34, 0x00, 0x00, 0x00,  // index entry 6
    0x08, 0x00, 0x4c, 0x00, 0x00, 0x00,  // index entry 8
    0x00, 0x00, 0x69, 0x00, 0x00, 0x00,  // extra entry for the size of last
    0x0a, 0x00, 0x00, 0x00,              // alias table

    't', 'h', 'i', 's', ' ', 'i', 's', ' ', 'i', 'd', ' ', '4',
    // "this is id 6" brotli compressed with
    // echo -n "this is id 6" |{brotli_executable_path}/brotli - -f|
    // hexdump -C where brotli_executable_path is the directory of the brotli
    // executable dependent on the build device. For example, on Android builds,
    // the executable path is out/Build_name/clang_x64/brotli. Also added header
    // with kBrotliConst and the length of the decompressed data.
    ResourceBundle::kBrotliConst[0], ResourceBundle::kBrotliConst[1], 0x0c,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x05, 0x80, 0x74, 0x68, 0x69, 0x73,
    0x20, 0x69, 0x73, 0x20, 0x69, 0x64, 0x20, 0x36, 0x03,
    // "this is id 8" gzipped with
    // echo -n "this is id 8" | gzip -f -c | hexdump -C
    0x1f, 0x8b, 0x08, 0x00, 0x53, 0x99, 0x1f, 0x5d, 0x00, 0x03, 0x2b, 0xc9,
    0xc8, 0x2c, 0x56, 0x00, 0xa1, 0x14, 0x05, 0x0b, 0x00, 0x71, 0xa7, 0x0b,
    0x4d, 0x0c, 0x00, 0x00, 0x00};

const size_t kSampleCompressPakSizeV5 = sizeof(kSampleCompressPakContentsV5);

const uint8_t kSampleCompressScaledPakContents[] = {
    0x05, 0x00, 0x00, 0x00,              // version
    0x01, 0x00, 0x00, 0x00,              // encoding + padding
    0x03, 0x00, 0x01, 0x00,              // num_resources, num_aliases
    0x01, 0x00, 0x28, 0x00, 0x00, 0x00,  // index entry 1
    0x04, 0x00, 0x28, 0x00, 0x00, 0x00,  // index entry 4
    0x06, 0x00, 0x34, 0x00, 0x00, 0x00,  // index entry 6
    0x00, 0x00, 0x4f, 0x00, 0x00, 0x00,  // extra entry for the size of last
    0x0a, 0x00, 0x01, 0x00,              // alias table

    't', 'h', 'i', 's', ' ', 'i', 's', ' ', 'i', 'd', ' ', '4',
    // "this is id 6 x2" brotli compressed with
    // echo -n "this is id 6 x2" |{brotli_executable_path}/brotli - -f|
    // hexdump -C where brotli_executable_path is the directory of the brotli
    // executable dependent on the build device. For example, on Android builds,
    // the executable path is out/Build_name/clang_x64/brotli. Also added header
    // with kBrotliConst and the length of the decompressed data. See
    // tools/grit/grit/node/base.py for grit brotli compression.
    ResourceBundle::kBrotliConst[0], ResourceBundle::kBrotliConst[1], 0x0f,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x07, 0x80, 0x74, 0x68, 0x69, 0x73,
    0x20, 0x69, 0x73, 0x20, 0x69, 0x64, 0x20, 0x36, 0x20, 0x78, 0x32, 0x03};

const size_t kSampleCompressScaledPakSize =
    sizeof(kSampleCompressScaledPakContents);

const uint8_t kSampleCorruptPakContents[] = {
    0x04, 0x00, 0x00, 0x00,              // header(version
    0x04, 0x00, 0x00, 0x00,              //        no. entries
    0x01,                                //        encoding)
    0x01, 0x00, 0x27, 0x00, 0x00, 0x00,  // index entry 1
    0x04, 0x00, 0x27, 0x00, 0x00, 0x00,  // index entry 4
    0x06, 0x00, 0x33, 0x00, 0x00, 0x00,  // index entry 6
    0x0a, 0x00, 0x3f, 0x00, 0x00, 0x00,  // index entry 10
    0x00, 0x00, 0x40, 0x00, 0x00, 0x00,  // extra entry for the size of last,
                                         // extends past END OF FILE.
    't', 'h', 'i', 's', ' ', 'i', 's', ' ', 'i', 'd', ' ', '4', 't', 'h', 'i',
    's', ' ', 'i', 's', ' ', 'i', 'd', ' ', '6'};

const size_t kSampleCorruptPakSize = sizeof(kSampleCorruptPakContents);

const uint8_t kSampleMisorderedPakContents[] = {
    0x05, 0x00, 0x00, 0x00,              // version
    0x01, 0x00, 0x00, 0x00,              // encoding + padding
    0x02, 0x00, 0x00, 0x00,              // num_resources, num_aliases
    0x06, 0x00, 0x2a, 0x00, 0x00, 0x00,  // index entry 6 (wrong order)
    0x04, 0x00, 0x1e, 0x00, 0x00, 0x00,  // index entry 4
    0x00, 0x00, 0x36, 0x00, 0x00, 0x00,  // extra entry for the size of last
    't',  'h',  'i',  's',  ' ',  'i',  's', ' ', 'i', 'd', ' ', '4',
    't',  'h',  'i',  's',  ' ',  'i',  's', ' ', 'i', 'd', ' ', '6'};

const size_t kSampleMisorderedPakSize = sizeof(kSampleMisorderedPakContents);

const uint8_t kSamplePakContents2x[] = {
    0x04, 0x00, 0x00, 0x00,              // header(version
    0x01, 0x00, 0x00, 0x00,              //        no. entries
    0x01,                                //        encoding)
    0x04, 0x00, 0x15, 0x00, 0x00, 0x00,  // index entry 4
    0x00, 0x00, 0x24, 0x00, 0x00, 0x00,  // extra entry for the size of last
    't',  'h',  'i',  's',  ' ',  'i',  's', ' ',
    'i',  'd',  ' ',  '4',  ' ',  '2',  'x'};

const size_t kSamplePakSize2x = sizeof(kSamplePakContents2x);

const uint8_t kEmptyPakContents[] = {
    0x04, 0x00, 0x00, 0x00,             // header(version
    0x00, 0x00, 0x00, 0x00,             //        no. entries
    0x01,                               //        encoding)
    0x00, 0x00, 0x0f, 0x00, 0x00, 0x00  // extra entry for the size of last
};

const size_t kEmptyPakSize = sizeof(kEmptyPakContents);

}  // namespace ui