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

Side by Side Diff: ppapi/proxy/host_resource.h

Issue 6334016: Refactor PPAPI proxy resource handling to maintain which host they came from,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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/proxy/dispatcher.cc ('k') | ppapi/proxy/host_var_serialization_rules.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef PPAPI_PROXY_HOST_RESOURCE_H_
6 #define PPAPI_PROXY_HOST_RESOURCE_H_
7
8 #include "ppapi/c/pp_instance.h"
9 #include "ppapi/c/pp_resource.h"
10
11 namespace pp {
12 namespace proxy {
13
14 // Represents a PP_Resource sent over the wire. This just wraps a PP_Resource.
15 // The point is to prevent mistakes where the wrong resource value is sent.
16 // Resource values are remapped in the plugin so that it can talk to multiple
17 // hosts. If all values were PP_Resource, it would be easy to forget to do
18 // this tranformation.
19 //
20 // All HostResources respresent IDs valid in the host.
21 class HostResource {
22 public:
23 HostResource() : instance_(0), host_resource_(0) {
24 }
25
26 bool is_null() const {
27 return !host_resource_;
28 }
29
30 // Sets and retrieves the internal PP_Resource which is valid for the host
31 // (a.k.a. renderer, as opposed to the plugin) process.
32 //
33 // DO NOT CALL THESE FUNCTIONS IN THE PLUGIN SIDE OF THE PROXY. The values
34 // will be invalid. See the class comment above.
35 void SetHostResource(PP_Instance instance, PP_Resource resource) {
36 instance_ = instance;
37 host_resource_ = resource;
38 }
39 PP_Resource host_resource() const {
40 return host_resource_;
41 }
42
43 PP_Instance instance() const { return instance_; }
44
45 // This object is used in maps so we need to provide this sorting operator.
46 bool operator<(const HostResource& other) const {
47 if (instance_ != other.instance_)
48 return instance_ < other.instance_;
49 return host_resource_ < other.host_resource_;
50 }
51
52 private:
53 PP_Instance instance_;
54 PP_Resource host_resource_;
55 };
56
57 } // namespace proxy
58 } // namespace pp
59
60 #endif // PPAPI_PROXY_HOST_RESOURCE_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/dispatcher.cc ('k') | ppapi/proxy/host_var_serialization_rules.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698