Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(660)

Side by Side Diff: ui/base/resource/data_pack.h

Issue 7555003: Update the .pak file format to version 2: Make resource ids 16bit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: evan's review feedback Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/grit/grit/format/data_pack_unittest.py ('k') | ui/base/resource/data_pack.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 // DataPack represents a read-only view onto an on-disk file that contains 5 // DataPack represents a read-only view onto an on-disk file that contains
6 // (key, value) pairs of data. It's used to store static resources like 6 // (key, value) pairs of data. It's used to store static resources like
7 // translation strings and images. 7 // translation strings and images.
8 8
9 #ifndef UI_BASE_RESOURCE_DATA_PACK_H_ 9 #ifndef UI_BASE_RESOURCE_DATA_PACK_H_
10 #define UI_BASE_RESOURCE_DATA_PACK_H_ 10 #define UI_BASE_RESOURCE_DATA_PACK_H_
(...skipping 22 matching lines...) Expand all
33 public: 33 public:
34 DataPack(); 34 DataPack();
35 ~DataPack(); 35 ~DataPack();
36 36
37 // Load a pack file from |path|, returning false on error. 37 // Load a pack file from |path|, returning false on error.
38 bool Load(const FilePath& path); 38 bool Load(const FilePath& path);
39 39
40 // Get resource by id |resource_id|, filling in |data|. 40 // Get resource by id |resource_id|, filling in |data|.
41 // The data is owned by the DataPack object and should not be modified. 41 // The data is owned by the DataPack object and should not be modified.
42 // Returns false if the resource id isn't found. 42 // Returns false if the resource id isn't found.
43 bool GetStringPiece(uint32 resource_id, base::StringPiece* data) const; 43 bool GetStringPiece(uint16 resource_id, base::StringPiece* data) const;
44 44
45 // Like GetStringPiece(), but returns a reference to memory. This interface 45 // Like GetStringPiece(), but returns a reference to memory. This interface
46 // is used for image data, while the StringPiece interface is usually used 46 // is used for image data, while the StringPiece interface is usually used
47 // for localization strings. 47 // for localization strings.
48 RefCountedStaticMemory* GetStaticMemory(uint32 resource_id) const; 48 RefCountedStaticMemory* GetStaticMemory(uint16 resource_id) const;
49 49
50 // Writes a pack file containing |resources| to |path|. 50 // Writes a pack file containing |resources| to |path|.
51 static bool WritePack(const FilePath& path, 51 static bool WritePack(const FilePath& path,
52 const std::map<uint32, base::StringPiece>& resources); 52 const std::map<uint16, base::StringPiece>& resources);
53 53
54 private: 54 private:
55 // The memory-mapped data. 55 // The memory-mapped data.
56 scoped_ptr<file_util::MemoryMappedFile> mmap_; 56 scoped_ptr<file_util::MemoryMappedFile> mmap_;
57 57
58 // Number of resources in the data. 58 // Number of resources in the data.
59 size_t resource_count_; 59 size_t resource_count_;
60 60
61 DISALLOW_COPY_AND_ASSIGN(DataPack); 61 DISALLOW_COPY_AND_ASSIGN(DataPack);
62 }; 62 };
63 63
64 } // namespace ui 64 } // namespace ui
65 65
66 #endif // UI_BASE_RESOURCE_DATA_PACK_H_ 66 #endif // UI_BASE_RESOURCE_DATA_PACK_H_
OLDNEW
« no previous file with comments | « tools/grit/grit/format/data_pack_unittest.py ('k') | ui/base/resource/data_pack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698