OLD | NEW |
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 #ifndef PPAPI_SHARED_IMPL_HOST_RESOURCE_H_ | 5 #ifndef PPAPI_SHARED_IMPL_HOST_RESOURCE_H_ |
6 #define PPAPI_SHARED_IMPL_HOST_RESOURCE_H_ | 6 #define PPAPI_SHARED_IMPL_HOST_RESOURCE_H_ |
7 | 7 |
8 #include "ppapi/c/pp_instance.h" | 8 #include "ppapi/c/pp_instance.h" |
9 #include "ppapi/c/pp_resource.h" | 9 #include "ppapi/c/pp_resource.h" |
10 #include "ppapi/shared_impl/ppapi_shared_export.h" | 10 #include "ppapi/shared_impl/ppapi_shared_export.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 // this transformation. | 32 // this transformation. |
33 // | 33 // |
34 // To get the corresponding plugin PP_Resource for a HostResource, use | 34 // To get the corresponding plugin PP_Resource for a HostResource, use |
35 // PluginResourceTracker::PluginResourceForHostResource(). | 35 // PluginResourceTracker::PluginResourceForHostResource(). |
36 // | 36 // |
37 // All HostResources respresent IDs valid in the host. | 37 // All HostResources respresent IDs valid in the host. |
38 class PPAPI_SHARED_EXPORT HostResource { | 38 class PPAPI_SHARED_EXPORT HostResource { |
39 public: | 39 public: |
40 HostResource(); | 40 HostResource(); |
41 | 41 |
42 bool is_null() const { | 42 bool is_null() const { return !host_resource_; } |
43 return !host_resource_; | |
44 } | |
45 | 43 |
46 // Some resources are plugin-side only and don't have a corresponding | 44 // Some resources are plugin-side only and don't have a corresponding |
47 // resource in the host. Yet these resources still need an instance to be | 45 // resource in the host. Yet these resources still need an instance to be |
48 // associated with. This function creates a HostResource with the given | 46 // associated with. This function creates a HostResource with the given |
49 // instances and a 0 host resource ID for these cases. | 47 // instances and a 0 host resource ID for these cases. |
50 static HostResource MakeInstanceOnly(PP_Instance instance); | 48 static HostResource MakeInstanceOnly(PP_Instance instance); |
51 | 49 |
52 // Sets and retrieves the internal PP_Resource which is valid for the host | 50 // Sets and retrieves the internal PP_Resource which is valid for the host |
53 // (a.k.a. renderer, as opposed to the plugin) process. | 51 // (a.k.a. renderer, as opposed to the plugin) process. |
54 // | 52 // |
55 // DO NOT CALL THESE FUNCTIONS IN THE PLUGIN SIDE OF THE PROXY. The values | 53 // DO NOT CALL THESE FUNCTIONS IN THE PLUGIN SIDE OF THE PROXY. The values |
56 // will be invalid. See the class comment above. | 54 // will be invalid. See the class comment above. |
57 void SetHostResource(PP_Instance instance, PP_Resource resource); | 55 void SetHostResource(PP_Instance instance, PP_Resource resource); |
58 PP_Resource host_resource() const { | 56 PP_Resource host_resource() const { return host_resource_; } |
59 return host_resource_; | |
60 } | |
61 | 57 |
62 PP_Instance instance() const { return instance_; } | 58 PP_Instance instance() const { return instance_; } |
63 | 59 |
64 // This object is used in maps so we need to provide this sorting operator. | 60 // This object is used in maps so we need to provide this sorting operator. |
65 bool operator<(const HostResource& other) const { | 61 bool operator<(const HostResource& other) const { |
66 if (instance_ != other.instance_) | 62 if (instance_ != other.instance_) |
67 return instance_ < other.instance_; | 63 return instance_ < other.instance_; |
68 return host_resource_ < other.host_resource_; | 64 return host_resource_ < other.host_resource_; |
69 } | 65 } |
70 | 66 |
71 private: | 67 private: |
72 PP_Instance instance_; | 68 PP_Instance instance_; |
73 PP_Resource host_resource_; | 69 PP_Resource host_resource_; |
74 }; | 70 }; |
75 | 71 |
76 } // namespace ppapi | 72 } // namespace ppapi |
77 | 73 |
78 #endif // PPAPI_SHARED_IMPL_HOST_RESOURCE_H_ | 74 #endif // PPAPI_SHARED_IMPL_HOST_RESOURCE_H_ |
OLD | NEW |