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

Side by Side Diff: chrome/renderer/extensions/scoped_persistent.h

Issue 15952012: remove remaining calls to old style MakeWeak (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_RENDERER_EXTENSIONS_SCOPED_PERSISTENT_H_ 5 #ifndef CHROME_RENDERER_EXTENSIONS_SCOPED_PERSISTENT_H_
6 #define CHROME_RENDERER_EXTENSIONS_SCOPED_PERSISTENT_H_ 6 #define CHROME_RENDERER_EXTENSIONS_SCOPED_PERSISTENT_H_
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "v8/include/v8.h" 9 #include "v8/include/v8.h"
10 10
(...skipping 27 matching lines...) Expand all
38 } 38 }
39 39
40 v8::Persistent<T> operator->() const { 40 v8::Persistent<T> operator->() const {
41 return handle_; 41 return handle_;
42 } 42 }
43 43
44 v8::Persistent<T> get() const { 44 v8::Persistent<T> get() const {
45 return handle_; 45 return handle_;
46 } 46 }
47 47
48 void MakeWeak(void* parameters, v8::NearDeathCallback callback) { 48 template<typename P>
49 void MakeWeak(P* parameters,
50 typename v8::WeakReferenceCallbacks<T, P>::Revivable callback) {
49 handle_.MakeWeak(GetIsolate(handle_), parameters, callback); 51 handle_.MakeWeak(GetIsolate(handle_), parameters, callback);
50 } 52 }
51 53
52 private: 54 private:
53 template <typename U> 55 template <typename U>
54 static v8::Isolate* GetIsolate(v8::Handle<U> object_handle) { 56 static v8::Isolate* GetIsolate(v8::Handle<U> object_handle) {
55 // Only works for v8::Object and its subclasses. Add specialisations for 57 // Only works for v8::Object and its subclasses. Add specialisations for
56 // anything else. 58 // anything else.
57 return GetIsolate(object_handle->CreationContext()); 59 return GetIsolate(object_handle->CreationContext());
58 } 60 }
59 static v8::Isolate* GetIsolate(v8::Handle<v8::Context> context_handle) { 61 static v8::Isolate* GetIsolate(v8::Handle<v8::Context> context_handle) {
60 return context_handle->GetIsolate(); 62 return context_handle->GetIsolate();
61 } 63 }
62 static v8::Isolate* GetIsolate( 64 static v8::Isolate* GetIsolate(
63 v8::Handle<v8::ObjectTemplate> template_handle) { 65 v8::Handle<v8::ObjectTemplate> template_handle) {
64 return v8::Isolate::GetCurrent(); 66 return v8::Isolate::GetCurrent();
65 } 67 }
66 68
67 v8::Persistent<T> handle_; 69 v8::Persistent<T> handle_;
68 70
69 DISALLOW_COPY_AND_ASSIGN(ScopedPersistent); 71 DISALLOW_COPY_AND_ASSIGN(ScopedPersistent);
70 }; 72 };
71 73
72 } // namespace extensions 74 } // namespace extensions
73 75
74 #endif // CHROME_RENDERER_EXTENSIONS_SCOPED_PERSISTENT_H_ 76 #endif // CHROME_RENDERER_EXTENSIONS_SCOPED_PERSISTENT_H_
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/miscellaneous_bindings.cc ('k') | content/renderer/browser_plugin/browser_plugin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698