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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/scriptable_handle.h

Issue 9390028: Remove browser support for non-PPAPI nexes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // The browser scriptable container class. The methods on this class 5 // The browser scriptable container class. The methods on this class
6 // are defined in the specific API directories. 6 // are defined in the specific API directories.
7 7
8 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SCRIPTABLE_HANDLE_H_ 8 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SCRIPTABLE_HANDLE_H_
9 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SCRIPTABLE_HANDLE_H_ 9 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SCRIPTABLE_HANDLE_H_
10 10
(...skipping 10 matching lines...) Expand all
21 #include "native_client/src/include/nacl_macros.h" 21 #include "native_client/src/include/nacl_macros.h"
22 #include "native_client/src/include/nacl_string.h" 22 #include "native_client/src/include/nacl_string.h"
23 #include "native_client/src/include/portability.h" 23 #include "native_client/src/include/portability.h"
24 #include "native_client/src/trusted/plugin/utility.h" 24 #include "native_client/src/trusted/plugin/utility.h"
25 #include "ppapi/cpp/dev/scriptable_object_deprecated.h" 25 #include "ppapi/cpp/dev/scriptable_object_deprecated.h"
26 #include "ppapi/cpp/private/var_private.h" 26 #include "ppapi/cpp/private/var_private.h"
27 27
28 namespace plugin { 28 namespace plugin {
29 29
30 // Forward declarations for externals. 30 // Forward declarations for externals.
31 class DescBasedHandle;
32 class Plugin; 31 class Plugin;
33 32
34 // ScriptableHandle encapsulates objects that are scriptable from the browser. 33 // ScriptableHandle encapsulates objects that are scriptable from the browser.
jvoung - send to chromium... 2012/02/15 08:28:17 It seems like from the implementation, most of the
sehr (please use chromium) 2012/02/15 17:58:10 You're right. It only wraps Plugins now and they
35 class ScriptableHandle : public pp::deprecated::ScriptableObject { 34 class ScriptableHandle : public pp::deprecated::ScriptableObject {
36 public: 35 public:
37 // Factory methods for creation. 36 // Factory method.
38 static ScriptableHandle* NewPlugin(Plugin* plugin); 37 static ScriptableHandle* NewPlugin(Plugin* plugin);
39 static ScriptableHandle* NewDescHandle(DescBasedHandle* desc_handle);
40 38
41 // If not NULL, this var should be reused to pass this object to the browser. 39 // If not NULL, this var should be reused to pass this object to the browser.
42 pp::VarPrivate* var() { return var_; } 40 pp::VarPrivate* var() { return var_; }
43 41
44 // Check that a pointer is to a validly created ScriptableHandle.
45 static bool is_valid(const ScriptableHandle* handle);
46 static void Unref(ScriptableHandle** handle); 42 static void Unref(ScriptableHandle** handle);
47 43
48 // Get the contained plugin object. NULL if this contains a descriptor. 44 // Get the contained plugin object. NULL if this contains a descriptor.
49 Plugin* plugin() const { return plugin_; } 45 Plugin* plugin() const { return plugin_; }
50 46
51 // Get the contained descriptor object. NULL if this contains a plugin.
52 // OBSOLETE -- this support is only needed for SRPC descriptor passing.
53 // TODO(polina): Remove this support when SRPC descriptor passing is removed.
54 DescBasedHandle* desc_handle() const { return desc_handle_; }
55
56 // This function is called when we are about to share the object owned by the 47 // This function is called when we are about to share the object owned by the
57 // plugin with the browser. Since reference counting on the browser side is 48 // plugin with the browser. Since reference counting on the browser side is
58 // handled via pp::Var's, we create the var() here if not created already. 49 // handled via pp::Var's, we create the var() here if not created already.
59 ScriptableHandle* AddRef(); 50 ScriptableHandle* AddRef();
60 // Remove a browser reference to this object. 51 // Remove a browser reference to this object.
61 // Delete the object when the ref count becomes 0. 52 // Delete the object when the ref count becomes 0.
62 // If var() is set, we delete it. Otherwise, we delete the object itself. 53 // If var() is set, we delete it. Otherwise, we delete the object itself.
63 // Therefore, this cannot be called more than once. 54 // Therefore, this cannot be called more than once.
64 void Unref(); 55 void Unref();
65 56
(...skipping 27 matching lines...) Expand all
93 84
94 // Sets |exception| to indicate that constructor is not supported. 85 // Sets |exception| to indicate that constructor is not supported.
95 virtual pp::Var Construct(const std::vector<pp::Var>& args, 86 virtual pp::Var Construct(const std::vector<pp::Var>& args,
96 pp::Var* exception); 87 pp::Var* exception);
97 88
98 private: 89 private:
99 NACL_DISALLOW_COPY_AND_ASSIGN(ScriptableHandle); 90 NACL_DISALLOW_COPY_AND_ASSIGN(ScriptableHandle);
100 // Prevent construction from outside the class: must use factory New() 91 // Prevent construction from outside the class: must use factory New()
101 // method instead. 92 // method instead.
102 explicit ScriptableHandle(Plugin* plugin); 93 explicit ScriptableHandle(Plugin* plugin);
103 explicit ScriptableHandle(DescBasedHandle* desc_handle);
104 // This will be called when both the plugin and the browser clear all 94 // This will be called when both the plugin and the browser clear all
105 // references to this object. 95 // references to this object.
106 virtual ~ScriptableHandle(); 96 virtual ~ScriptableHandle();
107 97
108 // When we pass the object owned by the plugin to the browser, we need to wrap 98 // When we pass the object owned by the plugin to the browser, we need to wrap
109 // it in a pp::VarPrivate, which also registers the object with the browser 99 // it in a pp::VarPrivate, which also registers the object with the browser
110 // for refcounting. It must be registered only once with all other var 100 // for refcounting. It must be registered only once with all other var
111 // references being copies of the original one. Thus, we record the 101 // references being copies of the original one. Thus, we record the
112 // pp::VarPrivate here and reuse it when satisfiying additional browser 102 // pp::VarPrivate here and reuse it when satisfiying additional browser
113 // requests. This way we also ensure that when the browser clears its 103 // requests. This way we also ensure that when the browser clears its
114 // references, this object does not get deallocated while we still hold ours. 104 // references, this object does not get deallocated while we still hold ours.
115 // This is never set for objects that are not shared with the browser nor for 105 // This is never set for objects that are not shared with the browser nor for
116 // objects created during SRPC calls as they are taken over by the browser on 106 // objects created during SRPC calls as they are taken over by the browser on
117 // return. 107 // return.
118 pp::VarPrivate* var_; 108 pp::VarPrivate* var_;
119 109
120 // We should have no more than one internal plugin owner for this object, 110 // We should have no more than one internal plugin owner for this object,
121 // and only that owner should call Unref(). To CHECK for that keep a counter. 111 // and only that owner should call Unref(). To CHECK for that keep a counter.
122 int num_unref_calls_; 112 int num_unref_calls_;
123 113
124 // The contained plugin object. 114 // The contained plugin object.
125 Plugin* plugin_; 115 Plugin* plugin_;
126 // OBSOLETE -- this support is only needed for SRPC descriptor passing.
127 // TODO(polina): Remove this support when SRPC descriptor passing is removed.
128 // The contained descriptor handle object.
129 DescBasedHandle* desc_handle_;
130 }; 116 };
131 117
132 } // namespace plugin 118 } // namespace plugin
133 119
134 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SCRIPTABLE_HANDLE_H_ 120 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SCRIPTABLE_HANDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698