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

Side by Side Diff: sky/engine/web/Sky.cpp

Issue 922893002: Merge the Sky Engine changes from the SkyDart branch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « sky/engine/web/FrameLoaderClientImpl.cpp ('k') | sky/engine/web/WebDocument.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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "sky/engine/config.h" 31 #include "sky/engine/config.h"
32 #include "sky/engine/public/web/Sky.h" 32 #include "sky/engine/public/web/Sky.h"
33 33
34 #include "base/message_loop/message_loop.h" 34 #include "base/message_loop/message_loop.h"
35 #include "base/rand_util.h" 35 #include "base/rand_util.h"
36 #include "gen/sky/platform/RuntimeEnabledFeatures.h" 36 #include "gen/sky/platform/RuntimeEnabledFeatures.h"
37 #include "gin/public/v8_platform.h"
38 #include "mojo/common/message_pump_mojo.h" 37 #include "mojo/common/message_pump_mojo.h"
39 #include "sky/engine/bindings/core/v8/V8Binding.h"
40 #include "sky/engine/bindings/core/v8/V8GCController.h"
41 #include "sky/engine/bindings/core/v8/V8Initializer.h"
42 #include "sky/engine/core/Init.h"
43 #include "sky/engine/core/animation/AnimationClock.h" 38 #include "sky/engine/core/animation/AnimationClock.h"
44 #include "sky/engine/core/dom/Microtask.h" 39 #include "sky/engine/core/dom/Microtask.h"
45 #include "sky/engine/core/frame/Settings.h" 40 #include "sky/engine/core/frame/Settings.h"
41 #include "sky/engine/core/Init.h"
46 #include "sky/engine/core/page/Page.h" 42 #include "sky/engine/core/page/Page.h"
43 #include "sky/engine/core/script/dart_controller.h"
47 #include "sky/engine/platform/LayoutTestSupport.h" 44 #include "sky/engine/platform/LayoutTestSupport.h"
48 #include "sky/engine/platform/Logging.h" 45 #include "sky/engine/platform/Logging.h"
49 #include "sky/engine/platform/graphics/ImageDecodingStore.h"
50 #include "sky/engine/public/platform/Platform.h" 46 #include "sky/engine/public/platform/Platform.h"
51 #include "sky/engine/wtf/Assertions.h" 47 #include "sky/engine/wtf/Assertions.h"
52 #include "sky/engine/wtf/CryptographicallyRandomNumber.h" 48 #include "sky/engine/wtf/CryptographicallyRandomNumber.h"
53 #include "sky/engine/wtf/MainThread.h" 49 #include "sky/engine/wtf/MainThread.h"
54 #include "sky/engine/wtf/WTF.h"
55 #include "sky/engine/wtf/text/AtomicString.h" 50 #include "sky/engine/wtf/text/AtomicString.h"
56 #include "sky/engine/wtf/text/TextEncoding.h" 51 #include "sky/engine/wtf/text/TextEncoding.h"
57 #include "v8/include/v8.h" 52 #include "sky/engine/wtf/WTF.h"
58 53
59 namespace blink { 54 namespace blink {
60 55
61 namespace { 56 namespace {
62 57
63 void willProcessTask() 58 void willProcessTask()
64 { 59 {
65 AnimationClock::notifyTaskStart(); 60 AnimationClock::notifyTaskStart();
66 } 61 }
67 62
68 void didProcessTask() 63 void didProcessTask()
69 { 64 {
70 Microtask::performCheckpoint(); 65 Microtask::performCheckpoint();
71 V8GCController::reportDOMMemoryUsageToV8(mainThreadIsolate()); 66 // FIXME: Report memory usage to dart?
72 } 67 }
73 68
74 class TaskObserver : public base::MessageLoop::TaskObserver { 69 class TaskObserver : public base::MessageLoop::TaskObserver {
75 public: 70 public:
76 void WillProcessTask(const base::PendingTask& pending_task) override { willP rocessTask(); } 71 void WillProcessTask(const base::PendingTask& pending_task) override { willP rocessTask(); }
77 void DidProcessTask(const base::PendingTask& pending_task) override { didPro cessTask(); } 72 void DidProcessTask(const base::PendingTask& pending_task) override { didPro cessTask(); }
78 }; 73 };
79 74
80 class SignalObserver : public mojo::common::MessagePumpMojo::Observer { 75 class SignalObserver : public mojo::common::MessagePumpMojo::Observer {
81 public: 76 public:
(...skipping 29 matching lines...) Expand all
111 delete s_signalObserver; 106 delete s_signalObserver;
112 s_signalObserver = 0; 107 s_signalObserver = 0;
113 } 108 }
114 109
115 } // namespace 110 } // namespace
116 111
117 // Make sure we are not re-initialized in the same address space. 112 // Make sure we are not re-initialized in the same address space.
118 // Doing so may cause hard to reproduce crashes. 113 // Doing so may cause hard to reproduce crashes.
119 static bool s_webKitInitialized = false; 114 static bool s_webKitInitialized = false;
120 115
121 void initialize(Platform* platform)
122 {
123 initializeWithoutV8(platform);
124
125 V8Initializer::initializeMainThreadIfNeeded();
126
127 addMessageLoopObservers();
128 }
129
130 v8::Isolate* mainThreadIsolate()
131 {
132 return V8PerIsolateData::mainThreadIsolate();
133 }
134
135 static void cryptographicallyRandomValues(unsigned char* buffer, size_t length) 116 static void cryptographicallyRandomValues(unsigned char* buffer, size_t length)
136 { 117 {
137 base::RandBytes(buffer, length); 118 base::RandBytes(buffer, length);
138 } 119 }
139 120
140 void initializeWithoutV8(Platform* platform) 121 void initialize(Platform* platform)
141 { 122 {
142 ASSERT(!s_webKitInitialized); 123 ASSERT(!s_webKitInitialized);
143 s_webKitInitialized = true; 124 s_webKitInitialized = true;
144 125
145 ASSERT(platform); 126 ASSERT(platform);
146 Platform::initialize(platform); 127 Platform::initialize(platform);
147 128
148 WTF::setRandomSource(cryptographicallyRandomValues); 129 WTF::setRandomSource(cryptographicallyRandomValues);
149 WTF::initialize(); 130 WTF::initialize();
150 WTF::initializeMainThread(); 131 WTF::initializeMainThread();
151 132
152 DEFINE_STATIC_LOCAL(CoreInitializer, initializer, ()); 133 DEFINE_STATIC_LOCAL(CoreInitializer, initializer, ());
153 initializer.init(); 134 initializer.init();
154 135
155 // There are some code paths (for example, running WebKit in the browser 136 // There are some code paths (for example, running WebKit in the browser
156 // process and calling into LocalStorage before anything else) where the 137 // process and calling into LocalStorage before anything else) where the
157 // UTF8 string encoding tables are used on a background thread before 138 // UTF8 string encoding tables are used on a background thread before
158 // they're set up. This is a problem because their set up routines assert 139 // they're set up. This is a problem because their set up routines assert
159 // they're running on the main WebKitThread. It might be possible to make 140 // they're running on the main WebKitThread. It might be possible to make
160 // the initialization thread-safe, but given that so many code paths use 141 // the initialization thread-safe, but given that so many code paths use
161 // this, initializing this lazily probably doesn't buy us much. 142 // this, initializing this lazily probably doesn't buy us much.
162 WTF::UTF8Encoding(); 143 WTF::UTF8Encoding();
144
145 DartController::InitVM();
146
147 addMessageLoopObservers();
163 } 148 }
164 149
165 void shutdown() 150 void shutdown()
166 { 151 {
167 removeMessageLoopObservers(); 152 removeMessageLoopObservers();
168 153
169 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); 154 // FIXME: Shutdown dart?
170 V8PerIsolateData::dispose(isolate);
171 155
172 shutdownWithoutV8();
173 }
174
175 void shutdownWithoutV8()
176 {
177 CoreInitializer::shutdown(); 156 CoreInitializer::shutdown();
178 WTF::shutdown(); 157 WTF::shutdown();
179 Platform::shutdown(); 158 Platform::shutdown();
180 } 159 }
181 160
182 void setLayoutTestMode(bool value) 161 void setLayoutTestMode(bool value)
183 { 162 {
184 LayoutTestSupport::setIsRunningLayoutTest(value); 163 LayoutTestSupport::setIsRunningLayoutTest(value);
185 } 164 }
186 165
(...skipping 15 matching lines...) Expand all
202 void enableLogChannel(const char* name) 181 void enableLogChannel(const char* name)
203 { 182 {
204 #if !LOG_DISABLED 183 #if !LOG_DISABLED
205 WTFLogChannel* channel = getChannelFromName(name); 184 WTFLogChannel* channel = getChannelFromName(name);
206 if (channel) 185 if (channel)
207 channel->state = WTFLogChannelOn; 186 channel->state = WTFLogChannelOn;
208 #endif // !LOG_DISABLED 187 #endif // !LOG_DISABLED
209 } 188 }
210 189
211 } // namespace blink 190 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/web/FrameLoaderClientImpl.cpp ('k') | sky/engine/web/WebDocument.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698