Chromium Code Reviews| Index: gin/unsafe_persistent.h |
| diff --git a/chrome/renderer/extensions/unsafe_persistent.h b/gin/unsafe_persistent.h |
| similarity index 77% |
| copy from chrome/renderer/extensions/unsafe_persistent.h |
| copy to gin/unsafe_persistent.h |
| index f8fa9bbd42acfa9a57eb531dbb17c4b37ce49c38..84a71c91d1904a6f96fdab06cec400d69a49b78c 100644 |
| --- a/chrome/renderer/extensions/unsafe_persistent.h |
| +++ b/gin/unsafe_persistent.h |
| @@ -1,13 +1,13 @@ |
| -// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CHROME_RENDERER_EXTENSIONS_UNSAFE_PERSISTENT_H_ |
| -#define CHROME_RENDERER_EXTENSIONS_UNSAFE_PERSISTENT_H_ |
| +#ifndef GIN_UNSAFE_PERSISTENT_H_ |
|
jochen (gone - plz use gerrit)
2014/02/24 11:21:52
instead of putting this into gin/, i'd put it into
hajimehoshi
2014/02/25 04:27:47
Done. (I put this into the namespace 'content', bu
|
| +#define GIN_UNSAFE_PERSISTENT_H_ |
| #include "v8/include/v8.h" |
| -namespace extensions { |
| +namespace gin { |
| // An unsafe way to pass Persistent handles around. Do not use unless you know |
| // what you're doing. UnsafePersistent is only safe to use when we know that the |
| @@ -27,9 +27,17 @@ template<typename T> class UnsafePersistent { |
| value_ = persistent.ClearAndLeak(); |
| } |
| + T* Value() const { |
| + return value_; |
| + } |
| + |
| + T* operator ->() const { |
| + return value_; |
| + } |
| + |
| // Usage of this function requires |
| // V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR to be defined |
| - void dispose() { |
| + void Dispose() { |
| v8::Persistent<T> handle(value_); |
| handle.Reset(); |
| value_ = 0; |
| @@ -37,7 +45,7 @@ template<typename T> class UnsafePersistent { |
| // Usage of this function requires |
| // V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR to be defined |
| - v8::Local<T> newLocal(v8::Isolate* isolate) { |
| + v8::Local<T> NewLocal(v8::Isolate* isolate) { |
| return v8::Local<T>::New(isolate, v8::Local<T>(value_)); |
| } |
| @@ -45,6 +53,6 @@ template<typename T> class UnsafePersistent { |
| T* value_; |
| }; |
| -} // namespace extensions |
| +} // namespace gin |
| -#endif // CHROME_RENDERER_EXTENSIONS_UNSAFE_PERSISTENT_H_ |
| +#endif // GIN_UNSAFE_PERSISTENT_H_ |