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

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

Issue 10790078: PPAPI: Make PPB_MessageLoop_Dev::GetForMainThread work (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: review comments Created 8 years, 3 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
« no previous file with comments | « ppapi/proxy/ppb_message_loop_proxy.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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // For constructing "impl" (non-proxied) objects, this just takes the 100 // For constructing "impl" (non-proxied) objects, this just takes the
101 // associated instance, and generates a new resource ID. The host resource 101 // associated instance, and generates a new resource ID. The host resource
102 // will be the same as the newly-generated resource ID. For all objects in 102 // will be the same as the newly-generated resource ID. For all objects in
103 // the renderer (host) process, you'll use this constructor and call it with 103 // the renderer (host) process, you'll use this constructor and call it with
104 // OBJECT_IS_IMPL. 104 // OBJECT_IS_IMPL.
105 // 105 //
106 // For proxied objects, this will create an "instance-only" object which 106 // For proxied objects, this will create an "instance-only" object which
107 // lives only in the plugin and doesn't have a corresponding object in the 107 // lives only in the plugin and doesn't have a corresponding object in the
108 // host. If you have a host resource ID, use the constructor below which 108 // host. If you have a host resource ID, use the constructor below which
109 // takes that HostResource value. 109 // takes that HostResource value.
110 explicit Resource(ResourceObjectType type, PP_Instance instance); 110 Resource(ResourceObjectType type, PP_Instance instance);
111 111
112 // For constructing given a host resource. 112 // For constructing given a host resource.
113 // 113 //
114 // For OBJECT_IS_PROXY objects, this takes the resource generated in the host 114 // For OBJECT_IS_PROXY objects, this takes the resource generated in the host
115 // side, stores it, and allocates a "local" resource ID for use in the 115 // side, stores it, and allocates a "local" resource ID for use in the
116 // current process. 116 // current process.
117 // 117 //
118 // For OBJECT_IS_IMPL, the host resource ID must be 0, since there should be 118 // For OBJECT_IS_IMPL, the host resource ID must be 0, since there should be
119 // no host resource generated (impl objects should generate their own). The 119 // no host resource generated (impl objects should generate their own). The
120 // reason for supporting this constructor at all for the IMPL case is that 120 // reason for supporting this constructor at all for the IMPL case is that
121 // some shared objects use a host resource for both modes to keep things the 121 // some shared objects use a host resource for both modes to keep things the
122 // same. 122 // same.
123 explicit Resource(ResourceObjectType type, 123 Resource(ResourceObjectType type, const HostResource& host_resource);
124 const HostResource& host_resource); 124
125 // Constructor for untracked objects. These have no associated instance. Use
126 // this with care, as the object is likely to persist for the lifetime of the
127 // plugin module. This is appropriate in some rare cases, like the
128 // PPB_MessageLoop resource for the main thread.
129 struct Untracked {};
130 explicit Resource(Untracked);
125 131
126 virtual ~Resource(); 132 virtual ~Resource();
127 133
128 PP_Instance pp_instance() const { return host_resource_.instance(); } 134 PP_Instance pp_instance() const { return host_resource_.instance(); }
129 135
130 // Returns the resource ID for this object in the current process without 136 // Returns the resource ID for this object in the current process without
131 // adjusting the refcount. See also GetReference(). 137 // adjusting the refcount. See also GetReference().
132 PP_Resource pp_resource() const { return pp_resource_; } 138 PP_Resource pp_resource() const { return pp_resource_; }
133 139
134 // Returns the host resource which identifies the resource in the host side 140 // Returns the host resource which identifies the resource in the host side
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 #define DEFINE_RESOURCE_CAST(RESOURCE) \ 207 #define DEFINE_RESOURCE_CAST(RESOURCE) \
202 template<> inline thunk::RESOURCE* Resource::GetAs() { \ 208 template<> inline thunk::RESOURCE* Resource::GetAs() { \
203 return As##RESOURCE(); \ 209 return As##RESOURCE(); \
204 } 210 }
205 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST) 211 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST)
206 #undef DEFINE_RESOURCE_CAST 212 #undef DEFINE_RESOURCE_CAST
207 213
208 } // namespace ppapi 214 } // namespace ppapi
209 215
210 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_ 216 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_message_loop_proxy.cc ('k') | ppapi/shared_impl/resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698