summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/app.gyp1
-rw-r--r--app/app_base.gypi2
-rw-r--r--app/data_pack.cc (renamed from base/data_pack.cc)17
-rw-r--r--app/data_pack.h (renamed from base/data_pack.h)24
-rw-r--r--app/data_pack_unittest.cc (renamed from base/data_pack_unittest.cc)16
-rw-r--r--app/resource_bundle.cc4
-rw-r--r--app/resource_bundle.h6
-rw-r--r--app/resource_bundle_posix.cc6
-rw-r--r--app/resource_bundle_win.cc2
-rw-r--r--app/test/data/data_pack_unittest/sample.pak (renamed from base/data/data_pack_unittest/sample.pak)bin80 -> 80 bytes
-rw-r--r--base/base.gyp1
-rw-r--r--base/base.gypi1
-rw-r--r--chrome/browser/themes/browser_theme_pack.cc8
-rw-r--r--chrome/browser/themes/browser_theme_pack.h4
-rw-r--r--chrome/tools/mac_helpers/infoplist_strings_util.mm18
-rw-r--r--webkit/support/platform_support_gtk.cc6
-rw-r--r--webkit/support/platform_support_mac.mm6
-rw-r--r--webkit/tools/test_shell/test_shell_gtk.cc6
-rw-r--r--webkit/tools/test_shell/test_shell_mac.mm6
19 files changed, 73 insertions, 61 deletions
diff --git a/app/app.gyp b/app/app.gyp
index 1527c55..e34f161 100644
--- a/app/app.gyp
+++ b/app/app.gyp
@@ -41,6 +41,7 @@
'animation_container_unittest.cc',
'animation_unittest.cc',
'clipboard/clipboard_unittest.cc',
+ 'data_pack_unittest.cc',
'l10n_util_mac_unittest.mm',
'l10n_util_unittest.cc',
'multi_animation_unittest.cc',
diff --git a/app/app_base.gypi b/app/app_base.gypi
index cc2c0e6..60159ac 100644
--- a/app/app_base.gypi
+++ b/app/app_base.gypi
@@ -115,6 +115,8 @@
'clipboard/scoped_clipboard_writer.cc',
'clipboard/scoped_clipboard_writer.h',
'combobox_model.h',
+ 'data_pack.cc',
+ 'data_pack.h',
'drag_drop_types_gtk.cc',
'drag_drop_types_win.cc',
'drag_drop_types.h',
diff --git a/base/data_pack.cc b/app/data_pack.cc
index e01318f..93f7e82 100644
--- a/base/data_pack.cc
+++ b/app/data_pack.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/data_pack.h"
+#include "app/data_pack.h"
#include <errno.h>
@@ -59,7 +59,7 @@ enum LoadErrors {
} // anonymous namespace
-namespace base {
+namespace app {
// In .cc for MemoryMappedFile dtor.
DataPack::DataPack() : resource_count_(0) {
@@ -118,7 +118,8 @@ bool DataPack::Load(const FilePath& path) {
return true;
}
-bool DataPack::GetStringPiece(uint32 resource_id, StringPiece* data) const {
+bool DataPack::GetStringPiece(uint32 resource_id,
+ base::StringPiece* data) const {
// It won't be hard to make this endian-agnostic, but it's not worth
// bothering to do right now.
#if defined(__BYTE_ORDER)
@@ -152,7 +153,7 @@ RefCountedStaticMemory* DataPack::GetStaticMemory(uint32 resource_id) const {
// static
bool DataPack::WritePack(const FilePath& path,
- const std::map<uint32, StringPiece>& resources) {
+ const std::map<uint32, base::StringPiece>& resources) {
FILE* file = file_util::OpenFile(path, "wb");
if (!file)
return false;
@@ -175,7 +176,8 @@ bool DataPack::WritePack(const FilePath& path,
// Each entry is 3 uint32s.
uint32 index_length = entry_count * 3 * kWord;
uint32 data_offset = kHeaderLength + index_length;
- for (std::map<uint32, StringPiece>::const_iterator it = resources.begin();
+ for (std::map<uint32, base::StringPiece>::const_iterator it =
+ resources.begin();
it != resources.end(); ++it) {
if (fwrite(&it->first, 1, kWord, file) != kWord) {
LOG(ERROR) << "Failed to write id for " << it->first;
@@ -199,7 +201,8 @@ bool DataPack::WritePack(const FilePath& path,
data_offset += len;
}
- for (std::map<uint32, StringPiece>::const_iterator it = resources.begin();
+ for (std::map<uint32, base::StringPiece>::const_iterator it =
+ resources.begin();
it != resources.end(); ++it) {
if (fwrite(it->second.data(), it->second.length(), 1, file) != 1) {
LOG(ERROR) << "Failed to write data for " << it->first;
@@ -213,4 +216,4 @@ bool DataPack::WritePack(const FilePath& path,
return true;
}
-} // namespace base
+} // namespace app
diff --git a/base/data_pack.h b/app/data_pack.h
index 2836715..aeeee98 100644
--- a/base/data_pack.h
+++ b/app/data_pack.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,8 +6,8 @@
// (key, value) pairs of data. It's used to store static resources like
// translation strings and images.
-#ifndef BASE_DATA_PACK_H_
-#define BASE_DATA_PACK_H_
+#ifndef APP_DATA_PACK_H_
+#define APP_DATA_PACK_H_
#pragma once
#include <map>
@@ -15,15 +15,19 @@
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
+namespace base {
+class StringPiece;
+}
+
namespace file_util {
- class MemoryMappedFile;
+class MemoryMappedFile;
}
+
class FilePath;
class RefCountedStaticMemory;
-namespace base {
-class StringPiece;
+namespace app {
class DataPack {
public:
@@ -36,7 +40,7 @@ class DataPack {
// Get resource by id |resource_id|, filling in |data|.
// The data is owned by the DataPack object and should not be modified.
// Returns false if the resource id isn't found.
- bool GetStringPiece(uint32 resource_id, StringPiece* data) const;
+ bool GetStringPiece(uint32 resource_id, base::StringPiece* data) const;
// Like GetStringPiece(), but returns a reference to memory. This interface
// is used for image data, while the StringPiece interface is usually used
@@ -45,7 +49,7 @@ class DataPack {
// Writes a pack file containing |resources| to |path|.
static bool WritePack(const FilePath& path,
- const std::map<uint32, StringPiece>& resources);
+ const std::map<uint32, base::StringPiece>& resources);
private:
// The memory-mapped data.
@@ -57,6 +61,6 @@ class DataPack {
DISALLOW_COPY_AND_ASSIGN(DataPack);
};
-} // namespace base
+} // namespace app
-#endif // BASE_DATA_PACK_H_
+#endif // APP_DATA_PACK_H_
diff --git a/base/data_pack_unittest.cc b/app/data_pack_unittest.cc
index d089b28..83521ff 100644
--- a/base/data_pack_unittest.cc
+++ b/app/data_pack_unittest.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/data_pack.h"
+#include "app/data_pack.h"
#include "base/file_path.h"
#include "base/file_util.h"
@@ -11,13 +11,15 @@
#include "base/string_piece.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace app {
+
TEST(DataPackTest, Load) {
FilePath data_path;
PathService::Get(base::DIR_SOURCE_ROOT, &data_path);
data_path = data_path.Append(
- FILE_PATH_LITERAL("base/data/data_pack_unittest/sample.pak"));
+ FILE_PATH_LITERAL("app/test/data/data_pack_unittest/sample.pak"));
- base::DataPack pack;
+ DataPack pack;
ASSERT_TRUE(pack.Load(data_path));
base::StringPiece data;
@@ -53,10 +55,10 @@ TEST(DataPackTest, Write) {
resources.insert(std::make_pair(15, base::StringPiece(fifteen)));
resources.insert(std::make_pair(3, base::StringPiece(three)));
resources.insert(std::make_pair(4, base::StringPiece(four)));
- ASSERT_TRUE(base::DataPack::WritePack(file, resources));
+ ASSERT_TRUE(DataPack::WritePack(file, resources));
// Now try to read the data back in.
- base::DataPack pack;
+ DataPack pack;
ASSERT_TRUE(pack.Load(file));
base::StringPiece data;
@@ -71,3 +73,5 @@ TEST(DataPackTest, Write) {
ASSERT_TRUE(pack.GetStringPiece(15, &data));
EXPECT_EQ(fifteen, data);
}
+
+} // namespace app
diff --git a/app/resource_bundle.cc b/app/resource_bundle.cc
index ab34609..b0e79ed 100644
--- a/app/resource_bundle.cc
+++ b/app/resource_bundle.cc
@@ -4,7 +4,7 @@
#include "app/resource_bundle.h"
-#include "base/data_pack.h"
+#include "app/data_pack.h"
#include "base/lock.h"
#include "base/logging.h"
#include "base/string_piece.h"
@@ -246,7 +246,7 @@ ResourceBundle::LoadedDataPack::~LoadedDataPack() {
void ResourceBundle::LoadedDataPack::Load() {
DCHECK(!data_pack_.get());
- data_pack_.reset(new base::DataPack);
+ data_pack_.reset(new app::DataPack);
bool success = data_pack_->Load(path_);
CHECK(success) << "Failed to load " << path_.value();
}
diff --git a/app/resource_bundle.h b/app/resource_bundle.h
index 19905c2..d2c2d59 100644
--- a/app/resource_bundle.h
+++ b/app/resource_bundle.h
@@ -23,7 +23,7 @@
#include "base/string16.h"
#include "gfx/native_widget_types.h"
-namespace base {
+namespace app {
class DataPack;
}
#if defined(USE_X11)
@@ -178,7 +178,7 @@ class ResourceBundle {
private:
void Load();
- scoped_ptr<base::DataPack> data_pack_;
+ scoped_ptr<app::DataPack> data_pack_;
FilePath path_;
DISALLOW_COPY_AND_ASSIGN(LoadedDataPack);
@@ -191,7 +191,7 @@ class ResourceBundle {
typedef HINSTANCE DataHandle;
#elif defined(USE_BASE_DATA_PACK)
// Linux uses base::DataPack.
- typedef base::DataPack* DataHandle;
+ typedef app::DataPack* DataHandle;
#endif
// Ctor/dtor are private, since we're a singleton.
diff --git a/app/resource_bundle_posix.cc b/app/resource_bundle_posix.cc
index 9944280..f3c868b 100644
--- a/app/resource_bundle_posix.cc
+++ b/app/resource_bundle_posix.cc
@@ -4,8 +4,8 @@
#include "app/resource_bundle.h"
+#include "app/data_pack.h"
#include "app/l10n_util.h"
-#include "base/data_pack.h"
#include "base/lock.h"
#include "base/logging.h"
#include "base/stl_util-inl.h"
@@ -15,8 +15,8 @@
namespace {
-base::DataPack* LoadResourcesDataPak(FilePath resources_pak_path) {
- base::DataPack* resources_pak = new base::DataPack;
+app::DataPack* LoadResourcesDataPak(FilePath resources_pak_path) {
+ app::DataPack* resources_pak = new app::DataPack;
bool success = resources_pak->Load(resources_pak_path);
if (!success) {
delete resources_pak;
diff --git a/app/resource_bundle_win.cc b/app/resource_bundle_win.cc
index fbc40b4..5527160 100644
--- a/app/resource_bundle_win.cc
+++ b/app/resource_bundle_win.cc
@@ -7,8 +7,8 @@
#include <atlbase.h>
#include "app/app_paths.h"
+#include "app/data_pack.h"
#include "app/l10n_util.h"
-#include "base/data_pack.h"
#include "base/debug_util.h"
#include "base/debug/stack_trace.h"
#include "base/file_util.h"
diff --git a/base/data/data_pack_unittest/sample.pak b/app/test/data/data_pack_unittest/sample.pak
index fdbe2b5..fdbe2b5 100644
--- a/base/data/data_pack_unittest/sample.pak
+++ b/app/test/data/data_pack_unittest/sample.pak
Binary files differ
diff --git a/base/base.gyp b/base/base.gyp
index 562aedf..075561b 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -74,7 +74,6 @@
'crypto/signature_creator_unittest.cc',
'crypto/signature_verifier_unittest.cc',
'crypto/symmetric_key_unittest.cc',
- 'data_pack_unittest.cc',
'debug/leak_tracker_unittest.cc',
'debug/stack_trace_unittest.cc',
'debug/trace_event_win_unittest.cc',
diff --git a/base/base.gypi b/base/base.gypi
index f4f32b0..3eaedfa 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -605,7 +605,6 @@
'auto_reset.h',
'base64.cc',
'base64.h',
- 'data_pack.cc',
'event_recorder.cc',
'event_recorder.h',
'event_recorder_stubs.cc',
diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc
index 62f09ef..6333900 100644
--- a/chrome/browser/themes/browser_theme_pack.cc
+++ b/chrome/browser/themes/browser_theme_pack.cc
@@ -4,8 +4,8 @@
#include "chrome/browser/themes/browser_theme_pack.h"
+#include "app/data_pack.h"
#include "app/resource_bundle.h"
-#include "base/data_pack.h"
#include "base/stl_util-inl.h"
#include "base/string_util.h"
#include "base/thread_restrictions.h"
@@ -370,7 +370,7 @@ scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromDataPack(
FilePath path, const std::string& expected_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
scoped_refptr<BrowserThemePack> pack(new BrowserThemePack);
- pack->data_pack_.reset(new base::DataPack);
+ pack->data_pack_.reset(new app::DataPack);
if (!pack->data_pack_->Load(path)) {
LOG(ERROR) << "Failed to load theme data pack.";
@@ -448,7 +448,7 @@ bool BrowserThemePack::WriteToDisk(FilePath path) const {
RepackImages(prepared_images_, &reencoded_images);
AddRawImagesTo(reencoded_images, &resources);
- return base::DataPack::WritePack(path, resources);
+ return app::DataPack::WritePack(path, resources);
}
bool BrowserThemePack::GetTint(int id, color_utils::HSL* hsl) const {
@@ -583,7 +583,7 @@ void BrowserThemePack::BuildHeader(const Extension* extension) {
header_->version = kThemePackVersion;
// TODO(erg): Need to make this endian safe on other computers. Prerequisite
- // is that base::DataPack removes this same check.
+ // is that app::DataPack removes this same check.
#if defined(__BYTE_ORDER)
// Linux check
COMPILE_ASSERT(__BYTE_ORDER == __LITTLE_ENDIAN,
diff --git a/chrome/browser/themes/browser_theme_pack.h b/chrome/browser/themes/browser_theme_pack.h
index 3771462..b90f30a 100644
--- a/chrome/browser/themes/browser_theme_pack.h
+++ b/chrome/browser/themes/browser_theme_pack.h
@@ -16,7 +16,7 @@
#include "chrome/browser/browser_thread.h"
#include "chrome/common/extensions/extension.h"
-namespace base {
+namespace app {
class DataPack;
}
class DictionaryValue;
@@ -170,7 +170,7 @@ class BrowserThemePack : public base::RefCountedThreadSafe<
color_utils::HSL GetTintInternal(int id) const;
// Data pack, if we have one.
- scoped_ptr<base::DataPack> data_pack_;
+ scoped_ptr<app::DataPack> data_pack_;
// All structs written to disk need to be packed; no alignment tricks here,
// please.
diff --git a/chrome/tools/mac_helpers/infoplist_strings_util.mm b/chrome/tools/mac_helpers/infoplist_strings_util.mm
index d086444..727932f 100644
--- a/chrome/tools/mac_helpers/infoplist_strings_util.mm
+++ b/chrome/tools/mac_helpers/infoplist_strings_util.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,7 +11,7 @@
#include <stdio.h>
#include <unistd.h>
-#include "base/data_pack.h"
+#include "app/data_pack.h"
#include "base/file_path.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/scoped_ptr.h"
@@ -51,16 +51,16 @@ NSString* ApplicationVersionString(const char* version_file_path) {
return nil;
}
-base::DataPack* LoadResourceDataPack(const char* dir_path,
- const char* branding_strings_name,
- const char* locale_name) {
- base::DataPack* resource_pack = NULL;
+app::DataPack* LoadResourceDataPack(const char* dir_path,
+ const char* branding_strings_name,
+ const char* locale_name) {
+ app::DataPack* resource_pack = NULL;
NSString* resource_path = [NSString stringWithFormat:@"%s/%s_%s.pak",
dir_path, branding_strings_name, locale_name];
if (resource_path) {
FilePath resources_pak_path([resource_path fileSystemRepresentation]);
- resource_pack = new base::DataPack;
+ resource_pack = new app::DataPack;
bool success = resource_pack->Load(resources_pak_path);
if (!success) {
delete resource_pack;
@@ -71,7 +71,7 @@ base::DataPack* LoadResourceDataPack(const char* dir_path,
return resource_pack;
}
-NSString* LoadStringFromDataPack(base::DataPack* data_pack,
+NSString* LoadStringFromDataPack(app::DataPack* data_pack,
const char* data_pack_lang,
uint32_t resource_id,
const char* resource_id_str) {
@@ -204,7 +204,7 @@ int main(int argc, char* const argv[]) {
const char* cur_lang = lang_list[loop];
// Open the branded string pak file
- scoped_ptr<base::DataPack> branded_data_pack(
+ scoped_ptr<app::DataPack> branded_data_pack(
LoadResourceDataPack(grit_output_dir,
branding_strings_name,
cur_lang));
diff --git a/webkit/support/platform_support_gtk.cc b/webkit/support/platform_support_gtk.cc
index f9f177f..2ab9627 100644
--- a/webkit/support/platform_support_gtk.cc
+++ b/webkit/support/platform_support_gtk.cc
@@ -4,7 +4,7 @@
#include "webkit/support/platform_support.h"
-#include "base/data_pack.h"
+#include "app/data_pack.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
@@ -16,7 +16,7 @@
namespace {
// Data resources on linux. This is a pointer to the mmapped resources file.
-base::DataPack* g_resource_data_pack = NULL;
+app::DataPack* g_resource_data_pack = NULL;
}
@@ -31,7 +31,7 @@ void BeforeInitialize(bool unit_test_mode) {
void AfterInitialize(bool unit_test_mode) {
if (unit_test_mode)
return; // We don't have a resource pack when running the unit-tests.
- g_resource_data_pack = new base::DataPack;
+ g_resource_data_pack = new app::DataPack;
FilePath data_path;
PathService::Get(base::DIR_EXE, &data_path);
data_path = data_path.Append("DumpRenderTree.pak");
diff --git a/webkit/support/platform_support_mac.mm b/webkit/support/platform_support_mac.mm
index 8ff15a7..0e9000f 100644
--- a/webkit/support/platform_support_mac.mm
+++ b/webkit/support/platform_support_mac.mm
@@ -8,8 +8,8 @@
#import <Foundation/Foundation.h>
#import <objc/objc-runtime.h>
+#include "app/data_pack.h"
#include "base/base_paths.h"
-#include "base/data_pack.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/mac_util.h"
@@ -21,7 +21,7 @@
#import "webkit/support/drt_application_mac.h"
#import "webkit/tools/test_shell/mac/DumpRenderTreePasteboard.h"
-static base::DataPack* g_resource_data_pack = NULL;
+static app::DataPack* g_resource_data_pack = NULL;
namespace webkit_support {
@@ -102,7 +102,7 @@ void AfterInitialize(bool unit_test_mode) {
return; // We don't have a resource pack when running the unit-tests.
// Load a data pack.
- g_resource_data_pack = new base::DataPack;
+ g_resource_data_pack = new app::DataPack;
NSString* resource_path =
[mac_util::MainAppBundle() pathForResource:@"DumpRenderTree"
ofType:@"pak"];
diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc
index 38c0dad..cc38e1f 100644
--- a/webkit/tools/test_shell/test_shell_gtk.cc
+++ b/webkit/tools/test_shell/test_shell_gtk.cc
@@ -11,7 +11,7 @@
#include <signal.h>
#include <unistd.h>
-#include "base/data_pack.h"
+#include "app/data_pack.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/message_loop.h"
@@ -45,7 +45,7 @@ const FcChar8* FilePathAsFcChar(const FilePath& path) {
}
// Data resources on linux. This is a pointer to the mmapped resources file.
-base::DataPack* g_resource_data_pack = NULL;
+app::DataPack* g_resource_data_pack = NULL;
void TerminationSignalHandler(int signatl) {
TestShell::ShutdownTestShell();
@@ -159,7 +159,7 @@ void TestShell::InitializeTestShell(bool layout_test_mode,
web_prefs_ = new WebPreferences;
- g_resource_data_pack = new base::DataPack;
+ g_resource_data_pack = new app::DataPack;
FilePath data_path;
PathService::Get(base::DIR_EXE, &data_path);
data_path = data_path.Append("test_shell.pak");
diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm
index 249ccba..f05089c 100644
--- a/webkit/tools/test_shell/test_shell_mac.mm
+++ b/webkit/tools/test_shell/test_shell_mac.mm
@@ -9,9 +9,9 @@
#include "webkit/tools/test_shell/test_shell.h"
+#include "app/data_pack.h"
#include "base/base_paths.h"
#include "base/basictypes.h"
-#include "base/data_pack.h"
#include "base/debug_on_start.h"
#include "base/debug/debugger.h"
#include "base/file_path.h"
@@ -70,7 +70,7 @@ const int kTestWindowXLocation = -14000;
const int kTestWindowYLocation = -14000;
// Data pack resource. This is a pointer to the mmapped resources file.
-static base::DataPack* g_resource_data_pack = NULL;
+static app::DataPack* g_resource_data_pack = NULL;
// Define static member variables
base::LazyInstance <std::map<gfx::NativeWindow, TestShell *> >
@@ -210,7 +210,7 @@ void TestShell::InitializeTestShell(bool layout_test_mode,
// mmap the data pack which holds strings used by WebCore. This is only
// a fatal error if we're bundled, which means we might be running layout
// tests. This is a harmless failure for test_shell_tests.
- g_resource_data_pack = new base::DataPack;
+ g_resource_data_pack = new app::DataPack;
NSString *resource_path =
[mac_util::MainAppBundle() pathForResource:@"test_shell"
ofType:@"pak"];