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

Unified Diff: base/data_pack.cc

Issue 338027: Modify DataPacks so they can return RefCountedStaticMemory objects. (Closed)
Patch Set: Rewrite GetStaticMemory Created 11 years, 2 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 | « base/data_pack.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/data_pack.cc
diff --git a/base/data_pack.cc b/base/data_pack.cc
index 46f3cb4924e0e6af2a775b6f46f55ec0ebe93910..a9e07a413cf10b8af876e015b3040ed342e00365 100644
--- a/base/data_pack.cc
+++ b/base/data_pack.cc
@@ -89,7 +89,7 @@ bool DataPack::Load(const FilePath& path) {
return true;
}
-bool DataPack::Get(uint32_t resource_id, StringPiece* data) {
+bool DataPack::GetStringPiece(uint32_t resource_id, StringPiece* data) {
// It won't be hard to make this endian-agnostic, but it's not worth
// bothering to do right now.
#if defined(__BYTE_ORDER)
@@ -113,4 +113,14 @@ bool DataPack::Get(uint32_t resource_id, StringPiece* data) {
return true;
}
+RefCountedStaticMemory* DataPack::GetStaticMemory(uint32_t resource_id) {
+ base::StringPiece piece;
+ if (!GetStringPiece(resource_id, &piece)) {
+ return NULL;
+ }
Evan Martin 2009/10/26 23:57:42 curlies not necessary here
+
+ return new RefCountedStaticMemory(
+ reinterpret_cast<const unsigned char*>(piece.data()), piece.length());
+}
+
} // namespace base
« no previous file with comments | « base/data_pack.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698