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

Side by Side Diff: base/data_pack.h

Issue 5992006: Move data pack from base to app (it's just part of the resource bundle system... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years 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 | « base/data/data_pack_unittest/sample.pak ('k') | base/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
(Empty)
1 // Copyright (c) 2008 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.
4
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
7 // translation strings and images.
8
9 #ifndef BASE_DATA_PACK_H_
10 #define BASE_DATA_PACK_H_
11 #pragma once
12
13 #include <map>
14
15 #include "base/basictypes.h"
16 #include "base/scoped_ptr.h"
17
18 namespace file_util {
19 class MemoryMappedFile;
20 }
21 class FilePath;
22 class RefCountedStaticMemory;
23
24 namespace base {
25
26 class StringPiece;
27
28 class DataPack {
29 public:
30 DataPack();
31 ~DataPack();
32
33 // Load a pack file from |path|, returning false on error.
34 bool Load(const FilePath& path);
35
36 // Get resource by id |resource_id|, filling in |data|.
37 // The data is owned by the DataPack object and should not be modified.
38 // Returns false if the resource id isn't found.
39 bool GetStringPiece(uint32 resource_id, StringPiece* data) const;
40
41 // Like GetStringPiece(), but returns a reference to memory. This interface
42 // is used for image data, while the StringPiece interface is usually used
43 // for localization strings.
44 RefCountedStaticMemory* GetStaticMemory(uint32 resource_id) const;
45
46 // Writes a pack file containing |resources| to |path|.
47 static bool WritePack(const FilePath& path,
48 const std::map<uint32, StringPiece>& resources);
49
50 private:
51 // The memory-mapped data.
52 scoped_ptr<file_util::MemoryMappedFile> mmap_;
53
54 // Number of resources in the data.
55 size_t resource_count_;
56
57 DISALLOW_COPY_AND_ASSIGN(DataPack);
58 };
59
60 } // namespace base
61
62 #endif // BASE_DATA_PACK_H_
OLDNEW
« no previous file with comments | « base/data/data_pack_unittest/sample.pak ('k') | base/data_pack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698