| 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. This class is intended for use by |
| 42 // ScriptValue and not for normal use. Consider using ScopedPersistent directly |
| 43 // instead. |
| 41 template <typename T> | 44 template <typename T> |
| 42 class SharedPersistent : public RefCounted<SharedPersistent<T>> { | 45 class SharedPersistent : public RefCounted<SharedPersistent<T>> { |
| 43 WTF_MAKE_NONCOPYABLE(SharedPersistent); | 46 WTF_MAKE_NONCOPYABLE(SharedPersistent); |
| 44 | 47 |
| 45 public: | 48 public: |
| 46 static PassRefPtr<SharedPersistent<T>> Create(v8::Local<T> value, | 49 static PassRefPtr<SharedPersistent<T>> Create(v8::Local<T> value, |
| 47 v8::Isolate* isolate) { | 50 v8::Isolate* isolate) { |
| 48 return AdoptRef(new SharedPersistent<T>(value, isolate)); | 51 return AdoptRef(new SharedPersistent<T>(value, isolate)); |
| 49 } | 52 } |
| 50 | 53 |
| 51 v8::Local<T> NewLocal(v8::Isolate* isolate) const { | 54 v8::Local<T> NewLocal(v8::Isolate* isolate) const { |
| 52 return value_.NewLocal(isolate); | 55 return value_.NewLocal(isolate); |
| 53 } | 56 } |
| 54 | 57 |
| 55 bool IsEmpty() { return value_.IsEmpty(); } | 58 bool IsEmpty() { return value_.IsEmpty(); } |
| 56 | 59 |
| 57 bool operator==(const SharedPersistent<T>& other) { | 60 bool operator==(const SharedPersistent<T>& other) { |
| 58 return value_ == other.value_; | 61 return value_ == other.value_; |
| 59 } | 62 } |
| 60 | 63 |
| 61 private: | 64 private: |
| 62 explicit SharedPersistent(v8::Local<T> value, v8::Isolate* isolate) | 65 explicit SharedPersistent(v8::Local<T> value, v8::Isolate* isolate) |
| 63 : value_(isolate, value) {} | 66 : value_(isolate, value) {} |
| 64 ScopedPersistent<T> value_; | 67 ScopedPersistent<T> value_; |
| 65 }; | 68 }; |
| 66 | 69 |
| 67 } // namespace blink | 70 } // namespace blink |
| 68 | 71 |
| 69 #endif // SharedPersistent_h | 72 #endif // SharedPersistent_h |
| OLD | NEW |