diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-20 21:22:37 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-20 21:22:37 +0000 |
commit | 559fd2cc6db35d5dd473849836e5b31396936a73 (patch) | |
tree | e0cde62d5b6f120f64e1861299f8ae857278190c | |
parent | 2306bbd5843b30f4e78a9342b60d580dce083794 (diff) | |
download | chromium_src-559fd2cc6db35d5dd473849836e5b31396936a73.zip chromium_src-559fd2cc6db35d5dd473849836e5b31396936a73.tar.gz chromium_src-559fd2cc6db35d5dd473849836e5b31396936a73.tar.bz2 |
generate test_shell.pak and hook up loading net resources from
test_shell.pak. Move the net resource loading into the platform
specific files (still a stub on osx).
Review URL: http://codereview.chromium.org/18186
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8321 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/data_pack.h | 2 | ||||
-rw-r--r-- | net/base/net_util.cc | 6 | ||||
-rw-r--r-- | webkit/tools/test_shell/SConscript | 16 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.h | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_gtk.cc | 20 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_mac.mm | 8 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_main.cc | 18 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_win.cc | 15 |
8 files changed, 70 insertions, 19 deletions
diff --git a/base/data_pack.h b/base/data_pack.h index 1836552..ff4f6d9 100644 --- a/base/data_pack.h +++ b/base/data_pack.h @@ -39,6 +39,8 @@ class DataPack { // Number of resources in the data. size_t resource_count_; + + DISALLOW_COPY_AND_ASSIGN(DataPack); }; } // namespace base diff --git a/net/base/net_util.cc b/net/base/net_util.cc index 6b24fe7..16adb8a 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -807,15 +807,15 @@ std::string CanonicalizeHost(const std::wstring& host, bool* is_ip_address) { } std::string GetDirectoryListingHeader(const std::string& title) { -#if defined(OS_WIN) +#if defined(OS_WIN) || defined(OS_LINUX) static const StringPiece header(NetModule::GetResource(IDR_DIR_HEADER_HTML)); if (header.empty()) { NOTREACHED() << "expected resource not found"; } std::string result(header.data(), header.size()); -#elif defined(OS_POSIX) +#elif defined(OS_MACOSX) // TODO(estade): Temporary hack. Remove these platform #ifdefs when we - // have implemented resources for non-Windows platforms. + // have implemented resources for OSX. LOG(INFO) << "FIXME: hacked resource loading"; FilePath path; PathService::Get(base::DIR_EXE, &path); diff --git a/webkit/tools/test_shell/SConscript b/webkit/tools/test_shell/SConscript index 4a81850..c3d57ac 100644 --- a/webkit/tools/test_shell/SConscript +++ b/webkit/tools/test_shell/SConscript @@ -194,6 +194,22 @@ env.Alias('webkit', i) if env.Bit('windows'): env.Depends(test_shell, '$V8_DIR/vc80.pdb') +if env.Bit('linux'): + # Build the linux resource file. + env.Append(BUILDERS = { 'Repack' : Builder( + action = 'python $CHROME_SRC_DIR/tools/data_pack/repack.py $TARGET $SOURCES', + )}) + test_shell_data = env.Repack( + '$TARGET_ROOT/test_shell.pak', + ['$TARGET_ROOT/grit_derived_sources/net_resources.pak', + '$TARGET_ROOT/grit_derived_sources/webkit_resources.pak', + ] + ) + env.Depends(test_shell, test_shell_data) + + i = env.Install('$DESTINATION_ROOT', test_shell_data) + env.Alias('webkit', i) + test_files = [ 'image_decoder_unittest.cc', 'keyboard_unittest.cc', diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h index 79ab497..ce25eb9 100644 --- a/webkit/tools/test_shell/test_shell.h +++ b/webkit/tools/test_shell/test_shell.h @@ -48,6 +48,7 @@ typedef std::list<gfx::NativeWindow> WindowList; struct WebPreferences; +class StringPiece; class TestNavigationEntry; class TestNavigationController; @@ -252,6 +253,9 @@ public: // Show the "attach to me" dialog, for debugging test shell startup. static void ShowStartupDebuggingDialog(); + // This is called indirectly by the network layer to access resources. + static StringPiece NetResourceProvider(int key); + protected: bool Initialize(const std::wstring& startingURL); void SizeToSVG(); diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc index 972256e..f1087a8 100644 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -11,10 +11,12 @@ #include <signal.h> #include <unistd.h> +#include "base/data_pack.h" #include "base/file_path.h" #include "base/file_util.h" #include "base/message_loop.h" #include "base/path_service.h" +#include "base/string_piece.h" #include "base/string_util.h" #include "net/base/mime_util.h" #include "net/base/net_util.h" @@ -616,6 +618,24 @@ void TestShell::ShowStartupDebuggingDialog() { gtk_widget_destroy(dialog); } +// static +StringPiece TestShell::NetResourceProvider(int key) { + static scoped_ptr<base::DataPack> resource_data_pack; + + if (!resource_data_pack.get()) { + resource_data_pack.reset(new base::DataPack); + FilePath data_path; + PathService::Get(base::DIR_EXE, &data_path); + data_path = data_path.Append("test_shell.pak"); + bool success = resource_data_pack->Load(data_path); + CHECK(success) << "failed to load test_shell.pak"; + } + + StringPiece res; + resource_data_pack->Get(key, &res); + return res; +} + //----------------------------------------------------------------------------- namespace webkit_glue { diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm index 554f3c2..40a6fd2 100644 --- a/webkit/tools/test_shell/test_shell_mac.mm +++ b/webkit/tools/test_shell/test_shell_mac.mm @@ -15,11 +15,13 @@ #include "base/file_util.h" #include "base/gfx/size.h" #include "base/icu_util.h" +#include "base/logging.h" #include "base/mac_util.h" #include "base/memory_debug.h" #include "base/message_loop.h" #include "base/path_service.h" #include "base/stats_table.h" +#include "base/string_piece.h" #include "base/string_util.h" #include "net/base/mime_util.h" #include "skia/ext/bitmap_platform_device.h" @@ -859,6 +861,12 @@ void TestShell::ShowStartupDebuggingDialog() { // TODO(port): Show a modal dialog here with an attach to me message. } +StringPiece TestShell::NetResourceProvider(int key) { + // TODO(port): Return the requested resource. + NOTIMPLEMENTED(); + return StringPiece(); +} + //----------------------------------------------------------------------------- namespace webkit_glue { diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc index f3a051d..d24c42d 100644 --- a/webkit/tools/test_shell/test_shell_main.cc +++ b/webkit/tools/test_shell/test_shell_main.cc @@ -32,7 +32,6 @@ #include "base/process_util.h" #include "base/rand_util.h" #include "base/stats_table.h" -#include "base/string_piece.h" #include "base/string_util.h" #include "base/sys_info.h" #include "base/trace_event.h" @@ -60,19 +59,6 @@ static int kStatsFileThreads = 20; static int kStatsFileCounters = 200; #if defined(OS_WIN) -StringPiece GetRawDataResource(HMODULE module, int resource_id) { - void* data_ptr; - size_t data_size; - return base::GetDataResourceFromModule(module, resource_id, &data_ptr, - &data_size) ? - StringPiece(static_cast<char*>(data_ptr), data_size) : StringPiece(); -} - -// This is called indirectly by the network layer to access resources. -StringPiece NetResourceProvider(int key) { - return GetRawDataResource(::GetModuleHandle(NULL), key); -} - // This test approximates whether you have the Windows XP theme selected by // inspecting a couple of metrics. It does not catch all cases, but it does // pick up on classic vs xp, and normal vs large fonts. Something it misses @@ -224,10 +210,10 @@ int main(int argc, char* argv[]) { // Load ICU data tables icu_util::Initialize(); -#if defined(OS_WIN) // Config the network module so it has access to a limited set of resources. - net::NetModule::SetResourceProvider(NetResourceProvider); + net::NetModule::SetResourceProvider(TestShell::NetResourceProvider); +#if defined(OS_WIN) INITCOMMONCONTROLSEX InitCtrlEx; InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc index dd6682a..a6ba571 100644 --- a/webkit/tools/test_shell/test_shell_win.cc +++ b/webkit/tools/test_shell/test_shell_win.cc @@ -17,6 +17,7 @@ #include "base/path_service.h" #include "base/resource_util.h" #include "base/stack_container.h" +#include "base/string_piece.h" #include "base/string_util.h" #include "base/trace_event.h" #include "base/win_util.h" @@ -111,6 +112,14 @@ bool MinidumpCallback(const wchar_t *dumpPath, return false; } +StringPiece GetRawDataResource(HMODULE module, int resource_id) { + void* data_ptr; + size_t data_size; + return base::GetDataResourceFromModule(module, resource_id, &data_ptr, + &data_size) ? + StringPiece(static_cast<char*>(data_ptr), data_size) : StringPiece(); +} + } // namespace // Initialize static member variable @@ -690,6 +699,12 @@ void TestShell::ShowStartupDebuggingDialog() { MessageBox(NULL, L"attach to me?", L"test_shell", MB_OK); } +// static +StringPiece TestShell::NetResourceProvider(int key) { + return GetRawDataResource(::GetModuleHandle(NULL), key); +} + + ///////////////////////////////////////////////////////////////////////////// // WebKit glue functions |