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

Side by Side Diff: third_party/WebKit/Source/platform/bindings/SharedPersistent.h

Issue 2851563004: Add documentation for platform/bindings (Closed)
Patch Set: Code review Created 3 years, 7 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
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 20 matching lines...) Expand all
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.
haraken 2017/04/29 02:39:11 This class is intended to be used for ScriptValue
adithyas 2017/05/01 17:41:16 Added.
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698