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

Unified Diff: ui/base/resource/resource_bundle.cc

Issue 2980773002: Revert of Deduplicate Monochrome locale .paks (Closed)
Patch Set: Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/resource/resource_bundle.h ('k') | ui/base/resource/resource_bundle_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/resource/resource_bundle.cc
diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc
index a3c31f075becb93fbe57030485191e132ac4d680..7e66615fa1b4f0490b78f17dfcd0c6c077f27776 100644
--- a/ui/base/resource/resource_bundle.cc
+++ b/ui/base/resource/resource_bundle.cc
@@ -211,7 +211,7 @@
base::File pak_file,
const base::MemoryMappedFile::Region& region) {
InitSharedInstance(NULL);
- auto data_pack = base::MakeUnique<DataPack>(SCALE_FACTOR_100P);
+ std::unique_ptr<DataPack> data_pack(new DataPack(SCALE_FACTOR_100P));
if (!data_pack->LoadFromFileRegion(std::move(pak_file), region)) {
NOTREACHED() << "failed to load pak file";
return;
@@ -246,17 +246,6 @@
// Must call InitSharedInstance before this function.
CHECK(g_shared_instance_ != NULL);
return *g_shared_instance_;
-}
-
-void ResourceBundle::LoadSecondaryLocaleDataWithPakFileRegion(
- base::File pak_file,
- const base::MemoryMappedFile::Region& region) {
- auto data_pack = base::MakeUnique<DataPack>(SCALE_FACTOR_100P);
- if (!data_pack->LoadFromFileRegion(std::move(pak_file), region)) {
- NOTREACHED() << "failed to load secondary pak file";
- return;
- }
- secondary_locale_resources_data_ = std::move(data_pack);
}
#if !defined(OS_ANDROID)
@@ -400,7 +389,6 @@
void ResourceBundle::UnloadLocaleResources() {
locale_resources_data_.reset();
- secondary_locale_resources_data_.reset();
}
void ResourceBundle::OverrideLocalePakForTest(const base::FilePath& pak_path) {
@@ -563,27 +551,20 @@
}
base::StringPiece data;
+ if (!locale_resources_data_->GetStringPiece(static_cast<uint16_t>(message_id),
+ &data)) {
+ // Fall back on the main data pack (shouldn't be any strings here except in
+ // unittests).
+ data = GetRawDataResource(message_id);
+ if (data.empty()) {
+ NOTREACHED() << "unable to find resource: " << message_id;
+ return base::string16();
+ }
+ }
+
+ // Strings should not be loaded from a data pack that contains binary data.
ResourceHandle::TextEncodingType encoding =
locale_resources_data_->GetTextEncodingType();
- if (!locale_resources_data_->GetStringPiece(static_cast<uint16_t>(message_id),
- &data)) {
- if (secondary_locale_resources_data_.get() &&
- secondary_locale_resources_data_->GetStringPiece(
- static_cast<uint16_t>(message_id), &data)) {
- // Fall back on the secondary locale pak if it exists.
- encoding = secondary_locale_resources_data_->GetTextEncodingType();
- } else {
- // Fall back on the main data pack (shouldn't be any strings here except
- // in unittests).
- data = GetRawDataResource(message_id);
- if (data.empty()) {
- NOTREACHED() << "unable to find resource: " << message_id;
- return base::string16();
- }
- }
- }
-
- // Strings should not be loaded from a data pack that contains binary data.
DCHECK(encoding == ResourceHandle::UTF16 || encoding == ResourceHandle::UTF8)
<< "requested localized string from binary pack file";
@@ -603,16 +584,8 @@
{
base::AutoLock lock_scope(*locale_resources_data_lock_);
base::StringPiece data;
-
if (locale_resources_data_.get() &&
locale_resources_data_->GetStringPiece(
- static_cast<uint16_t>(resource_id), &data) &&
- !data.empty()) {
- return new base::RefCountedStaticMemory(data.data(), data.length());
- }
-
- if (secondary_locale_resources_data_.get() &&
- secondary_locale_resources_data_->GetStringPiece(
static_cast<uint16_t>(resource_id), &data) &&
!data.empty()) {
return new base::RefCountedStaticMemory(data.data(), data.length());
« no previous file with comments | « ui/base/resource/resource_bundle.h ('k') | ui/base/resource/resource_bundle_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698