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

Side by Side Diff: Source/bindings/v8/ScopedPersistent.h

Issue 23254004: Implement ScriptPromise and ScriptFunction (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Control shouldn't reach the end of a non-void function Created 7 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 | Annotate | Revision Log
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 return v8::Local<T>::New(isolate, m_handle); 57 return v8::Local<T>::New(isolate, m_handle);
58 } 58 }
59 59
60 template<typename P> 60 template<typename P>
61 void makeWeak(P* parameters, void (*callback)(v8::Isolate*, v8::Persistent<T >*, P*)) 61 void makeWeak(P* parameters, void (*callback)(v8::Isolate*, v8::Persistent<T >*, P*))
62 { 62 {
63 m_handle.MakeWeak(parameters, callback); 63 m_handle.MakeWeak(parameters, callback);
64 } 64 }
65 65
66 bool isEmpty() const { return m_handle.IsEmpty(); } 66 bool isEmpty() const { return m_handle.IsEmpty(); }
67 bool isWeak() const { return m_handle.IsWeak(); }
67 68
68 void set(v8::Isolate* isolate, v8::Handle<T> handle) 69 void set(v8::Isolate* isolate, v8::Handle<T> handle)
69 { 70 {
70 m_handle.Reset(isolate, handle); 71 m_handle.Reset(isolate, handle);
71 } 72 }
72 73
73 // Note: This is clear in the OwnPtr sense, not the v8::Handle sense. 74 // Note: This is clear in the OwnPtr sense, not the v8::Handle sense.
74 void clear() 75 void clear()
75 { 76 {
76 if (m_handle.IsEmpty()) 77 if (m_handle.IsEmpty())
77 return; 78 return;
78 m_handle.Dispose(); 79 m_handle.Dispose();
79 m_handle.Clear(); 80 m_handle.Clear();
80 } 81 }
81 82
82 bool operator==(const ScopedPersistent<T>& other) 83 bool operator==(const ScopedPersistent<T>& other)
83 { 84 {
84 return m_handle == other.m_handle; 85 return m_handle == other.m_handle;
85 } 86 }
86 87
88 template <class S>
89 bool operator==(const v8::Handle<S> other) const
90 {
91 return m_handle == other;
92 }
93
87 private: 94 private:
88 // FIXME: This function does an unsafe handle access. Remove it. 95 // FIXME: This function does an unsafe handle access. Remove it.
89 friend class V8AbstractEventListener; 96 friend class V8AbstractEventListener;
90 friend class V8PerIsolateData; 97 friend class V8PerIsolateData;
91 ALWAYS_INLINE v8::Persistent<T>& getUnsafe() 98 ALWAYS_INLINE v8::Persistent<T>& getUnsafe()
92 { 99 {
93 return m_handle; 100 return m_handle;
94 } 101 }
95 102
96 v8::Persistent<T> m_handle; 103 v8::Persistent<T> m_handle;
97 }; 104 };
98 105
99 } // namespace WebCore 106 } // namespace WebCore
100 107
101 #endif // ScopedPersistent_h 108 #endif // ScopedPersistent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698