Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012, Google Inc. | 1 // Copyright 2012, Google Inc. |
| 2 // All rights reserved. | 2 // 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 13 matching lines...) Expand all Loading... | |
| 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 #ifndef DartIsolate_h | 30 #ifndef DartIsolate_h |
| 31 #define DartIsolate_h | 31 #define DartIsolate_h |
| 32 | 32 |
| 33 #include <dart_api.h> | 33 #include <dart_api.h> |
| 34 #include <wtf/HashMap.h> | |
| 34 #include <wtf/RefPtr.h> | 35 #include <wtf/RefPtr.h> |
| 35 #include <wtf/ThreadSafeRefCounted.h> | 36 #include <wtf/ThreadSafeRefCounted.h> |
| 36 | 37 |
| 37 namespace WebCore { | 38 namespace WebCore { |
| 38 | 39 |
| 39 class DartIsolate : public ThreadSafeRefCounted<DartIsolate> { | 40 class DartIsolate : public ThreadSafeRefCounted<DartIsolate> { |
| 40 WTF_MAKE_NONCOPYABLE(DartIsolate); | 41 WTF_MAKE_NONCOPYABLE(DartIsolate); |
| 41 public: | 42 public: |
| 42 static PassRefPtr<DartIsolate> create(Dart_Isolate isolate) | 43 static PassRefPtr<DartIsolate> create(Dart_Isolate isolate) |
| 43 { | 44 { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 67 | 68 |
| 68 ~Scope() | 69 ~Scope() |
| 69 { | 70 { |
| 70 m_isolate->exit(); | 71 m_isolate->exit(); |
| 71 } | 72 } |
| 72 | 73 |
| 73 private: | 74 private: |
| 74 RefPtr<DartIsolate> m_isolate; | 75 RefPtr<DartIsolate> m_isolate; |
| 75 }; | 76 }; |
| 76 | 77 |
| 78 Dart_Handle createWeakPersistentHandle(Dart_Handle object, void* peer, Dart_ WeakPersistentHandleFinalizer); | |
| 79 | |
| 77 private: | 80 private: |
| 78 DartIsolate(Dart_Isolate); | 81 DartIsolate(Dart_Isolate); |
| 79 | 82 |
| 80 Dart_Isolate m_isolate; | 83 Dart_Isolate m_isolate; |
| 84 | |
| 85 static void weakCallbackWrapper(Dart_Handle object, void* peer); | |
|
Anton Muhin
2012/03/28 18:03:23
do you really need a map here? it looks like all
podivilov
2012/03/28 18:20:05
I will need to dispose persistent handles in some
| |
| 86 | |
| 87 struct WeakCallbackData | |
| 88 { | |
| 89 WeakCallbackData() | |
| 90 : peer(0) | |
| 91 , weakCallback(0) | |
| 92 { | |
| 93 } | |
| 94 | |
| 95 WeakCallbackData(void* peer, Dart_WeakPersistentHandleFinalizer weakCall back) | |
| 96 : peer(peer) | |
| 97 , weakCallback(weakCallback) | |
| 98 { | |
| 99 } | |
| 100 | |
| 101 void* peer; | |
| 102 Dart_WeakPersistentHandleFinalizer weakCallback; | |
| 103 }; | |
| 104 typedef HashMap<Dart_Handle, WeakCallbackData> WeakCallbackMap; | |
| 105 WeakCallbackMap m_weakCallbackMap; | |
| 81 }; | 106 }; |
| 82 | 107 |
| 83 | 108 |
| 84 | 109 |
| 85 } | 110 } |
| 86 | 111 |
| 87 #endif // DartIsolate_h | 112 #endif // DartIsolate_h |
| OLD | NEW |