Chromium Code Reviews| 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 22 matching lines...) Expand all Loading... | |
| 33 | 33 |
| 34 #include <memory> | 34 #include <memory> |
| 35 | 35 |
| 36 #include "platform/bindings/ScriptWrappableVisitor.h" | 36 #include "platform/bindings/ScriptWrappableVisitor.h" |
| 37 #include "platform/wtf/Allocator.h" | 37 #include "platform/wtf/Allocator.h" |
| 38 #include "platform/wtf/Noncopyable.h" | 38 #include "platform/wtf/Noncopyable.h" |
| 39 #include "v8/include/v8.h" | 39 #include "v8/include/v8.h" |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 // Holds a persistent handle to a V8 object. | |
|
haraken
2017/04/29 02:39:11
Add that:
- developers should use ScopedPersisten
jbroman
2017/04/29 04:11:30
Aside: What does ScopedPersistent do that v8::Glob
adithyas
2017/05/01 17:41:16
Done.
| |
| 43 template <typename T> | 44 template <typename T> |
| 44 class ScopedPersistent { | 45 class ScopedPersistent { |
| 45 USING_FAST_MALLOC(ScopedPersistent); | 46 USING_FAST_MALLOC(ScopedPersistent); |
| 46 WTF_MAKE_NONCOPYABLE(ScopedPersistent); | 47 WTF_MAKE_NONCOPYABLE(ScopedPersistent); |
| 47 | 48 |
| 48 public: | 49 public: |
| 49 ScopedPersistent() {} | 50 ScopedPersistent() {} |
| 50 | 51 |
| 51 ScopedPersistent(v8::Isolate* isolate, v8::Local<T> handle) | 52 ScopedPersistent(v8::Isolate* isolate, v8::Local<T> handle) |
| 52 : handle_(isolate, handle) {} | 53 : handle_(isolate, handle) {} |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 | 100 |
| 100 ALWAYS_INLINE v8::Persistent<T>& Get() { return handle_; } | 101 ALWAYS_INLINE v8::Persistent<T>& Get() { return handle_; } |
| 101 | 102 |
| 102 private: | 103 private: |
| 103 v8::Persistent<T> handle_; | 104 v8::Persistent<T> handle_; |
| 104 }; | 105 }; |
| 105 | 106 |
| 106 } // namespace blink | 107 } // namespace blink |
| 107 | 108 |
| 108 #endif // ScopedPersistent_h | 109 #endif // ScopedPersistent_h |
| OLD | NEW |