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

Side by Side Diff: Source/core/Init.cpp

Issue 464043002: Refactor module initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed one-line functions and added isInitialized Created 6 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "core/html/parser/HTMLParserThread.h" 50 #include "core/html/parser/HTMLParserThread.h"
51 #include "platform/EventTracer.h" 51 #include "platform/EventTracer.h"
52 #include "platform/FontFamilyNames.h" 52 #include "platform/FontFamilyNames.h"
53 #include "platform/Partitions.h" 53 #include "platform/Partitions.h"
54 #include "platform/PlatformThreadData.h" 54 #include "platform/PlatformThreadData.h"
55 #include "platform/heap/Heap.h" 55 #include "platform/heap/Heap.h"
56 #include "wtf/text/StringStatics.h" 56 #include "wtf/text/StringStatics.h"
57 57
58 namespace blink { 58 namespace blink {
59 59
60 void CoreInitializer::initEventNames()
61 {
62 EventNames::init();
63 }
64
65 void CoreInitializer::initEventTargetNames()
66 {
67 EventTargetNames::init();
68 }
69
70 void CoreInitializer::registerEventFactory() 60 void CoreInitializer::registerEventFactory()
71 { 61 {
72 static bool isRegistered = false; 62 static bool isRegistered = false;
73 if (isRegistered) 63 if (isRegistered)
74 return; 64 return;
75 isRegistered = true; 65 isRegistered = true;
76 66
77 Document::registerEventFactory(EventFactory::create()); 67 Document::registerEventFactory(EventFactory::create());
78 } 68 }
79 69
80 void CoreInitializer::init() 70 void CoreInitializer::init()
81 { 71 {
82 if (m_isInited) 72 ASSERT(!m_isInited);
83 return;
84 m_isInited = true; 73 m_isInited = true;
85 74
86 // It would make logical sense to do this and WTF::StringStatics::init() in 75 // It would make logical sense to do this and WTF::StringStatics::init() in
87 // WTF::initialize() but there are ordering dependencies. 76 // WTF::initialize() but there are ordering dependencies.
88 AtomicString::init(); 77 AtomicString::init();
89 HTMLNames::init(); 78 HTMLNames::init();
90 SVGNames::init(); 79 SVGNames::init();
91 XLinkNames::init(); 80 XLinkNames::init();
92 MathMLNames::init(); 81 MathMLNames::init();
93 XMLNSNames::init(); 82 XMLNSNames::init();
94 XMLNames::init(); 83 XMLNames::init();
95 84
96 initEventNames(); 85 EventNames::init();
97 initEventTargetNames(); 86 EventTargetNames::init();
98 EventTypeNames::init(); 87 EventTypeNames::init();
99 FetchInitiatorTypeNames::init(); 88 FetchInitiatorTypeNames::init();
100 FontFamilyNames::init(); 89 FontFamilyNames::init();
101 HTMLTokenizerNames::init(); 90 HTMLTokenizerNames::init();
102 InputTypeNames::init(); 91 InputTypeNames::init();
103 MediaFeatureNames::init(); 92 MediaFeatureNames::init();
104 MediaTypeNames::init(); 93 MediaTypeNames::init();
105 94
106 WTF::StringStatics::init(); 95 WTF::StringStatics::init();
107 QualifiedName::init(); 96 QualifiedName::init();
108 Partitions::init(); 97 Partitions::init();
109 EventTracer::initialize(); 98 EventTracer::initialize();
110 99
111 initBindings();
112 registerEventFactory(); 100 registerEventFactory();
113 101
114 // Ensure that the main thread's thread-local data is initialized before 102 // Ensure that the main thread's thread-local data is initialized before
115 // starting any worker threads. 103 // starting any worker threads.
116 PlatformThreadData::current(); 104 PlatformThreadData::current();
117 105
118 StringImpl::freezeStaticStrings(); 106 StringImpl::freezeStaticStrings();
119 107
120 // Creates HTMLParserThread::shared, but does not start the thread. 108 // Creates HTMLParserThread::shared, but does not start the thread.
121 HTMLParserThread::init(); 109 HTMLParserThread::init();
122 } 110 }
123 111
124 void CoreInitializer::shutdown() 112 void CoreInitializer::shutdown()
125 { 113 {
126 // Make sure we stop the HTMLParserThread before Platform::current() is clea red. 114 // Make sure we stop the HTMLParserThread before Platform::current() is clea red.
127 HTMLParserThread::shutdown(); 115 HTMLParserThread::shutdown();
128 116
129 Partitions::shutdown(); 117 Partitions::shutdown();
130 } 118 }
131 119
132 } // namespace blink 120 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/Init.h ('k') | Source/modules/InitModules.h » ('j') | Source/modules/InitModules.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698