OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // Creates an instance of the test_shell. | 5 // Creates an instance of the test_shell. |
6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
7 | 7 |
8 #include <stdlib.h> // required by _set_abort_behavior | 8 #include <stdlib.h> // required by _set_abort_behavior |
9 | 9 |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
25 #include "base/command_line.h" | 25 #include "base/command_line.h" |
26 #include "base/file_util.h" | 26 #include "base/file_util.h" |
27 #include "base/icu_util.h" | 27 #include "base/icu_util.h" |
28 #include "base/memory_debug.h" | 28 #include "base/memory_debug.h" |
29 #include "base/message_loop.h" | 29 #include "base/message_loop.h" |
30 #include "base/path_service.h" | 30 #include "base/path_service.h" |
31 #include "base/process_util.h" | 31 #include "base/process_util.h" |
32 #include "base/rand_util.h" | 32 #include "base/rand_util.h" |
33 #include "base/stats_table.h" | 33 #include "base/stats_table.h" |
| 34 #include "base/string_piece.h" |
34 #include "base/string_util.h" | 35 #include "base/string_util.h" |
35 #include "base/sys_info.h" | 36 #include "base/sys_info.h" |
36 #include "base/trace_event.h" | 37 #include "base/trace_event.h" |
37 #include "net/base/cookie_monster.h" | 38 #include "net/base/cookie_monster.h" |
38 #include "net/base/net_module.h" | 39 #include "net/base/net_module.h" |
39 #include "net/http/http_cache.h" | 40 #include "net/http/http_cache.h" |
40 #include "net/url_request/url_request_context.h" | 41 #include "net/url_request/url_request_context.h" |
41 #include "webkit/glue/webkit_glue.h" | 42 #include "webkit/glue/webkit_glue.h" |
42 #include "webkit/glue/window_open_disposition.h" | 43 #include "webkit/glue/window_open_disposition.h" |
43 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 44 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
44 #include "webkit/tools/test_shell/test_shell.h" | 45 #include "webkit/tools/test_shell/test_shell.h" |
45 #include "webkit/tools/test_shell/test_shell_request_context.h" | 46 #include "webkit/tools/test_shell/test_shell_request_context.h" |
46 #include "webkit/tools/test_shell/test_shell_switches.h" | 47 #include "webkit/tools/test_shell/test_shell_switches.h" |
47 | 48 |
48 #include <iostream> | 49 #include <iostream> |
49 using namespace std; | 50 using namespace std; |
50 | 51 |
51 static const size_t kPathBufSize = 2048; | 52 static const size_t kPathBufSize = 2048; |
52 | 53 |
53 namespace { | 54 namespace { |
54 | 55 |
55 // StatsTable initialization parameters. | 56 // StatsTable initialization parameters. |
56 static const wchar_t* kStatsFilePrefix = L"testshell_"; | 57 static const wchar_t* kStatsFilePrefix = L"testshell_"; |
57 static int kStatsFileThreads = 20; | 58 static int kStatsFileThreads = 20; |
58 static int kStatsFileCounters = 200; | 59 static int kStatsFileCounters = 200; |
59 | 60 |
60 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
61 std::string GetDataResource(HMODULE module, int resource_id) { | 62 StringPiece GetRawDataResource(HMODULE module, int resource_id) { |
62 void* data_ptr; | 63 void* data_ptr; |
63 size_t data_size; | 64 size_t data_size; |
64 return base::GetDataResourceFromModule(module, resource_id, &data_ptr, | 65 return base::GetDataResourceFromModule(module, resource_id, &data_ptr, |
65 &data_size) ? | 66 &data_size) ? |
66 std::string(static_cast<char*>(data_ptr), data_size) : std::string(); | 67 StringPiece(static_cast<char*>(data_ptr), data_size) : StringPiece(); |
67 } | 68 } |
68 | 69 |
69 // This is called indirectly by the network layer to access resources. | 70 // This is called indirectly by the network layer to access resources. |
70 std::string NetResourceProvider(int key) { | 71 StringPiece NetResourceProvider(int key) { |
71 return GetDataResource(::GetModuleHandle(NULL), key); | 72 return GetRawDataResource(::GetModuleHandle(NULL), key); |
72 } | 73 } |
73 #endif | 74 #endif |
74 | 75 |
75 } // namespace | 76 } // namespace |
76 | 77 |
77 | 78 |
78 int main(int argc, char* argv[]) { | 79 int main(int argc, char* argv[]) { |
79 base::EnableTerminationOnHeapCorruption(); | 80 base::EnableTerminationOnHeapCorruption(); |
80 #ifdef _CRTDBG_MAP_ALLOC | 81 #ifdef _CRTDBG_MAP_ALLOC |
81 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); | 82 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 325 |
325 // Tear down shared StatsTable; prevents unit_tests from leaking it. | 326 // Tear down shared StatsTable; prevents unit_tests from leaking it. |
326 StatsTable::set_current(NULL); | 327 StatsTable::set_current(NULL); |
327 delete table; | 328 delete table; |
328 | 329 |
329 #ifdef _CRTDBG_MAP_ALLOC | 330 #ifdef _CRTDBG_MAP_ALLOC |
330 _CrtDumpMemoryLeaks(); | 331 _CrtDumpMemoryLeaks(); |
331 #endif | 332 #endif |
332 return 0; | 333 return 0; |
333 } | 334 } |
OLD | NEW |