OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 #include "ModulesInitializer.h" | 5 #include "ModulesInitializer.h" |
6 | 6 |
7 #include "bindings/modules/v8/ModuleBindingsInitializer.h" | 7 #include "bindings/modules/v8/ModuleBindingsInitializer.h" |
8 #include "core/EventTypeNames.h" | 8 #include "core/EventTypeNames.h" |
9 #include "core/css/CSSPaintImageGenerator.h" | 9 #include "core/css/CSSPaintImageGenerator.h" |
10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
11 #include "core/html/HTMLCanvasElement.h" | 11 #include "core/html/HTMLCanvasElement.h" |
12 #include "core/offscreencanvas/OffscreenCanvas.h" | 12 #include "core/offscreencanvas/OffscreenCanvas.h" |
13 #include "modules/EventModulesFactory.h" | 13 #include "modules/EventModulesFactory.h" |
14 #include "modules/EventModulesNames.h" | 14 #include "modules/EventModulesNames.h" |
15 #include "modules/EventTargetModulesNames.h" | 15 #include "modules/EventTargetModulesNames.h" |
16 #include "modules/IndexedDBNames.h" | 16 #include "modules/IndexedDBNames.h" |
17 #include "modules/accessibility/AXObjectCacheImpl.h" | 17 #include "modules/accessibility/AXObjectCacheImpl.h" |
18 #include "modules/canvas2d/CanvasRenderingContext2D.h" | 18 #include "modules/canvas2d/CanvasRenderingContext2D.h" |
19 #include "modules/compositorworker/CompositorWorkerThread.h" | 19 #include "modules/compositorworker/CompositorWorkerThread.h" |
20 #include "modules/csspaint/CSSPaintImageGeneratorImpl.h" | 20 #include "modules/csspaint/CSSPaintImageGeneratorImpl.h" |
21 #include "modules/filesystem/DraggedIsolatedFileSystemImpl.h" | 21 #include "modules/filesystem/DraggedIsolatedFileSystemImpl.h" |
22 #include "modules/imagebitmap/ImageBitmapRenderingContext.h" | 22 #include "modules/imagebitmap/ImageBitmapRenderingContext.h" |
23 #include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h" | 23 #include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h" |
| 24 #include "modules/time_zone_monitor/TimeZoneMonitorClient.h" |
24 #include "modules/webdatabase/DatabaseManager.h" | 25 #include "modules/webdatabase/DatabaseManager.h" |
25 #include "modules/webgl/WebGL2RenderingContext.h" | 26 #include "modules/webgl/WebGL2RenderingContext.h" |
26 #include "modules/webgl/WebGLRenderingContext.h" | 27 #include "modules/webgl/WebGLRenderingContext.h" |
| 28 #include "platform/mojo/MojoHelper.h" |
27 #include "wtf/PtrUtil.h" | 29 #include "wtf/PtrUtil.h" |
28 | 30 |
29 namespace blink { | 31 namespace blink { |
30 | 32 |
31 void ModulesInitializer::initialize() { | 33 void ModulesInitializer::initialize() { |
32 ASSERT(!isInitialized()); | 34 ASSERT(!isInitialized()); |
33 | 35 |
34 // Strings must be initialized before calling CoreInitializer::init(). | 36 // Strings must be initialized before calling CoreInitializer::init(). |
35 const unsigned modulesStaticStringsCount = | 37 const unsigned modulesStaticStringsCount = |
36 EventNames::EventModulesNamesCount + | 38 EventNames::EventModulesNamesCount + |
37 EventTargetNames::EventTargetModulesNamesCount + | 39 EventTargetNames::EventTargetModulesNamesCount + |
38 IndexedDBNames::IndexedDBNamesCount; | 40 IndexedDBNames::IndexedDBNamesCount; |
39 StringImpl::reserveStaticStringsCapacityForSize(modulesStaticStringsCount); | 41 StringImpl::reserveStaticStringsCapacityForSize(modulesStaticStringsCount); |
40 | 42 |
41 EventNames::initModules(); | 43 EventNames::initModules(); |
42 EventTargetNames::initModules(); | 44 EventTargetNames::initModules(); |
43 Document::registerEventFactory(EventModulesFactory::create()); | 45 Document::registerEventFactory(EventModulesFactory::create()); |
44 ModuleBindingsInitializer::init(); | 46 ModuleBindingsInitializer::init(); |
45 IndexedDBNames::init(); | 47 IndexedDBNames::init(); |
46 AXObjectCache::init(AXObjectCacheImpl::create); | 48 AXObjectCache::init(AXObjectCacheImpl::create); |
47 DraggedIsolatedFileSystem::init( | 49 DraggedIsolatedFileSystem::init( |
48 DraggedIsolatedFileSystemImpl::prepareForDataObject); | 50 DraggedIsolatedFileSystemImpl::prepareForDataObject); |
49 CSSPaintImageGenerator::init(CSSPaintImageGeneratorImpl::create); | 51 CSSPaintImageGenerator::init(CSSPaintImageGeneratorImpl::create); |
| 52 // Some unit tests may have no message loop ready, so we can't initialize the |
| 53 // mojo stuff here. They can initialize those mojo stuff they're interested in |
| 54 // later after they got a message loop ready. |
| 55 if (canInitializeMojo()) |
| 56 TimeZoneMonitorClient::Init(); |
50 | 57 |
51 CoreInitializer::initialize(); | 58 CoreInitializer::initialize(); |
52 | 59 |
53 // Canvas context types must be registered with the HTMLCanvasElement. | 60 // Canvas context types must be registered with the HTMLCanvasElement. |
54 HTMLCanvasElement::registerRenderingContextFactory( | 61 HTMLCanvasElement::registerRenderingContextFactory( |
55 wrapUnique(new CanvasRenderingContext2D::Factory())); | 62 wrapUnique(new CanvasRenderingContext2D::Factory())); |
56 HTMLCanvasElement::registerRenderingContextFactory( | 63 HTMLCanvasElement::registerRenderingContextFactory( |
57 wrapUnique(new WebGLRenderingContext::Factory())); | 64 wrapUnique(new WebGLRenderingContext::Factory())); |
58 HTMLCanvasElement::registerRenderingContextFactory( | 65 HTMLCanvasElement::registerRenderingContextFactory( |
59 wrapUnique(new WebGL2RenderingContext::Factory())); | 66 wrapUnique(new WebGL2RenderingContext::Factory())); |
(...skipping 10 matching lines...) Expand all Loading... |
70 } | 77 } |
71 | 78 |
72 void ModulesInitializer::shutdown() { | 79 void ModulesInitializer::shutdown() { |
73 ASSERT(isInitialized()); | 80 ASSERT(isInitialized()); |
74 DatabaseManager::terminateDatabaseThread(); | 81 DatabaseManager::terminateDatabaseThread(); |
75 CoreInitializer::shutdown(); | 82 CoreInitializer::shutdown(); |
76 CompositorWorkerThread::clearSharedBackingThread(); | 83 CompositorWorkerThread::clearSharedBackingThread(); |
77 } | 84 } |
78 | 85 |
79 } // namespace blink | 86 } // namespace blink |
OLD | NEW |