| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "app/resource_bundle.h" | 5 #include "app/resource_bundle.h" |
| 6 | 6 |
| 7 #include "base/data_pack.h" | 7 #include "base/data_pack.h" |
| 8 #include "base/lock.h" | 8 #include "base/lock.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 | 209 |
| 210 // LoadedDataPack implementation | 210 // LoadedDataPack implementation |
| 211 ResourceBundle::LoadedDataPack::LoadedDataPack(const FilePath& path) | 211 ResourceBundle::LoadedDataPack::LoadedDataPack(const FilePath& path) |
| 212 : path_(path) { | 212 : path_(path) { |
| 213 // Always preload the data packs so we can maintain constness. | 213 // Always preload the data packs so we can maintain constness. |
| 214 Load(); | 214 Load(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 ResourceBundle::LoadedDataPack::~LoadedDataPack() { |
| 218 } |
| 219 |
| 217 void ResourceBundle::LoadedDataPack::Load() { | 220 void ResourceBundle::LoadedDataPack::Load() { |
| 218 DCHECK(!data_pack_.get()); | 221 DCHECK(!data_pack_.get()); |
| 219 data_pack_.reset(new base::DataPack); | 222 data_pack_.reset(new base::DataPack); |
| 220 bool success = data_pack_->Load(path_); | 223 bool success = data_pack_->Load(path_); |
| 221 CHECK(success) << "Failed to load " << path_.value(); | 224 CHECK(success) << "Failed to load " << path_.value(); |
| 222 } | 225 } |
| 223 | 226 |
| 224 bool ResourceBundle::LoadedDataPack::GetStringPiece( | 227 bool ResourceBundle::LoadedDataPack::GetStringPiece( |
| 225 int resource_id, base::StringPiece* data) const { | 228 int resource_id, base::StringPiece* data) const { |
| 226 return data_pack_->GetStringPiece(static_cast<uint32>(resource_id), data); | 229 return data_pack_->GetStringPiece(static_cast<uint32>(resource_id), data); |
| 227 } | 230 } |
| 228 | 231 |
| 229 RefCountedStaticMemory* ResourceBundle::LoadedDataPack::GetStaticMemory( | 232 RefCountedStaticMemory* ResourceBundle::LoadedDataPack::GetStaticMemory( |
| 230 int resource_id) const { | 233 int resource_id) const { |
| 231 return data_pack_->GetStaticMemory(resource_id); | 234 return data_pack_->GetStaticMemory(resource_id); |
| 232 } | 235 } |
| OLD | NEW |