diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-08 19:51:09 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-08 19:51:09 +0000 |
commit | 9a9df873c619cd08ac6fb14a510135f29d8cccd1 (patch) | |
tree | f057fade0f12e9c5bf6e0dcd3de5158ccca9defc /base/data_pack.h | |
parent | 9dc2438fcf00c4ee2f30f66fc8b8bc2f6b7fc465 (diff) | |
download | chromium_src-9a9df873c619cd08ac6fb14a510135f29d8cccd1.zip chromium_src-9a9df873c619cd08ac6fb14a510135f29d8cccd1.tar.gz chromium_src-9a9df873c619cd08ac6fb14a510135f29d8cccd1.tar.bz2 |
Data pack file reader and unit test, used for resources on Linux.
See http://dev.chromium.org/developers/design-documents/linuxresourcesandlocalizedstrings for more details.
Review URL: http://codereview.chromium.org/17253
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7751 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/data_pack.h')
-rw-r--r-- | base/data_pack.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/base/data_pack.h b/base/data_pack.h new file mode 100644 index 0000000..1836552 --- /dev/null +++ b/base/data_pack.h @@ -0,0 +1,46 @@ +// Copyright (c) 2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// DataPack represents a read-only view onto an on-disk file that contains +// (key, value) pairs of data. It's used to store static resources like +// translation strings and images. + +#ifndef BASE_DATA_PACK_H_ +#define BASE_DATA_PACK_H_ + +#include "base/basictypes.h" +#include "base/scoped_ptr.h" + +namespace file_util { + class MemoryMappedFile; +} +class FilePath; +class StringPiece; + +namespace base { + +class DataPack { + public: + DataPack(); + ~DataPack(); + + // Load a pack file from |path|, returning false on error. + bool Load(const FilePath& path); + + // Get resource by id |resource_id|, filling in |data|. + // The data is owned by the DataPack object and should not be modified. + // Returns false if the resource id isn't found. + bool Get(uint32_t resource_id, StringPiece* data); + + private: + // The memory-mapped data. + scoped_ptr<file_util::MemoryMappedFile> mmap_; + + // Number of resources in the data. + size_t resource_count_; +}; + +} // namespace base + +#endif // BASE_DATA_PACK_H_ |