| OLD | NEW |
| 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 20 matching lines...) Expand all Loading... |
| 31 #ifndef SharedPersistent_h | 31 #ifndef SharedPersistent_h |
| 32 #define SharedPersistent_h | 32 #define SharedPersistent_h |
| 33 | 33 |
| 34 #include "platform/bindings/ScopedPersistent.h" | 34 #include "platform/bindings/ScopedPersistent.h" |
| 35 #include "platform/wtf/PassRefPtr.h" | 35 #include "platform/wtf/PassRefPtr.h" |
| 36 #include "platform/wtf/RefCounted.h" | 36 #include "platform/wtf/RefCounted.h" |
| 37 #include "v8/include/v8.h" | 37 #include "v8/include/v8.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 // A ref counted version of ScopedPersistent. |
| 41 template <typename T> | 42 template <typename T> |
| 42 class SharedPersistent : public RefCounted<SharedPersistent<T>> { | 43 class SharedPersistent : public RefCounted<SharedPersistent<T>> { |
| 43 WTF_MAKE_NONCOPYABLE(SharedPersistent); | 44 WTF_MAKE_NONCOPYABLE(SharedPersistent); |
| 44 | 45 |
| 45 public: | 46 public: |
| 46 static PassRefPtr<SharedPersistent<T>> Create(v8::Local<T> value, | 47 static PassRefPtr<SharedPersistent<T>> Create(v8::Local<T> value, |
| 47 v8::Isolate* isolate) { | 48 v8::Isolate* isolate) { |
| 48 return AdoptRef(new SharedPersistent<T>(value, isolate)); | 49 return AdoptRef(new SharedPersistent<T>(value, isolate)); |
| 49 } | 50 } |
| 50 | 51 |
| 51 v8::Local<T> NewLocal(v8::Isolate* isolate) const { | 52 v8::Local<T> NewLocal(v8::Isolate* isolate) const { |
| 52 return value_.NewLocal(isolate); | 53 return value_.NewLocal(isolate); |
| 53 } | 54 } |
| 54 | 55 |
| 55 bool IsEmpty() { return value_.IsEmpty(); } | 56 bool IsEmpty() { return value_.IsEmpty(); } |
| 56 | 57 |
| 57 bool operator==(const SharedPersistent<T>& other) { | 58 bool operator==(const SharedPersistent<T>& other) { |
| 58 return value_ == other.value_; | 59 return value_ == other.value_; |
| 59 } | 60 } |
| 60 | 61 |
| 61 private: | 62 private: |
| 62 explicit SharedPersistent(v8::Local<T> value, v8::Isolate* isolate) | 63 explicit SharedPersistent(v8::Local<T> value, v8::Isolate* isolate) |
| 63 : value_(isolate, value) {} | 64 : value_(isolate, value) {} |
| 64 ScopedPersistent<T> value_; | 65 ScopedPersistent<T> value_; |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 } // namespace blink | 68 } // namespace blink |
| 68 | 69 |
| 69 #endif // SharedPersistent_h | 70 #endif // SharedPersistent_h |
| OLD | NEW |