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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScopedPersistent.h

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef ScopedPersistent_h 31 #ifndef ScopedPersistent_h
32 #define ScopedPersistent_h 32 #define ScopedPersistent_h
33 33
34 #include "wtf/Allocator.h" 34 #include "wtf/Allocator.h"
35 #include "wtf/Noncopyable.h" 35 #include "wtf/Noncopyable.h"
36 #include <memory>
37 #include <v8.h> 36 #include <v8.h>
38 37
39 namespace blink { 38 namespace blink {
40 39
41 template<typename T> 40 template<typename T>
42 class ScopedPersistent { 41 class ScopedPersistent {
43 USING_FAST_MALLOC(ScopedPersistent); 42 USING_FAST_MALLOC(ScopedPersistent);
44 WTF_MAKE_NONCOPYABLE(ScopedPersistent); 43 WTF_MAKE_NONCOPYABLE(ScopedPersistent);
45 public: 44 public:
46 ScopedPersistent() { } 45 ScopedPersistent() { }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 85 }
87 86
88 bool isEmpty() const { return m_handle.IsEmpty(); } 87 bool isEmpty() const { return m_handle.IsEmpty(); }
89 bool isWeak() const { return m_handle.IsWeak(); } 88 bool isWeak() const { return m_handle.IsWeak(); }
90 89
91 void set(v8::Isolate* isolate, v8::Local<T> handle) 90 void set(v8::Isolate* isolate, v8::Local<T> handle)
92 { 91 {
93 m_handle.Reset(isolate, handle); 92 m_handle.Reset(isolate, handle);
94 } 93 }
95 94
96 // Note: This is clear in the std::unique_ptr sense, not the v8::Handle sens e. 95 // Note: This is clear in the OwnPtr sense, not the v8::Handle sense.
97 void clear() 96 void clear()
98 { 97 {
99 m_handle.Reset(); 98 m_handle.Reset();
100 } 99 }
101 100
102 void setReference(const v8::Persistent<v8::Object>& parent, v8::Isolate* iso late) 101 void setReference(const v8::Persistent<v8::Object>& parent, v8::Isolate* iso late)
103 { 102 {
104 isolate->SetReference(parent, m_handle); 103 isolate->SetReference(parent, m_handle);
105 } 104 }
106 105
(...skipping 14 matching lines...) Expand all
121 } 120 }
122 121
123 122
124 private: 123 private:
125 v8::Persistent<T> m_handle; 124 v8::Persistent<T> m_handle;
126 }; 125 };
127 126
128 } // namespace blink 127 } // namespace blink
129 128
130 #endif // ScopedPersistent_h 129 #endif // ScopedPersistent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698