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

Side by Side Diff: Source/web/WebKit.cpp

Issue 398673003: Rename WebCore namespace to blink in bindings and web (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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
« no previous file with comments | « Source/web/WebInputEventConversion.cpp ('k') | Source/web/WebLabelElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "web/IndexedDBClientImpl.h" 57 #include "web/IndexedDBClientImpl.h"
58 #include "web/WebMediaPlayerClientImpl.h" 58 #include "web/WebMediaPlayerClientImpl.h"
59 #include "wtf/Assertions.h" 59 #include "wtf/Assertions.h"
60 #include "wtf/CryptographicallyRandomNumber.h" 60 #include "wtf/CryptographicallyRandomNumber.h"
61 #include "wtf/MainThread.h" 61 #include "wtf/MainThread.h"
62 #include "wtf/WTF.h" 62 #include "wtf/WTF.h"
63 #include "wtf/text/AtomicString.h" 63 #include "wtf/text/AtomicString.h"
64 #include "wtf/text/TextEncoding.h" 64 #include "wtf/text/TextEncoding.h"
65 #include <v8.h> 65 #include <v8.h>
66 66
67 using WebCore::LayoutTestSupport; 67 using blink::LayoutTestSupport;
68 68
69 namespace blink { 69 namespace blink {
70 70
71 namespace { 71 namespace {
72 72
73 class EndOfTaskRunner : public WebThread::TaskObserver { 73 class EndOfTaskRunner : public WebThread::TaskObserver {
74 public: 74 public:
75 virtual void willProcessTask() OVERRIDE 75 virtual void willProcessTask() OVERRIDE
76 { 76 {
77 WebCore::AnimationClock::notifyTaskStart(); 77 blink::AnimationClock::notifyTaskStart();
78 } 78 }
79 virtual void didProcessTask() OVERRIDE 79 virtual void didProcessTask() OVERRIDE
80 { 80 {
81 WebCore::Microtask::performCheckpoint(); 81 blink::Microtask::performCheckpoint();
82 WebCore::V8GCController::reportDOMMemoryUsageToV8(mainThreadIsolate()); 82 blink::V8GCController::reportDOMMemoryUsageToV8(mainThreadIsolate());
83 } 83 }
84 }; 84 };
85 85
86 } // namespace 86 } // namespace
87 87
88 static WebThread::TaskObserver* s_endOfTaskRunner = 0; 88 static WebThread::TaskObserver* s_endOfTaskRunner = 0;
89 static WebThread::TaskObserver* s_pendingGCRunner = 0; 89 static WebThread::TaskObserver* s_pendingGCRunner = 0;
90 static WebCore::ThreadState::Interruptor* s_messageLoopInterruptor = 0; 90 static blink::ThreadState::Interruptor* s_messageLoopInterruptor = 0;
91 static WebCore::ThreadState::Interruptor* s_isolateInterruptor = 0; 91 static blink::ThreadState::Interruptor* s_isolateInterruptor = 0;
92 92
93 // Make sure we are not re-initialized in the same address space. 93 // Make sure we are not re-initialized in the same address space.
94 // Doing so may cause hard to reproduce crashes. 94 // Doing so may cause hard to reproduce crashes.
95 static bool s_webKitInitialized = false; 95 static bool s_webKitInitialized = false;
96 96
97 static bool generateEntropy(unsigned char* buffer, size_t length) 97 static bool generateEntropy(unsigned char* buffer, size_t length)
98 { 98 {
99 if (Platform::current()) { 99 if (Platform::current()) {
100 Platform::current()->cryptographicallyRandomValues(buffer, length); 100 Platform::current()->cryptographicallyRandomValues(buffer, length);
101 return true; 101 return true;
102 } 102 }
103 return false; 103 return false;
104 } 104 }
105 105
106 void initialize(Platform* platform) 106 void initialize(Platform* platform)
107 { 107 {
108 initializeWithoutV8(platform); 108 initializeWithoutV8(platform);
109 109
110 v8::V8::InitializePlatform(gin::V8Platform::Get()); 110 v8::V8::InitializePlatform(gin::V8Platform::Get());
111 v8::Isolate* isolate = v8::Isolate::New(); 111 v8::Isolate* isolate = v8::Isolate::New();
112 isolate->Enter(); 112 isolate->Enter();
113 WebCore::V8Initializer::initializeMainThreadIfNeeded(isolate); 113 blink::V8Initializer::initializeMainThreadIfNeeded(isolate);
114 v8::V8::SetEntropySource(&generateEntropy); 114 v8::V8::SetEntropySource(&generateEntropy);
115 v8::V8::SetArrayBufferAllocator(WebCore::v8ArrayBufferAllocator()); 115 v8::V8::SetArrayBufferAllocator(blink::v8ArrayBufferAllocator());
116 v8::V8::Initialize(); 116 v8::V8::Initialize();
117 WebCore::V8PerIsolateData::ensureInitialized(isolate); 117 blink::V8PerIsolateData::ensureInitialized(isolate);
118 118
119 s_isolateInterruptor = new WebCore::V8IsolateInterruptor(v8::Isolate::GetCur rent()); 119 s_isolateInterruptor = new blink::V8IsolateInterruptor(v8::Isolate::GetCurre nt());
120 WebCore::ThreadState::current()->addInterruptor(s_isolateInterruptor); 120 blink::ThreadState::current()->addInterruptor(s_isolateInterruptor);
121 121
122 // currentThread will always be non-null in production, but can be null in C hromium unit tests. 122 // currentThread will always be non-null in production, but can be null in C hromium unit tests.
123 if (WebThread* currentThread = platform->currentThread()) { 123 if (WebThread* currentThread = platform->currentThread()) {
124 ASSERT(!s_endOfTaskRunner); 124 ASSERT(!s_endOfTaskRunner);
125 s_endOfTaskRunner = new EndOfTaskRunner; 125 s_endOfTaskRunner = new EndOfTaskRunner;
126 currentThread->addTaskObserver(s_endOfTaskRunner); 126 currentThread->addTaskObserver(s_endOfTaskRunner);
127 } 127 }
128 } 128 }
129 129
130 v8::Isolate* mainThreadIsolate() 130 v8::Isolate* mainThreadIsolate()
131 { 131 {
132 return WebCore::V8PerIsolateData::mainThreadIsolate(); 132 return blink::V8PerIsolateData::mainThreadIsolate();
133 } 133 }
134 134
135 static double currentTimeFunction() 135 static double currentTimeFunction()
136 { 136 {
137 return Platform::current()->currentTime(); 137 return Platform::current()->currentTime();
138 } 138 }
139 139
140 static double monotonicallyIncreasingTimeFunction() 140 static double monotonicallyIncreasingTimeFunction()
141 { 141 {
142 return Platform::current()->monotonicallyIncreasingTime(); 142 return Platform::current()->monotonicallyIncreasingTime();
143 } 143 }
144 144
145 static void cryptographicallyRandomValues(unsigned char* buffer, size_t length) 145 static void cryptographicallyRandomValues(unsigned char* buffer, size_t length)
146 { 146 {
147 Platform::current()->cryptographicallyRandomValues(buffer, length); 147 Platform::current()->cryptographicallyRandomValues(buffer, length);
148 } 148 }
149 149
150 static void callOnMainThreadFunction(WTF::MainThreadFunction function, void* con text) 150 static void callOnMainThreadFunction(WTF::MainThreadFunction function, void* con text)
151 { 151 {
152 WebCore::Scheduler::shared()->postTask(bind(function, context)); 152 blink::Scheduler::shared()->postTask(bind(function, context));
153 } 153 }
154 154
155 void initializeWithoutV8(Platform* platform) 155 void initializeWithoutV8(Platform* platform)
156 { 156 {
157 ASSERT(!s_webKitInitialized); 157 ASSERT(!s_webKitInitialized);
158 s_webKitInitialized = true; 158 s_webKitInitialized = true;
159 159
160 ASSERT(platform); 160 ASSERT(platform);
161 Platform::initialize(platform); 161 Platform::initialize(platform);
162 162
163 WTF::setRandomSource(cryptographicallyRandomValues); 163 WTF::setRandomSource(cryptographicallyRandomValues);
164 WTF::initialize(currentTimeFunction, monotonicallyIncreasingTimeFunction); 164 WTF::initialize(currentTimeFunction, monotonicallyIncreasingTimeFunction);
165 WTF::initializeMainThread(callOnMainThreadFunction); 165 WTF::initializeMainThread(callOnMainThreadFunction);
166 WebCore::Heap::init(); 166 blink::Heap::init();
167 WebCore::Scheduler::initializeOnMainThread(); 167 blink::Scheduler::initializeOnMainThread();
168 168
169 WebCore::ThreadState::attachMainThread(); 169 blink::ThreadState::attachMainThread();
170 // currentThread will always be non-null in production, but can be null in C hromium unit tests. 170 // currentThread will always be non-null in production, but can be null in C hromium unit tests.
171 if (WebThread* currentThread = platform->currentThread()) { 171 if (WebThread* currentThread = platform->currentThread()) {
172 ASSERT(!s_pendingGCRunner); 172 ASSERT(!s_pendingGCRunner);
173 s_pendingGCRunner = new WebCore::PendingGCRunner; 173 s_pendingGCRunner = new blink::PendingGCRunner;
174 currentThread->addTaskObserver(s_pendingGCRunner); 174 currentThread->addTaskObserver(s_pendingGCRunner);
175 175
176 ASSERT(!s_messageLoopInterruptor); 176 ASSERT(!s_messageLoopInterruptor);
177 s_messageLoopInterruptor = new WebCore::MessageLoopInterruptor(currentTh read); 177 s_messageLoopInterruptor = new blink::MessageLoopInterruptor(currentThre ad);
178 WebCore::ThreadState::current()->addInterruptor(s_messageLoopInterruptor ); 178 blink::ThreadState::current()->addInterruptor(s_messageLoopInterruptor);
179 } 179 }
180 180
181 DEFINE_STATIC_LOCAL(WebCore::ModulesInitializer, initializer, ()); 181 DEFINE_STATIC_LOCAL(blink::ModulesInitializer, initializer, ());
182 initializer.init(); 182 initializer.init();
183 183
184 // There are some code paths (for example, running WebKit in the browser 184 // There are some code paths (for example, running WebKit in the browser
185 // process and calling into LocalStorage before anything else) where the 185 // process and calling into LocalStorage before anything else) where the
186 // UTF8 string encoding tables are used on a background thread before 186 // UTF8 string encoding tables are used on a background thread before
187 // they're set up. This is a problem because their set up routines assert 187 // they're set up. This is a problem because their set up routines assert
188 // they're running on the main WebKitThread. It might be possible to make 188 // they're running on the main WebKitThread. It might be possible to make
189 // the initialization thread-safe, but given that so many code paths use 189 // the initialization thread-safe, but given that so many code paths use
190 // this, initializing this lazily probably doesn't buy us much. 190 // this, initializing this lazily probably doesn't buy us much.
191 WTF::UTF8Encoding(); 191 WTF::UTF8Encoding();
192 192
193 WebCore::setIndexedDBClientCreateFunction(blink::IndexedDBClientImpl::create ); 193 blink::setIndexedDBClientCreateFunction(blink::IndexedDBClientImpl::create);
194 194
195 WebCore::MediaPlayer::setMediaEngineCreateFunction(blink::WebMediaPlayerClie ntImpl::create); 195 blink::MediaPlayer::setMediaEngineCreateFunction(blink::WebMediaPlayerClient Impl::create);
196 } 196 }
197 197
198 void shutdown() 198 void shutdown()
199 { 199 {
200 // currentThread will always be non-null in production, but can be null in C hromium unit tests. 200 // currentThread will always be non-null in production, but can be null in C hromium unit tests.
201 if (Platform::current()->currentThread()) { 201 if (Platform::current()->currentThread()) {
202 ASSERT(s_endOfTaskRunner); 202 ASSERT(s_endOfTaskRunner);
203 Platform::current()->currentThread()->removeTaskObserver(s_endOfTaskRunn er); 203 Platform::current()->currentThread()->removeTaskObserver(s_endOfTaskRunn er);
204 delete s_endOfTaskRunner; 204 delete s_endOfTaskRunner;
205 s_endOfTaskRunner = 0; 205 s_endOfTaskRunner = 0;
206 } 206 }
207 207
208 ASSERT(s_isolateInterruptor); 208 ASSERT(s_isolateInterruptor);
209 WebCore::ThreadState::current()->removeInterruptor(s_isolateInterruptor); 209 blink::ThreadState::current()->removeInterruptor(s_isolateInterruptor);
210 WebCore::Scheduler::shutdown(); 210 blink::Scheduler::shutdown();
211 211
212 // currentThread will always be non-null in production, but can be null in C hromium unit tests. 212 // currentThread will always be non-null in production, but can be null in C hromium unit tests.
213 if (Platform::current()->currentThread()) { 213 if (Platform::current()->currentThread()) {
214 ASSERT(s_pendingGCRunner); 214 ASSERT(s_pendingGCRunner);
215 delete s_pendingGCRunner; 215 delete s_pendingGCRunner;
216 s_pendingGCRunner = 0; 216 s_pendingGCRunner = 0;
217 217
218 ASSERT(s_messageLoopInterruptor); 218 ASSERT(s_messageLoopInterruptor);
219 WebCore::ThreadState::current()->removeInterruptor(s_messageLoopInterrup tor); 219 blink::ThreadState::current()->removeInterruptor(s_messageLoopInterrupto r);
220 delete s_messageLoopInterruptor; 220 delete s_messageLoopInterruptor;
221 s_messageLoopInterruptor = 0; 221 s_messageLoopInterruptor = 0;
222 } 222 }
223 223
224 // Detach the main thread before starting the shutdown sequence 224 // Detach the main thread before starting the shutdown sequence
225 // so that the main thread won't get involved in a GC during the shutdown. 225 // so that the main thread won't get involved in a GC during the shutdown.
226 WebCore::ThreadState::detachMainThread(); 226 blink::ThreadState::detachMainThread();
227 227
228 v8::Isolate* isolate = WebCore::V8PerIsolateData::mainThreadIsolate(); 228 v8::Isolate* isolate = blink::V8PerIsolateData::mainThreadIsolate();
229 WebCore::V8PerIsolateData::dispose(isolate); 229 blink::V8PerIsolateData::dispose(isolate);
230 isolate->Exit(); 230 isolate->Exit();
231 isolate->Dispose(); 231 isolate->Dispose();
232 232
233 shutdownWithoutV8(); 233 shutdownWithoutV8();
234 } 234 }
235 235
236 void shutdownWithoutV8() 236 void shutdownWithoutV8()
237 { 237 {
238 ASSERT(!s_endOfTaskRunner); 238 ASSERT(!s_endOfTaskRunner);
239 WebCore::CoreInitializer::shutdown(); 239 blink::CoreInitializer::shutdown();
240 WebCore::Heap::shutdown(); 240 blink::Heap::shutdown();
241 WTF::shutdown(); 241 WTF::shutdown();
242 Platform::shutdown(); 242 Platform::shutdown();
243 WebPrerenderingSupport::shutdown(); 243 WebPrerenderingSupport::shutdown();
244 } 244 }
245 245
246 void setLayoutTestMode(bool value) 246 void setLayoutTestMode(bool value)
247 { 247 {
248 LayoutTestSupport::setIsRunningLayoutTest(value); 248 LayoutTestSupport::setIsRunningLayoutTest(value);
249 } 249 }
250 250
251 bool layoutTestMode() 251 bool layoutTestMode()
252 { 252 {
253 return LayoutTestSupport::isRunningLayoutTest(); 253 return LayoutTestSupport::isRunningLayoutTest();
254 } 254 }
255 255
256 void setFontAntialiasingEnabledForTest(bool value) 256 void setFontAntialiasingEnabledForTest(bool value)
257 { 257 {
258 LayoutTestSupport::setFontAntialiasingEnabledForTest(value); 258 LayoutTestSupport::setFontAntialiasingEnabledForTest(value);
259 } 259 }
260 260
261 bool fontAntialiasingEnabledForTest() 261 bool fontAntialiasingEnabledForTest()
262 { 262 {
263 return LayoutTestSupport::isFontAntialiasingEnabledForTest(); 263 return LayoutTestSupport::isFontAntialiasingEnabledForTest();
264 } 264 }
265 265
266 void enableLogChannel(const char* name) 266 void enableLogChannel(const char* name)
267 { 267 {
268 #if !LOG_DISABLED 268 #if !LOG_DISABLED
269 WTFLogChannel* channel = WebCore::getChannelFromName(name); 269 WTFLogChannel* channel = blink::getChannelFromName(name);
270 if (channel) 270 if (channel)
271 channel->state = WTFLogChannelOn; 271 channel->state = WTFLogChannelOn;
272 #endif // !LOG_DISABLED 272 #endif // !LOG_DISABLED
273 } 273 }
274 274
275 void resetPluginCache(bool reloadPages) 275 void resetPluginCache(bool reloadPages)
276 { 276 {
277 WebCore::Page::refreshPlugins(reloadPages); 277 blink::Page::refreshPlugins(reloadPages);
278 } 278 }
279 279
280 } // namespace blink 280 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebInputEventConversion.cpp ('k') | Source/web/WebLabelElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698