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

Side by Side Diff: third_party/WebKit/Source/core/dom/MaybeShared.h

Issue 2707243006: [SharedArrayBuffer] Prevent SharedArrayBuffer being used in Web APIs (Closed)
Patch Set: Created 3 years, 9 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MaybeShared_h
6 #define MaybeShared_h
7
8 #include "platform/heap/Handle.h"
9
10 namespace blink {
11
12 template <typename T>
13 class CORE_EXPORT MaybeShared {
14 STACK_ALLOCATED();
15
16 public:
17 MaybeShared() {}
18
19 MaybeShared(T* typedArray) : m_typedArray(typedArray) {}
20 MaybeShared(const MaybeShared& other) = default;
21 template <typename U>
22 MaybeShared(const MaybeShared<U>& other)
23 : m_typedArray(other.viewMaybeShared()) {}
24
25 MaybeShared& operator=(T* typedArray) {
26 m_typedArray = typedArray;
27 return *this;
28 }
29 MaybeShared& operator=(const MaybeShared& other) = default;
30 template <typename U>
31 MaybeShared& operator=(const MaybeShared<U>& other) {
32 m_typedArray = other.viewMaybeShared();
33 return *this;
34 }
35
36 bool isShared() const { return m_typedArray->view()->isShared(); }
37
38 T* viewNotShared() const {
39 DCHECK(!isShared());
40 return m_typedArray.get();
41 }
42 T* viewMaybeShared() const { return m_typedArray.get(); }
43
44 bool operator!() const { return !m_typedArray; }
45 explicit operator bool() const { return !!m_typedArray; }
46 operator ScriptWrappable*() const { return m_typedArray.get(); }
47
48 private:
49 Member<T> m_typedArray;
50 };
51
52 } // namespace blink
53
54 #endif // MaybeShared_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698