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

Side by Side Diff: app/resource_bundle.cc

Issue 2852011: Revert 50057 - Load net-internals from the newly created resources.pak file.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 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
« no previous file with comments | « app/resource_bundle.h ('k') | base/data_pack.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/logging.h" 8 #include "base/logging.h"
9 #include "base/string_piece.h" 9 #include "base/string_piece.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 if (!gfx::PNGCodec::Decode(memory->front(), memory->size(), &bitmap)) { 98 if (!gfx::PNGCodec::Decode(memory->front(), memory->size(), &bitmap)) {
99 NOTREACHED() << "Unable to decode theme image resource " << resource_id; 99 NOTREACHED() << "Unable to decode theme image resource " << resource_id;
100 return NULL; 100 return NULL;
101 } 101 }
102 102
103 return new SkBitmap(bitmap); 103 return new SkBitmap(bitmap);
104 } 104 }
105 105
106 RefCountedStaticMemory* ResourceBundle::LoadDataResourceBytes( 106 RefCountedStaticMemory* ResourceBundle::LoadDataResourceBytes(
107 int resource_id) const { 107 int resource_id) const {
108 RefCountedStaticMemory* bytes = 108 return LoadResourceBytes(resources_data_, resource_id);
109 LoadResourceBytes(resources_data_, resource_id);
110
111 // Check all our additional data packs for the resources if it wasn't loaded
112 // from our main source.
113 for (std::vector<LoadedDataPack*>::const_iterator it = data_packs_.begin();
114 !bytes && it != data_packs_.end(); ++it) {
115 bytes = (*it)->GetStaticMemory(resource_id);
116 }
117
118 return bytes;
119 } 109 }
120 110
121 SkBitmap* ResourceBundle::GetBitmapNamed(int resource_id) { 111 SkBitmap* ResourceBundle::GetBitmapNamed(int resource_id) {
122 // Check to see if we already have the Skia image in the cache. 112 // Check to see if we already have the Skia image in the cache.
123 { 113 {
124 AutoLock lock_scope(lock_); 114 AutoLock lock_scope(lock_);
125 SkImageMap::const_iterator found = skia_images_.find(resource_id); 115 SkImageMap::const_iterator found = skia_images_.find(resource_id);
126 if (found != skia_images_.end()) 116 if (found != skia_images_.end())
127 return found->second; 117 return found->second;
128 } 118 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 case LargeFont: 191 case LargeFont:
202 return *large_font_; 192 return *large_font_;
203 default: 193 default:
204 return *base_font_; 194 return *base_font_;
205 } 195 }
206 } 196 }
207 197
208 // LoadedDataPack implementation 198 // LoadedDataPack implementation
209 ResourceBundle::LoadedDataPack::LoadedDataPack(const FilePath& path) 199 ResourceBundle::LoadedDataPack::LoadedDataPack(const FilePath& path)
210 : path_(path) { 200 : path_(path) {
211 // Always preload the data packs so we can maintain constness. 201 // On unicies, we preload data packs so background updates don't cause us to
202 // load the wrong data.
203 #if defined(OS_POSIX) && !defined(OS_MACOSX)
212 Load(); 204 Load();
205 #endif
213 } 206 }
214 207
215 void ResourceBundle::LoadedDataPack::Load() { 208 void ResourceBundle::LoadedDataPack::Load() {
216 DCHECK(!data_pack_.get()); 209 DCHECK(!data_pack_.get());
217 data_pack_.reset(new base::DataPack); 210 data_pack_.reset(new base::DataPack);
218 bool success = data_pack_->Load(path_); 211 bool success = data_pack_->Load(path_);
219 CHECK(success) << "Failed to load " << path_.value(); 212 CHECK(success) << "Failed to load " << path_.value();
220 } 213 }
221 214
222 bool ResourceBundle::LoadedDataPack::GetStringPiece( 215 bool ResourceBundle::LoadedDataPack::GetStringPiece(int resource_id,
223 int resource_id, base::StringPiece* data) const { 216 base::StringPiece* data) {
217 if (!data_pack_.get())
218 Load();
224 return data_pack_->GetStringPiece(static_cast<uint32>(resource_id), data); 219 return data_pack_->GetStringPiece(static_cast<uint32>(resource_id), data);
225 } 220 }
226
227 RefCountedStaticMemory* ResourceBundle::LoadedDataPack::GetStaticMemory(
228 int resource_id) const {
229 return data_pack_->GetStaticMemory(resource_id);
230 }
OLDNEW
« no previous file with comments | « app/resource_bundle.h ('k') | base/data_pack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698