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

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

Issue 4096008: Var serialization-related proxy stuff. This allows vars to be sent over IPC... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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/serialized_var.cc ('k') | no next file » | 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) 2010 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_VAR_SERIALIZATION_RULES_H_
6 #define PPAPI_PROXY_VAR_SERIALIZATION_RULES_H_
7
8 #include "ppapi/c/pp_var.h"
9
10 #include <string>
11
12 namespace pp {
13 namespace proxy {
14
15 // Encapsulates the rules for serializing and deserializing vars to and from
16 // the local process. The renderer and the plugin process each have separate
17 // bookkeeping rules.
18 class VarSerializationRules {
19 public:
20 virtual ~VarSerializationRules() {}
21
22 // Caller-owned calls --------------------------------------------------------
23 //
24 // A caller-owned call is when doing a function call with a "normal" input
25 // argument. The caller has a reference to the var, and the caller is
26 // responsible for freeing that reference.
27
28 // Prepares the given var for sending to the callee. If the var is a string,
29 // the value of that string will be placed in *str_val. If the var is not
30 // a string, str_val will be untouched and may be NULL.
31 virtual void SendCallerOwned(const PP_Var& var, std::string* str_val) = 0;
32
33 // When receiving a caller-owned variable, normally we don't have to do
34 // anything. However, in the case of strings, we need to deserialize the
35 // string from IPC, create a new PP_Var string in the local process, call the
36 // function, and then destroy the temporary string. These two functions
37 // handle that process
38 //
39 // BeginReceiveCallerOwned takes a var from IPC and an optional pointer to
40 // the deserialized string (which will be used only when var is a
41 // VARTYPE_STRING and may be NULL otherwise) and returns a new var
42 // representing the input in the local process. The output will be the same
43 // as the input except for strings.
44 //
45 // EndReceiveCallerOwned destroys the string created by Begin* and does
46 // nothing otherwise. It should be called with the result of Begin*.
47 virtual PP_Var BeginReceiveCallerOwned(const PP_Var& var,
48 const std::string* str_val) = 0;
49 virtual void EndReceiveCallerOwned(const PP_Var& var) = 0;
50
51 // Passinag refs -------------------------------------------------------------
52 //
53 // A pass-ref transfer is when ownership of a reference is passed from
54 // onen side to the other. Normally, this happens via return values and
55 // output arguments, as for exceptions. The code generating the value
56 // (the function returning it in the case of a return value) will AddRef
57 // the var on behalf of the consumer of the value. Responsibility for
58 // Release is on the consumer (the caller of the function in the case of a
59 // return value).
60
61 // Creates a var in the context of the local process from the given
62 // deserialized var and deserialized string (which will be used only when var
63 // is a VARTYPE_STRING and may be NULL otherwise). The input var/string
64 // should be the result of calling SendPassRef in the remote process.
65 virtual PP_Var ReceivePassRef(const PP_Var& var,
66 const std::string& str_val) = 0;
67
68 // Prepares a var to be sent to the remote side. One local reference will
69 // be passed to the remote side. Call Begin* before doing the send and End*
70 // after doing the send. See SendCallerOwned for a description of the string.
71 virtual void BeginSendPassRef(const PP_Var& var, std::string* str_val) = 0;
72 virtual void EndSendPassRef(const PP_Var& var) = 0;
73
74 // ---------------------------------------------------------------------------
75
76 virtual void ReleaseObjectRef(const PP_Var& var) = 0;
77
78 protected:
79 VarSerializationRules() {}
80 };
81
82 } // namespace proxy
83 } // namespace pp
84
85 #endif // PPAPI_PROXY_VAR_SERIALIZATION_RULES_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/serialized_var.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698