OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef Transferables_h | 5 #ifndef Transferables_h |
6 #define Transferables_h | 6 #define Transferables_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
10 #include "wtf/Noncopyable.h" | 10 #include "wtf/Noncopyable.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 class DOMArrayBufferBase; | 14 class DOMArrayBufferBase; |
15 class ImageBitmap; | 15 class ImageBitmap; |
16 class MessagePort; | 16 class MessagePort; |
17 | 17 |
18 using ArrayBufferArray = HeapVector<Member<DOMArrayBufferBase>>; | 18 using ArrayBufferArray = HeapVector<Member<DOMArrayBufferBase>>; |
19 using ImageBitmapArray = HeapVector<Member<ImageBitmap>>; | 19 using ImageBitmapArray = HeapVector<Member<ImageBitmap>>; |
20 using MessagePortArray = HeapVector<Member<MessagePort>>; | 20 using MessagePortArray = HeapVector<Member<MessagePort>>; |
21 | 21 |
22 class CORE_EXPORT Transferables final { | 22 class CORE_EXPORT Transferables : public GarbageCollectedFinalized<Transferables > { |
23 STACK_ALLOCATED(); | |
24 WTF_MAKE_NONCOPYABLE(Transferables); | 23 WTF_MAKE_NONCOPYABLE(Transferables); |
25 public: | 24 public: |
26 Transferables() | 25 static Transferables* create() { return s_registeredFactory(); } |
27 { | 26 Transferables() { } |
28 } | 27 virtual ~Transferables() { } |
29 | 28 |
30 ArrayBufferArray arrayBuffers; | 29 ArrayBufferArray arrayBuffers; |
31 ImageBitmapArray imageBitmaps; | 30 ImageBitmapArray imageBitmaps; |
32 MessagePortArray messagePorts; | 31 MessagePortArray messagePorts; |
32 DECLARE_VIRTUAL_TRACE(); | |
33 | |
34 using Factory = Transferables*(*)(); | |
35 static void registerFactory(Factory f) { s_registeredFactory = f; } | |
haraken
2016/04/21 00:29:02
f => factory
| |
36 | |
37 private: | |
38 static Factory s_registeredFactory; | |
33 }; | 39 }; |
34 | 40 |
35 // Along with extending |Transferables| to hold a new kind of transferable | 41 // Along with extending |Transferables| to hold a new kind of transferable |
36 // objects, serialization handling code changes are required: | 42 // objects, serialization handling code changes are required: |
37 // - extend ScriptValueSerializer::copyTransferables() | 43 // - extend ScriptValueSerializer::copyTransferables() |
38 // - alter SerializedScriptValue(Factory) to do the actual transfer. | 44 // - alter SerializedScriptValue(Factory) to do the actual transfer. |
39 | 45 |
40 } // namespace blink | 46 } // namespace blink |
41 | 47 |
42 #endif // Transferables_h | 48 #endif // Transferables_h |
OLD | NEW |