| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 29 */ | |
| 30 | |
| 31 #include "Init.h" | |
| 32 | |
| 33 #include "bindings/core/v8/ScriptStreamerThread.h" | |
| 34 #include "core/EventNames.h" | |
| 35 #include "core/EventTargetNames.h" | |
| 36 #include "core/EventTypeNames.h" | |
| 37 #include "core/HTMLNames.h" | |
| 38 #include "core/HTMLTokenizerNames.h" | |
| 39 #include "core/InputTypeNames.h" | |
| 40 #include "core/MathMLNames.h" | |
| 41 #include "core/MediaFeatureNames.h" | |
| 42 #include "core/MediaTypeNames.h" | |
| 43 #include "core/SVGNames.h" | |
| 44 #include "core/XLinkNames.h" | |
| 45 #include "core/XMLNSNames.h" | |
| 46 #include "core/XMLNames.h" | |
| 47 #include "core/css/parser/CSSParserTokenRange.h" | |
| 48 #include "core/dom/Document.h" | |
| 49 #include "core/dom/StyleChangeReason.h" | |
| 50 #include "core/events/EventFactory.h" | |
| 51 #include "core/fetch/FetchInitiatorTypeNames.h" | |
| 52 #include "core/fetch/WebCacheMemoryDumpProvider.h" | |
| 53 #include "core/html/canvas/CanvasRenderingContextFactory.h" | |
| 54 #include "core/html/parser/HTMLParserThread.h" | |
| 55 #include "core/workers/WorkerThread.h" | |
| 56 #include "platform/EventTracer.h" | |
| 57 #include "platform/FontFamilyNames.h" | |
| 58 #include "platform/HTTPNames.h" | |
| 59 #include "platform/weborigin/KURL.h" | |
| 60 #include "platform/weborigin/SchemeRegistry.h" | |
| 61 #include "platform/weborigin/SecurityPolicy.h" | |
| 62 #include "wtf/Partitions.h" | |
| 63 | |
| 64 namespace blink { | |
| 65 | |
| 66 void CoreInitializer::registerEventFactory() | |
| 67 { | |
| 68 static bool isRegistered = false; | |
| 69 if (isRegistered) | |
| 70 return; | |
| 71 isRegistered = true; | |
| 72 | |
| 73 Document::registerEventFactory(EventFactory::create()); | |
| 74 } | |
| 75 | |
| 76 void CoreInitializer::init() | |
| 77 { | |
| 78 ASSERT(!isInitialized()); | |
| 79 m_isInitialized = true; | |
| 80 // Note: in order to add core static strings for a new module (1) | |
| 81 // the value of 'coreStaticStringsCount' must be updated with the | |
| 82 // added strings count, (2) if the added strings are quialified names | |
| 83 // the 'qualifiedNamesCount' must be updated as well, (3) the strings | |
| 84 // 'init()' function call must be added. | |
| 85 // TODO(mikhail.pozdnyakov@intel.com): We should generate static strings ini
tialization code. | |
| 86 const unsigned qualifiedNamesCount = HTMLNames::HTMLTagsCount + HTMLNames::H
TMLAttrsCount | |
| 87 + MathMLNames::MathMLTagsCount + MathMLNames::MathMLAttrsCount | |
| 88 + SVGNames::SVGTagsCount + SVGNames::SVGAttrsCount | |
| 89 + XLinkNames::XLinkAttrsCount | |
| 90 + XMLNSNames::XMLNSAttrsCount | |
| 91 + XMLNames::XMLAttrsCount; | |
| 92 | |
| 93 const unsigned coreStaticStringsCount = qualifiedNamesCount | |
| 94 + EventNames::EventNamesCount | |
| 95 + EventTargetNames::EventTargetNamesCount | |
| 96 + EventTypeNames::EventTypeNamesCount | |
| 97 + FetchInitiatorTypeNames::FetchInitiatorTypeNamesCount | |
| 98 + FontFamilyNames::FontFamilyNamesCount | |
| 99 + HTMLTokenizerNames::HTMLTokenizerNamesCount | |
| 100 + HTTPNames::HTTPNamesCount | |
| 101 + InputTypeNames::InputTypeNamesCount | |
| 102 + MediaFeatureNames::MediaFeatureNamesCount | |
| 103 + MediaTypeNames::MediaTypeNamesCount; | |
| 104 | |
| 105 StringImpl::reserveStaticStringsCapacityForSize(coreStaticStringsCount + Str
ingImpl::allStaticStrings().size()); | |
| 106 QualifiedName::initAndReserveCapacityForSize(qualifiedNamesCount); | |
| 107 AtomicString::reserveTableCapacity(coreStaticStringsCount); | |
| 108 | |
| 109 HTMLNames::init(); | |
| 110 SVGNames::init(); | |
| 111 XLinkNames::init(); | |
| 112 MathMLNames::init(); | |
| 113 XMLNSNames::init(); | |
| 114 XMLNames::init(); | |
| 115 | |
| 116 EventNames::init(); | |
| 117 EventTargetNames::init(); | |
| 118 EventTypeNames::init(); | |
| 119 FetchInitiatorTypeNames::init(); | |
| 120 FontFamilyNames::init(); | |
| 121 HTMLTokenizerNames::init(); | |
| 122 HTTPNames::init(); | |
| 123 InputTypeNames::init(); | |
| 124 MediaFeatureNames::init(); | |
| 125 MediaTypeNames::init(); | |
| 126 | |
| 127 CSSPrimitiveValue::initUnitTable(); | |
| 128 CSSParserTokenRange::initStaticEOFToken(); | |
| 129 | |
| 130 StyleChangeExtraData::init(); | |
| 131 | |
| 132 EventTracer::initialize(); | |
| 133 KURL::initialize(); | |
| 134 SchemeRegistry::initialize(); | |
| 135 SecurityPolicy::init(); | |
| 136 | |
| 137 registerEventFactory(); | |
| 138 | |
| 139 StringImpl::freezeStaticStrings(); | |
| 140 | |
| 141 Platform::current()->registerMemoryDumpProvider(WebCacheMemoryDumpProvider::
instance(), "MemoryCache"); | |
| 142 | |
| 143 // Creates HTMLParserThread::shared and ScriptStreamerThread::shared, but | |
| 144 // does not start the threads. | |
| 145 HTMLParserThread::init(); | |
| 146 ScriptStreamerThread::init(); | |
| 147 } | |
| 148 | |
| 149 void CoreInitializer::shutdown() | |
| 150 { | |
| 151 // Shutdown V8-related background threads before V8 is ramped down. Note | |
| 152 // that this will wait the thread to stop its operations. | |
| 153 ScriptStreamerThread::shutdown(); | |
| 154 | |
| 155 // Make sure we stop the HTMLParserThread before Platform::current() is | |
| 156 // cleared. | |
| 157 ASSERT(Platform::current()); | |
| 158 HTMLParserThread::shutdown(); | |
| 159 | |
| 160 Platform::current()->unregisterMemoryDumpProvider(WebCacheMemoryDumpProvider
::instance()); | |
| 161 | |
| 162 WorkerThread::terminateAndWaitForAllWorkers(); | |
| 163 } | |
| 164 | |
| 165 } // namespace blink | |
| OLD | NEW |