| OLD | NEW |
| 1 # platform/wtf | 1 # WTF (Web Template Framework) |
| 2 | 2 |
| 3 This is the location where all the files under Source/wtf will be moved | 3 WTF is a base library for Blink providing a variety of basic functionalities, |
| 4 eventually. See | 4 like containers, string libraries, reference counting mechanisms, functors, |
| 5 [the proposal](https://docs.google.com/document/d/1shS1IZe__auYxjm9FhPbTY2P01FbN
TMYRh-nen5gkDo/edit?usp=sharing) | 5 threading primitives etc. |
| 6 and | |
| 7 [the design doc](https://docs.google.com/document/d/1JK26H-1-cD9-s9QLvEfY55H2kgS
xRFNPLfjs049Us5w/edit?usp=sharing) | |
| 8 regarding the relocation project. For the project's progress, see | |
| 9 [bug 691465](https://bugs.chromium.org/p/chromium/issues/detail?id=691465). | |
| 10 | 6 |
| 11 During the project, files in wtf/ are moved to platform/wtf incrementally, and | 7 WTF's mission is to power and support all other Blink code base by providing |
| 12 redirection headers will be placed in wtf/. So nothing should break in the | 8 fast, reliable, user-friendly and secure generic primitives. |
| 13 meantime. You can continue including WTF headers like `#include "wtf/Xxx.h"` | 9 |
| 14 till the next announce in blink-dev. | 10 Dependency-wise, WTF cannot depend on any other Blink headers, including |
| 11 files under other platform/ subdirectories, since WTF is a library that can be |
| 12 referred from anywhere in Blink. WTF basically can only depend on [base]. |
| 13 |
| 14 Main code base of Blink (core and modules) cannot directly depend on [base]. |
| 15 The main objective of this is to limit what Blink core can use, so that Blink |
| 16 core code wouldn't use libraries prohibited in Blink accidentally (such as |
| 17 `std::string` or `std::vector`). |
| 18 |
| 19 Our approach here is to make WTF and other platform/ components a gatekeeper of |
| 20 the use of [base] libraries. platform/ (including WTF) can directly depend on |
| 21 [base], and if some of the [base] functionalities are worth having in Blink, |
| 22 WTF can expose them in a way Blink core code can easily use them. Usually, |
| 23 such a library would be a thin wrapper of the corresponding [base] |
| 24 functionality. |
| 25 |
| 26 Also, we are trying to eliminate duplicated functionalities between WTF and |
| 27 [base]. Historically, WTF was developed as a stand-alone library, so there |
| 28 are still many overlaps. We want to eventually delegate sharable implementation |
| 29 to [base] as much as possible. |
| 30 |
| 31 If you find a missing functionality in WTF, regardless of whether it is |
| 32 available in [base] or not, feel free to file a bug under the component |
| 33 Blink>Internals>WTF. |
| 34 |
| 35 ## Library catalog |
| 36 |
| 37 The below is a list of major libraries. For a complete list, look at |
| 38 [the directory listing]. |
| 39 |
| 40 * **Containers** |
| 41 |
| 42 [Vector], [HashSet], [HashMap], [Deque] |
| 43 |
| 44 * **Strings** |
| 45 |
| 46 [String], [AtomicString], [StringBuilder], [CString] |
| 47 |
| 48 * **Reference counting** |
| 49 |
| 50 [RefCounted], [RefPtr] |
| 51 |
| 52 * **Memory** |
| 53 |
| 54 [PtrUtil.h] (`std::unique_ptr<>` utilities), |
| 55 [Allocator.h] (memory placement macros) |
| 56 |
| 57 * **Functors, binding** |
| 58 |
| 59 [Functional.h] |
| 60 |
| 61 * **Threading** |
| 62 |
| 63 [Threading.h], [ThreadingPrimitives.h] |
| 64 |
| 65 * **Compile-time switch macros** |
| 66 |
| 67 [Compiler.h] (e.g. `COMPILER(GCC)`), |
| 68 [CPU.h] (e.g. `CPU(X86_64)` or `CPU(64BIT)`), |
| 69 [build_config.h] (e.g. `OS(WIN)`) |
| 70 |
| 71 * **Miscellaneous** |
| 72 |
| 73 [Noncopyable.h] (`WTF_MAKE_NONCOPYABLE`), |
| 74 [StdLibExtras.h] (`DEFINE_STATIC_LOCAL` etc.), |
| 75 [CurrentTime.h], |
| 76 [CryptographicallyRandomNumber.h], |
| 77 [AutoReset.h], |
| 78 [Optional.h] |
| 79 |
| 80 ## History |
| 81 |
| 82 The name WTF first [appeared in 2006][1], as a replacement of its older name |
| 83 KXMLCore. At that point, there were already plenty of libraries we see today. |
| 84 For example, you can see [the initial implementation of `Vector`][2] was landed |
| 85 in 2006, replacing several manual array allocations and deallocations(!). |
| 86 |
| 87 If you dig the repository a bit more, you can find the original version of |
| 88 Assertions.h was [committed back in 2002][3]. This is probably the oldest |
| 89 library that we can find from the repository history. |
| 90 |
| 91 As you see, pretty much everything that we have today in WTF was created in |
| 92 the WebKit era. WTF was initially under the directory Source/JavaScriptCore, |
| 93 but it moved to Source/WTF/wtf in 2011-2012, then to Source/wtf in 2013. |
| 94 |
| 95 Blink forked WebKit in 2013. In 2017, the directory finally [moved to the |
| 96 current location][4] Source/platform/wtf. |
| 97 |
| 98 [the directory listing]: https://cs.chromium.org/chromium/src/third_party/WebKit
/Source/platform/wtf/ |
| 99 [base]: https://cs.chromium.org/chromium/src/base/ |
| 100 [Vector]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platfor
m/wtf/Vector.h |
| 101 [HashSet]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platfo
rm/wtf/HashSet.h |
| 102 [HashMap]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platfo
rm/wtf/HashMap.h |
| 103 [Deque]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform
/wtf/Deque.h |
| 104 [String]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platfor
m/wtf/text/WTFString.h |
| 105 [AtomicString]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/p
latform/wtf/text/AtomicString.h |
| 106 [StringBuilder]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/
platform/wtf/text/StringBuilder.h |
| 107 [CString]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platfo
rm/wtf/text/CString.h |
| 108 [RefCounted]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/pla
tform/wtf/RefCounted.h |
| 109 [RefPtr]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platfor
m/wtf/RefPtr.h |
| 110 [PtrUtil.h]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/plat
form/wtf/PtrUtil.h |
| 111 [Allocator.h]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/pl
atform/wtf/Allocator.h |
| 112 [Functional.h]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/p
latform/wtf/Functional.h |
| 113 [Threading.h]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/pl
atform/wtf/Threading.h |
| 114 [ThreadingPrimitives.h]: https://cs.chromium.org/chromium/src/third_party/WebKit
/Source/platform/wtf/ThreadingPrimitives.h |
| 115 [Compiler.h]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/pla
tform/wtf/Compiler.h |
| 116 [CPU.h]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform
/wtf/CPU.h |
| 117 [build_config.h]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source
/platform/wtf/build_config.h |
| 118 [Noncopyable.h]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/
platform/wtf/Noncopyable.h |
| 119 [StdLibExtras.h]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source
/platform/wtf/StdLibExtras.h |
| 120 [CurrentTime.h]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/
platform/wtf/CurrentTime.h |
| 121 [CryptographicallyRandomNumber.h]: https://cs.chromium.org/chromium/src/third_pa
rty/WebKit/Source/platform/wtf/CryptographicallyRandomNumber.h |
| 122 [AutoReset.h]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/pl
atform/wtf/AutoReset.h |
| 123 [Optional.h]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/pla
tform/wtf/Optional.h |
| 124 [1]: https://chromium.googlesource.com/chromium/src/+/e372c152fc6e57743ebc508fe1
7f6eb131b4ff8d |
| 125 [2]: https://chromium.googlesource.com/chromium/src/+/547a6ca360a56fbee3d5ea4a71
ba18f91622455c |
| 126 [3]: https://chromium.googlesource.com/chromium/src/+/478890427ee03fd88e6f0f58ee
8220512044bed9/third_party/WebKit/WebCore/kwq/KWQAssertions.h |
| 127 [4]:https://docs.google.com/document/d/1JK26H-1-cD9-s9QLvEfY55H2kgSxRFNPLfjs049U
s5w/edit?usp=sharing |
| OLD | NEW |