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

Side by Side Diff: webkit/tools/test_shell/test_shell_webkit_init.h

Issue 2249005: AppCache: Use a dedicated thread for the disk cache. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Bound to IO thread 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
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 #ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_ 5 #ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_
6 #define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_ 6 #define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_
7 7
8 #include "base/file_util.h"
9 #include "base/path_service.h"
10 #include "base/platform_file.h"
11 #include "base/scoped_temp_dir.h"
12 #include "base/stats_counters.h"
13 #include "base/string_util.h"
14 #include "media/base/media.h"
15 #include "net/base/file_stream.h"
16 #include "third_party/WebKit/WebKit/chromium/public/WebData.h"
17 #include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h"
18 #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationServiceMock.h"
19 #include "third_party/WebKit/WebKit/chromium/public/WebGraphicsContext3D.h" 8 #include "third_party/WebKit/WebKit/chromium/public/WebGraphicsContext3D.h"
20 #include "third_party/WebKit/WebKit/chromium/public/WebIndexedDatabase.h" 9 #include "third_party/WebKit/WebKit/chromium/public/WebIndexedDatabase.h"
21 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h"
22 #include "third_party/WebKit/WebKit/chromium/public/WebRuntimeFeatures.h"
23 #include "third_party/WebKit/WebKit/chromium/public/WebScriptController.h"
24 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h"
25 #include "third_party/WebKit/WebKit/chromium/public/WebStorageArea.h"
26 #include "third_party/WebKit/WebKit/chromium/public/WebStorageEventDispatcher.h"
27 #include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h" 10 #include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h"
28 #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
29 #include "third_party/WebKit/WebKit/chromium/public/WebThemeEngine.h"
30 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
31 #include "webkit/database/vfs_backend.h"
32 #include "webkit/extensions/v8/gears_extension.h"
33 #include "webkit/extensions/v8/interval_extension.h"
34 #include "webkit/glue/webclipboard_impl.h" 11 #include "webkit/glue/webclipboard_impl.h"
35 #include "webkit/glue/webfilesystem_impl.h" 12 #include "webkit/glue/webfilesystem_impl.h"
36 #include "webkit/glue/webkit_glue.h" 13 #include "webkit/glue/webkit_glue.h"
37 #include "webkit/glue/webkitclient_impl.h" 14 #include "webkit/glue/webkitclient_impl.h"
38 #include "webkit/tools/test_shell/mock_webclipboard_impl.h" 15 #include "webkit/tools/test_shell/mock_webclipboard_impl.h"
39 #include "webkit/tools/test_shell/simple_appcache_system.h" 16 #include "webkit/tools/test_shell/simple_appcache_system.h"
40 #include "webkit/tools/test_shell/simple_database_system.h" 17 #include "webkit/tools/test_shell/simple_database_system.h"
41 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" 18 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
42 #include "webkit/tools/test_shell/simple_webcookiejar_impl.h" 19 #include "webkit/tools/test_shell/simple_webcookiejar_impl.h"
43 #include "webkit/tools/test_shell/test_shell_webmimeregistry_impl.h" 20 #include "webkit/tools/test_shell/test_shell_webmimeregistry_impl.h"
44 #include "v8/include/v8.h"
45 21
46 #if defined(OS_WIN) 22 #if defined(OS_WIN)
47 #include "webkit/tools/test_shell/test_shell_webthemeengine.h" 23 #include "webkit/tools/test_shell/test_shell_webthemeengine.h"
48 #endif 24 #endif
49 25
50 class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { 26 class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
51 public: 27 public:
52 explicit TestShellWebKitInit(bool layout_test_mode) { 28 explicit TestShellWebKitInit(bool layout_test_mode);
53 v8::V8::SetCounterFunction(StatsTable::FindLocation); 29 ~TestShellWebKitInit();
54
55 WebKit::initialize(this);
56 WebKit::setLayoutTestMode(layout_test_mode);
57 WebKit::WebSecurityPolicy::registerURLSchemeAsLocal(
58 WebKit::WebString::fromUTF8("test-shell-resource"));
59 WebKit::WebSecurityPolicy::registerURLSchemeAsNoAccess(
60 WebKit::WebString::fromUTF8("test-shell-resource"));
61 WebKit::WebScriptController::enableV8SingleThreadMode();
62 WebKit::WebScriptController::registerExtension(
63 extensions_v8::GearsExtension::Get());
64 WebKit::WebScriptController::registerExtension(
65 extensions_v8::IntervalExtension::Get());
66 WebKit::WebRuntimeFeatures::enableSockets(true);
67 WebKit::WebRuntimeFeatures::enableApplicationCache(true);
68 WebKit::WebRuntimeFeatures::enableDatabase(true);
69 WebKit::WebRuntimeFeatures::enableWebGL(true);
70 WebKit::WebRuntimeFeatures::enablePushState(true);
71 WebKit::WebRuntimeFeatures::enableNotifications(true);
72 WebKit::WebRuntimeFeatures::enableTouch(true);
73 WebKit::WebRuntimeFeatures::enableIndexedDatabase(true);
74
75 // Load libraries for media and enable the media player.
76 FilePath module_path;
77 WebKit::WebRuntimeFeatures::enableMediaPlayer(
78 PathService::Get(base::DIR_MODULE, &module_path) &&
79 media::InitializeMediaLibrary(module_path));
80
81 WebKit::WebRuntimeFeatures::enableGeolocation(true);
82
83 // Construct and initialize an appcache system for this scope.
84 // A new empty temp directory is created to house any cached
85 // content during the run. Upon exit that directory is deleted.
86 // If we can't create a tempdir, we'll use in-memory storage.
87 if (!appcache_dir_.CreateUniqueTempDir()) {
88 LOG(WARNING) << "Failed to create a temp dir for the appcache, "
89 "using in-memory storage.";
90 DCHECK(appcache_dir_.path().empty());
91 }
92 SimpleAppCacheSystem::InitializeOnUIThread(appcache_dir_.path());
93
94 WebKit::WebDatabase::setObserver(&database_system_);
95
96 file_system_.set_sandbox_enabled(false);
97
98 #if defined(OS_WIN)
99 // Ensure we pick up the default theme engine.
100 SetThemeEngine(NULL);
101 #endif
102 }
103
104 ~TestShellWebKitInit() {
105 WebKit::shutdown();
106 }
107 30
108 virtual WebKit::WebMimeRegistry* mimeRegistry() { 31 virtual WebKit::WebMimeRegistry* mimeRegistry() {
109 return &mime_registry_; 32 return &mime_registry_;
110 } 33 }
111 34
112 WebKit::WebClipboard* clipboard() { 35 WebKit::WebClipboard* clipboard();
113 // Mock out clipboard calls in layout test mode so that tests don't mess
114 // with each other's copies/pastes when running in parallel.
115 if (TestShell::layout_test_mode()) {
116 return &mock_clipboard_;
117 } else {
118 return &real_clipboard_;
119 }
120 }
121 36
122 virtual WebKit::WebFileSystem* fileSystem() { 37 virtual WebKit::WebFileSystem* fileSystem() {
123 return &file_system_; 38 return &file_system_;
124 } 39 }
125 40
126 virtual WebKit::WebSandboxSupport* sandboxSupport() { 41 virtual WebKit::WebSandboxSupport* sandboxSupport() {
127 return NULL; 42 return NULL;
128 } 43 }
129 44
130 virtual WebKit::WebCookieJar* cookieJar() { 45 virtual WebKit::WebCookieJar* cookieJar() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return false; 82 return false;
168 } 83 }
169 84
170 virtual WebKit::WebMessagePortChannel* createMessagePortChannel() { 85 virtual WebKit::WebMessagePortChannel* createMessagePortChannel() {
171 return NULL; 86 return NULL;
172 } 87 }
173 88
174 virtual void prefetchHostName(const WebKit::WebString&) { 89 virtual void prefetchHostName(const WebKit::WebString&) {
175 } 90 }
176 91
177 virtual WebKit::WebData loadResource(const char* name) { 92 virtual WebKit::WebData loadResource(const char* name);
178 if (!strcmp(name, "deleteButton")) {
179 // Create a red 30x30 square.
180 const char red_square[] =
181 "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52"
182 "\x00\x00\x00\x1e\x00\x00\x00\x1e\x04\x03\x00\x00\x00\xc9\x1e\xb3"
183 "\x91\x00\x00\x00\x30\x50\x4c\x54\x45\x00\x00\x00\x80\x00\x00\x00"
184 "\x80\x00\x80\x80\x00\x00\x00\x80\x80\x00\x80\x00\x80\x80\x80\x80"
185 "\x80\xc0\xc0\xc0\xff\x00\x00\x00\xff\x00\xff\xff\x00\x00\x00\xff"
186 "\xff\x00\xff\x00\xff\xff\xff\xff\xff\x7b\x1f\xb1\xc4\x00\x00\x00"
187 "\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a"
188 "\x9c\x18\x00\x00\x00\x17\x49\x44\x41\x54\x78\x01\x63\x98\x89\x0a"
189 "\x18\x50\xb9\x33\x47\xf9\xa8\x01\x32\xd4\xc2\x03\x00\x33\x84\x0d"
190 "\x02\x3a\x91\xeb\xa5\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60"
191 "\x82";
192 return WebKit::WebData(red_square, arraysize(red_square));
193 }
194 return webkit_glue::WebKitClientImpl::loadResource(name);
195 }
196 93
197 virtual WebKit::WebString defaultLocale() { 94 virtual WebKit::WebString defaultLocale() {
198 return ASCIIToUTF16("en-US"); 95 return ASCIIToUTF16("en-US");
199 } 96 }
200 97
201 virtual WebKit::WebStorageNamespace* createLocalStorageNamespace( 98 virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
202 const WebKit::WebString& path, unsigned quota) { 99 const WebKit::WebString& path, unsigned quota) {
203 // Enforce quota here, ignoring the value from the renderer as in Chrome. 100 // Enforce quota here, ignoring the value from the renderer as in Chrome.
204 return WebKit::WebStorageNamespace::createLocalStorageNamespace(path, 101 return WebKit::WebStorageNamespace::createLocalStorageNamespace(path,
205 WebKit::WebStorageNamespace::m_localStorageQuota); 102 WebKit::WebStorageNamespace::m_localStorageQuota);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 SimpleAppCacheSystem appcache_system_; 140 SimpleAppCacheSystem appcache_system_;
244 SimpleDatabaseSystem database_system_; 141 SimpleDatabaseSystem database_system_;
245 SimpleWebCookieJarImpl cookie_jar_; 142 SimpleWebCookieJarImpl cookie_jar_;
246 143
247 #if defined(OS_WIN) 144 #if defined(OS_WIN)
248 WebKit::WebThemeEngine* active_theme_engine_; 145 WebKit::WebThemeEngine* active_theme_engine_;
249 #endif 146 #endif
250 }; 147 };
251 148
252 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_ 149 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/test_shell_request_context.cc ('k') | webkit/tools/test_shell/test_shell_webkit_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698