Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / Init.cpp
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 "config.h"
32 #include "Init.h"
33
34 #include "bindings/core/v8/ScriptStreamerThread.h"
35 #include "core/EventNames.h"
36 #include "core/EventTargetNames.h"
37 #include "core/EventTypeNames.h"
38 #include "core/FetchInitiatorTypeNames.h"
39 #include "core/HTMLNames.h"
40 #include "core/HTMLTokenizerNames.h"
41 #include "core/InputTypeNames.h"
42 #include "core/MathMLNames.h"
43 #include "core/MediaFeatureNames.h"
44 #include "core/MediaTypeNames.h"
45 #include "core/SVGNames.h"
46 #include "core/XLinkNames.h"
47 #include "core/XMLNSNames.h"
48 #include "core/XMLNames.h"
49 #include "core/dom/Document.h"
50 #include "core/dom/StyleChangeReason.h"
51 #include "core/events/EventFactory.h"
52 #include "core/html/parser/HTMLParserThread.h"
53 #include "core/workers/WorkerThread.h"
54 #include "platform/EventTracer.h"
55 #include "platform/FontFamilyNames.h"
56 #include "platform/Partitions.h"
57 #include "platform/PlatformThreadData.h"
58 #include "platform/heap/Heap.h"
59 #include "wtf/text/StringStatics.h"
60
61 namespace blink {
62
63 void CoreInitializer::registerEventFactory()
64 {
65     static bool isRegistered = false;
66     if (isRegistered)
67         return;
68     isRegistered = true;
69
70     Document::registerEventFactory(EventFactory::create());
71 }
72
73 void CoreInitializer::init()
74 {
75     ASSERT(!m_isInited);
76     m_isInited = true;
77
78     HTMLNames::init();
79     SVGNames::init();
80     XLinkNames::init();
81     MathMLNames::init();
82     XMLNSNames::init();
83     XMLNames::init();
84
85     EventNames::init();
86     EventTargetNames::init();
87     EventTypeNames::init();
88     FetchInitiatorTypeNames::init();
89     FontFamilyNames::init();
90     HTMLTokenizerNames::init();
91     InputTypeNames::init();
92     MediaFeatureNames::init();
93     MediaTypeNames::init();
94
95     // It would make logical sense to do this in WTF::initialize() but there are
96     // ordering dependencies, e.g. about "xmlns".
97     WTF::StringStatics::init();
98
99     StyleChangeExtraData::init();
100
101     QualifiedName::init();
102     Partitions::init();
103     EventTracer::initialize();
104
105     registerEventFactory();
106
107     // Ensure that the main thread's thread-local data is initialized before
108     // starting any worker threads.
109     PlatformThreadData::current();
110
111     StringImpl::freezeStaticStrings();
112
113     // Creates HTMLParserThread::shared and ScriptStreamerThread::shared, but
114     // does not start the threads.
115     HTMLParserThread::init();
116     ScriptStreamerThread::init();
117 }
118
119 void CoreInitializer::shutdown()
120 {
121     // Make sure we stop the HTMLParserThread and ScriptStreamerThread before
122     // Platform::current() is cleared.
123     ScriptStreamerThread::shutdown();
124     HTMLParserThread::shutdown();
125
126     Partitions::shutdown();
127 }
128
129 } // namespace blink