OLD | NEW |
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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/containers/hash_tables.h" | 15 #include "base/containers/hash_tables.h" |
16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
17 #include "base/files/memory_mapped_file.h" | 17 #include "base/files/memory_mapped_file.h" |
18 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/sequence_checker.h" |
20 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
21 #include "base/strings/string_piece.h" | 22 #include "base/strings/string_piece.h" |
22 #include "build/build_config.h" | 23 #include "build/build_config.h" |
23 #include "ui/base/layout.h" | 24 #include "ui/base/layout.h" |
24 #include "ui/base/ui_base_export.h" | 25 #include "ui/base/ui_base_export.h" |
25 #include "ui/gfx/font_list.h" | 26 #include "ui/gfx/font_list.h" |
26 #include "ui/gfx/image/image.h" | 27 #include "ui/gfx/image/image.h" |
27 #include "ui/gfx/native_widget_types.h" | 28 #include "ui/gfx/native_widget_types.h" |
28 | 29 |
29 class SkBitmap; | 30 class SkBitmap; |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 // Returns an empty image for when a resource cannot be loaded. This is a | 387 // Returns an empty image for when a resource cannot be loaded. This is a |
387 // bright red bitmap. | 388 // bright red bitmap. |
388 gfx::Image& GetEmptyImage(); | 389 gfx::Image& GetEmptyImage(); |
389 | 390 |
390 const base::FilePath& GetOverriddenPakPath(); | 391 const base::FilePath& GetOverriddenPakPath(); |
391 | 392 |
392 // This pointer is guaranteed to outlive the ResourceBundle instance and may | 393 // This pointer is guaranteed to outlive the ResourceBundle instance and may |
393 // be NULL. | 394 // be NULL. |
394 Delegate* delegate_; | 395 Delegate* delegate_; |
395 | 396 |
396 // Protects |images_| and font-related members. | |
397 std::unique_ptr<base::Lock> images_and_fonts_lock_; | |
398 | |
399 // Protects |locale_resources_data_|. | 397 // Protects |locale_resources_data_|. |
400 std::unique_ptr<base::Lock> locale_resources_data_lock_; | 398 std::unique_ptr<base::Lock> locale_resources_data_lock_; |
401 | 399 |
402 // Handles for data sources. | 400 // Handles for data sources. |
403 std::unique_ptr<ResourceHandle> locale_resources_data_; | 401 std::unique_ptr<ResourceHandle> locale_resources_data_; |
404 std::vector<std::unique_ptr<ResourceHandle>> data_packs_; | 402 std::vector<std::unique_ptr<ResourceHandle>> data_packs_; |
405 | 403 |
406 // The maximum scale factor currently loaded. | 404 // The maximum scale factor currently loaded. |
407 ScaleFactor max_scale_factor_; | 405 ScaleFactor max_scale_factor_; |
408 | 406 |
409 // Cached images. The ResourceBundle caches all retrieved images and keeps | 407 // Cached images. The ResourceBundle caches all retrieved images and keeps |
410 // ownership of the pointers. | 408 // ownership of the pointers. |
411 typedef std::map<int, gfx::Image> ImageMap; | 409 typedef std::map<int, gfx::Image> ImageMap; |
412 ImageMap images_; | 410 ImageMap images_; |
413 | 411 |
414 gfx::Image empty_image_; | 412 gfx::Image empty_image_; |
415 | 413 |
416 // The various font lists used, as a map from a signed size delta from the | 414 // The various font lists used, as a map from a signed size delta from the |
417 // platform base font size, plus style, to the FontList. Cached to avoid | 415 // platform base font size, plus style, to the FontList. Cached to avoid |
418 // repeated GDI creation/destruction and font derivation. | 416 // repeated GDI creation/destruction and font derivation. |
419 // Must be accessed only while holding |images_and_fonts_lock_|. | 417 // Must be accessed only from UI thread. |
420 std::map<FontKey, gfx::FontList> font_cache_; | 418 std::map<FontKey, gfx::FontList> font_cache_; |
421 | 419 |
422 base::FilePath overridden_pak_path_; | 420 base::FilePath overridden_pak_path_; |
423 | 421 |
424 IdToStringMap overridden_locale_strings_; | 422 IdToStringMap overridden_locale_strings_; |
425 | 423 |
426 bool is_test_resources_ = false; | 424 bool is_test_resources_ = false; |
427 | 425 |
| 426 base::SequenceChecker sequence_checker_; |
| 427 |
428 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); | 428 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); |
429 }; | 429 }; |
430 | 430 |
431 } // namespace ui | 431 } // namespace ui |
432 | 432 |
433 // TODO(beng): Someday, maybe, get rid of this. | 433 // TODO(beng): Someday, maybe, get rid of this. |
434 using ui::ResourceBundle; | 434 using ui::ResourceBundle; |
435 | 435 |
436 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 436 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
OLD | NEW |