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

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

Issue 109273002: Convert base::MemoryMappedFile to use File instead of PlatformFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Posix GetSize Created 6 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 5 #ifndef UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
6 #define UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 6 #define UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/files/file.h"
14 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
15 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/scoped_vector.h" 18 #include "base/memory/scoped_vector.h"
18 #include "base/platform_file.h"
19 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
20 #include "base/strings/string_piece.h" 20 #include "base/strings/string_piece.h"
21 #include "ui/base/layout.h" 21 #include "ui/base/layout.h"
22 #include "ui/base/ui_export.h" 22 #include "ui/base/ui_export.h"
23 #include "ui/gfx/font_list.h" 23 #include "ui/gfx/font_list.h"
24 #include "ui/gfx/image/image.h" 24 #include "ui/gfx/image/image.h"
25 #include "ui/gfx/native_widget_types.h" 25 #include "ui/gfx/native_widget_types.h"
26 26
27 class SkBitmap; 27 class SkBitmap;
28 28
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 // Same as InitSharedInstanceWithLocale(), but loads only localized resources, 129 // Same as InitSharedInstanceWithLocale(), but loads only localized resources,
130 // without default resource packs. 130 // without default resource packs.
131 static std::string InitSharedInstanceLocaleOnly( 131 static std::string InitSharedInstanceLocaleOnly(
132 const std::string& pref_locale, Delegate* delegate); 132 const std::string& pref_locale, Delegate* delegate);
133 133
134 // Initialize the ResourceBundle using given file. The second argument 134 // Initialize the ResourceBundle using given file. The second argument
135 // controls whether or not ResourceBundle::LoadCommonResources is called. 135 // controls whether or not ResourceBundle::LoadCommonResources is called.
136 // This allows the use of this function in a sandbox without local file 136 // This allows the use of this function in a sandbox without local file
137 // access (as on Android). 137 // access (as on Android).
138 static void InitSharedInstanceWithPakFile( 138 static void InitSharedInstanceWithPakFile(base::File file,
139 base::PlatformFile file, bool should_load_common_resources); 139 bool should_load_common_resources);
140 140
141 // Initialize the ResourceBundle using given data pack path for testing. 141 // Initialize the ResourceBundle using given data pack path for testing.
142 static void InitSharedInstanceWithPakPath(const base::FilePath& path); 142 static void InitSharedInstanceWithPakPath(const base::FilePath& path);
143 143
144 // Delete the ResourceBundle for this process if it exists. 144 // Delete the ResourceBundle for this process if it exists.
145 static void CleanupSharedInstance(); 145 static void CleanupSharedInstance();
146 146
147 // Returns true after the global resource loader instance has been created. 147 // Returns true after the global resource loader instance has been created.
148 static bool HasSharedInstance(); 148 static bool HasSharedInstance();
149 149
150 // Return the global resource loader instance. 150 // Return the global resource loader instance.
151 static ResourceBundle& GetSharedInstance(); 151 static ResourceBundle& GetSharedInstance();
152 152
153 // Check if the .pak for the given locale exists. 153 // Check if the .pak for the given locale exists.
154 bool LocaleDataPakExists(const std::string& locale); 154 bool LocaleDataPakExists(const std::string& locale);
155 155
156 // Registers additional data pack files with this ResourceBundle. When 156 // Registers additional data pack files with this ResourceBundle. When
157 // looking for a DataResource, we will search these files after searching the 157 // looking for a DataResource, we will search these files after searching the
158 // main module. |path| should be the complete path to the pack file if known 158 // main module. |path| should be the complete path to the pack file if known
159 // or just the pack file name otherwise (the delegate may optionally override 159 // or just the pack file name otherwise (the delegate may optionally override
160 // this value). |scale_factor| is the scale of images in this resource pak 160 // this value). |scale_factor| is the scale of images in this resource pak
161 // relative to the images in the 1x resource pak. This method is not thread 161 // relative to the images in the 1x resource pak. This method is not thread
162 // safe! You should call it immediately after calling InitSharedInstance. 162 // safe! You should call it immediately after calling InitSharedInstance.
163 void AddDataPackFromPath(const base::FilePath& path, 163 void AddDataPackFromPath(const base::FilePath& path,
164 ScaleFactor scale_factor); 164 ScaleFactor scale_factor);
165 165
166 // Same as above but using an already open file. 166 // Same as above but using an already open file.
167 void AddDataPackFromFile(base::PlatformFile file, ScaleFactor scale_factor); 167 void AddDataPackFromFile(base::File file, ScaleFactor scale_factor);
168 168
169 // Same as AddDataPackFromPath but does not log an error if the pack fails to 169 // Same as AddDataPackFromPath but does not log an error if the pack fails to
170 // load. 170 // load.
171 void AddOptionalDataPackFromPath(const base::FilePath& path, 171 void AddOptionalDataPackFromPath(const base::FilePath& path,
172 ScaleFactor scale_factor); 172 ScaleFactor scale_factor);
173 173
174 // Changes the locale for an already-initialized ResourceBundle, returning the 174 // Changes the locale for an already-initialized ResourceBundle, returning the
175 // name of the newly-loaded locale. Future calls to get strings will return 175 // name of the newly-loaded locale. Future calls to get strings will return
176 // the strings for this new locale. This has no effect on existing or future 176 // the strings for this new locale. This has no effect on existing or future
177 // image resources. |locale_resources_data_| is protected by a lock for the 177 // image resources. |locale_resources_data_| is protected by a lock for the
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 394
395 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); 395 DISALLOW_COPY_AND_ASSIGN(ResourceBundle);
396 }; 396 };
397 397
398 } // namespace ui 398 } // namespace ui
399 399
400 // TODO(beng): Someday, maybe, get rid of this. 400 // TODO(beng): Someday, maybe, get rid of this.
401 using ui::ResourceBundle; 401 using ui::ResourceBundle;
402 402
403 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 403 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698