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

Side by Side Diff: ppapi/shared_impl/resource.h

Issue 9391013: Make a global enum to differentiate impl & proxy. (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
« no previous file with comments | « ppapi/shared_impl/private/udp_socket_private_impl.cc ('k') | ppapi/shared_impl/resource.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 PPAPI_SHARED_IMPL_RESOURCE_H_ 5 #ifndef PPAPI_SHARED_IMPL_RESOURCE_H_
6 #define PPAPI_SHARED_IMPL_RESOURCE_H_ 6 #define PPAPI_SHARED_IMPL_RESOURCE_H_
7 7
8 #include <stddef.h> // For NULL. 8 #include <stddef.h> // For NULL.
9 9
10 #include <string> 10 #include <string>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 namespace ppapi { 63 namespace ppapi {
64 64
65 // Forward declare all the resource APIs. 65 // Forward declare all the resource APIs.
66 namespace thunk { 66 namespace thunk {
67 #define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE; 67 #define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE;
68 FOR_ALL_PPAPI_RESOURCE_APIS(DECLARE_RESOURCE_CLASS) 68 FOR_ALL_PPAPI_RESOURCE_APIS(DECLARE_RESOURCE_CLASS)
69 #undef DECLARE_RESOURCE_CLASS 69 #undef DECLARE_RESOURCE_CLASS
70 } // namespace thunk 70 } // namespace thunk
71 71
72 // Resources have slightly different registration behaviors when the're an
73 // in-process ("impl") resource in the host (renderer) process, or when they're
74 // a proxied resource in the plugin process. This enum differentiates those
75 // cases.
76 enum ResourceObjectType {
77 OBJECT_IS_IMPL,
78 OBJECT_IS_PROXY
79 };
80
72 class PPAPI_SHARED_EXPORT Resource : public base::RefCounted<Resource> { 81 class PPAPI_SHARED_EXPORT Resource : public base::RefCounted<Resource> {
73 public: 82 public:
74 // For constructing non-proxied objects. This just takes the associated 83 // Constructor for impl and non-proxied, instance-only objects.
75 // instance, and generates a new resource ID. The host resource will be the 84 //
76 // same as the newly-generated resource ID. 85 // For constructing "impl" (non-proxied) objects, this just takes the
77 explicit Resource(PP_Instance instance); 86 // associated instance, and generates a new resource ID. The host resource
87 // will be the same as the newly-generated resource ID. For all objects in
88 // the renderer (host) process, you'll use this constructor and call it with
89 // OBJECT_IS_IMPL.
90 //
91 // For proxied objects, this will create an "instance-only" object which
92 // lives only in the plugin and doesn't have a corresponding object in the
93 // host. If you have a host resource ID, use the constructor below which
94 // takes that HostResource value.
95 explicit Resource(ResourceObjectType type, PP_Instance instance);
78 96
79 // For constructing proxied objects. This takes the resource generated in 97 // For constructing given a host resource.
80 // the host side, stores it, and allocates a "local" resource ID for use in 98 //
81 // the current process. 99 // For OBJECT_IS_PROXY objects, this takes the resource generated in the host
82 explicit Resource(const HostResource& host_resource); 100 // side, stores it, and allocates a "local" resource ID for use in the
101 // current process.
102 //
103 // For OBJECT_IS_IMPL, the host resource ID must be 0, since there should be
104 // no host resource generated (impl objects should generate their own). The
105 // reason for supporting this constructor at all for the IMPL case is that
106 // some shared objects use a host resource for both modes to keep things the
107 // same.
108 explicit Resource(ResourceObjectType type,
109 const HostResource& host_resource);
dmichael (off chromium) 2012/02/13 22:24:40 Will this one ever be called with OBJECT_IS_IMPL?
brettw 2012/02/13 22:28:28 Yes, in ppb_file_ref_shared.cc. That class needs t
83 110
84 virtual ~Resource(); 111 virtual ~Resource();
85 112
86 PP_Instance pp_instance() const { return host_resource_.instance(); } 113 PP_Instance pp_instance() const { return host_resource_.instance(); }
87 114
88 // Returns the resource ID for this object in the current process without 115 // Returns the resource ID for this object in the current process without
89 // adjusting the refcount. See also GetReference(). 116 // adjusting the refcount. See also GetReference().
90 PP_Resource pp_resource() const { return pp_resource_; } 117 PP_Resource pp_resource() const { return pp_resource_; }
91 118
92 // Returns the host resource which identifies the resource in the host side 119 // Returns the host resource which identifies the resource in the host side
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 #define DEFINE_RESOURCE_CAST(RESOURCE) \ 173 #define DEFINE_RESOURCE_CAST(RESOURCE) \
147 template<> inline thunk::RESOURCE* Resource::GetAs() { \ 174 template<> inline thunk::RESOURCE* Resource::GetAs() { \
148 return As##RESOURCE(); \ 175 return As##RESOURCE(); \
149 } 176 }
150 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST) 177 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST)
151 #undef DEFINE_RESOURCE_CAST 178 #undef DEFINE_RESOURCE_CAST
152 179
153 } // namespace ppapi 180 } // namespace ppapi
154 181
155 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_ 182 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_
OLDNEW
« no previous file with comments | « ppapi/shared_impl/private/udp_socket_private_impl.cc ('k') | ppapi/shared_impl/resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698