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

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

Issue 9316123: Remove special handling for strings in var serialization. (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
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_PROXY_VAR_SERIALIZATION_RULES_H_ 5 #ifndef PPAPI_PROXY_VAR_SERIALIZATION_RULES_H_
6 #define PPAPI_PROXY_VAR_SERIALIZATION_RULES_H_ 6 #define PPAPI_PROXY_VAR_SERIALIZATION_RULES_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "ppapi/c/pp_var.h" 9 #include "ppapi/c/pp_var.h"
10 10
(...skipping 10 matching lines...) Expand all
21 class VarSerializationRules { 21 class VarSerializationRules {
22 public: 22 public:
23 virtual ~VarSerializationRules() {} 23 virtual ~VarSerializationRules() {}
24 24
25 // Caller-owned calls -------------------------------------------------------- 25 // Caller-owned calls --------------------------------------------------------
26 // 26 //
27 // A caller-owned call is when doing a function call with a "normal" input 27 // A caller-owned call is when doing a function call with a "normal" input
28 // argument. The caller has a reference to the var, and the caller is 28 // argument. The caller has a reference to the var, and the caller is
29 // responsible for freeing that reference. 29 // responsible for freeing that reference.
30 30
31 // Prepares the given var for sending to the remote process. If the var is a 31 // Prepares the given var for sending to the remote process. For object vars,
32 // string, *str_ptr_out will be set to point to the string in the tracker 32 // the returned var will contain the id valid for the host process.
33 // referenced by var. If the var is not a string, *str_ptr_out will be 33 // Otherwise, the returned var is valid in the local process.
34 // untouched and may be NULL. For object vars, the returned var will contain 34 virtual PP_Var SendCallerOwned(const PP_Var& var) = 0;
35 // the id valid for the host process. Otherwise, the returned var is valid in
36 // the local process.
37 virtual PP_Var SendCallerOwned(const PP_Var& var,
38 const std::string** str_ptr_out) = 0;
39 35
40 // When receiving a caller-owned variable, normally we don't have to do 36 // When receiving a caller-owned variable, normally we don't have to do
41 // anything. However, in the case of strings, we need to deserialize the 37 // anything. However, in the case of strings, we need to deserialize the
42 // string from IPC, create a new PP_Var string in the local process, call the 38 // string from IPC, call the function, and then destroy the temporary string.
43 // function, and then destroy the temporary string. These two functions 39 // These two functions handle that process.
44 // handle that process.
45 // 40 //
46 // BeginReceiveCallerOwned takes a var from IPC and an optional pointer to 41 // BeginReceiveCallerOwned takes a var from IPC and returns a new var
47 // the deserialized string (which will be used only when var is a
48 // VARTYPE_STRING and may be NULL otherwise) and returns a new var
49 // representing the input in the local process. 42 // representing the input in the local process.
50 // 43 //
51 // EndReceiveCallerOwned releases the reference count in the Var tracker for 44 // EndReceiveCallerOwned releases the reference count in the Var tracker for
52 // the object or string that was added to the tracker. (Note, if the recipient 45 // the object or string that was added to the tracker. (Note, if the recipient
53 // took a reference to the Var, it will remain in the tracker after 46 // took a reference to the Var, it will remain in the tracker after
54 // EndReceiveCallerOwned). 47 // EndReceiveCallerOwned).
55 virtual PP_Var BeginReceiveCallerOwned(const PP_Var& var, 48 virtual PP_Var BeginReceiveCallerOwned(const PP_Var& var,
56 scoped_ptr<std::string> str,
57 Dispatcher* dispatcher) = 0; 49 Dispatcher* dispatcher) = 0;
58 virtual void EndReceiveCallerOwned(const PP_Var& var) = 0; 50 virtual void EndReceiveCallerOwned(const PP_Var& var) = 0;
59 51
60 // Passing refs ------------------------------------------------------------- 52 // Passing refs -------------------------------------------------------------
61 // 53 //
62 // A pass-ref transfer is when ownership of a reference is passed from 54 // A pass-ref transfer is when ownership of a reference is passed from
63 // one side to the other. Normally, this happens via return values and 55 // one side to the other. Normally, this happens via return values and
64 // output arguments, as for exceptions. The code generating the value 56 // output arguments, as for exceptions. The code generating the value
65 // (the function returning it in the case of a return value) will AddRef 57 // (the function returning it in the case of a return value) will AddRef
66 // the var on behalf of the consumer of the value. Responsibility for 58 // the var on behalf of the consumer of the value. Responsibility for
67 // Release is on the consumer (the caller of the function in the case of a 59 // Release is on the consumer (the caller of the function in the case of a
68 // return value). 60 // return value).
69 61
70 // Creates a var in the context of the local process from the given 62 // Creates a var in the context of the local process from the given
71 // deserialized var and deserialized string (which will be used only when var 63 // deserialized var. The input var should be the result of calling
72 // is a VARTYPE_STRING and may be NULL otherwise). The input var/string 64 // SendPassRef in the remote process. The return value is the var valid in
73 // should be the result of calling SendPassRef in the remote process. The 65 // the host process for object vars. Otherwise, the return value is a var
74 // return value is the var valid in the host process for object vars. 66 // which is valid in the local process.
75 // Otherwise, the return value is a var which is valid in the local process.
76 virtual PP_Var ReceivePassRef(const PP_Var& var, 67 virtual PP_Var ReceivePassRef(const PP_Var& var,
77 scoped_ptr<std::string> str,
78 Dispatcher* dispatcher) = 0; 68 Dispatcher* dispatcher) = 0;
79 69
80 // Prepares a var to be sent to the remote side. One local reference will 70 // Prepares a var to be sent to the remote side. One local reference will
81 // be passed to the remote side. Call Begin* before doing the send and End* 71 // be passed to the remote side. Call Begin* before doing the send and End*
82 // after doing the send. See SendCallerOwned for a description of the string. 72 // after doing the send
83 // 73 //
84 // For object vars, the return value from BeginSendPassRef will be the var 74 // For object vars, the return value from BeginSendPassRef will be the var
85 // valid for the host process. Otherwise, it is a var that is valid in the 75 // valid for the host process. Otherwise, it is a var that is valid in the
86 // local process. This same var must be passed to EndSendPassRef. 76 // local process. This same var must be passed to EndSendPassRef.
87 virtual PP_Var BeginSendPassRef(const PP_Var& var, 77 virtual PP_Var BeginSendPassRef(const PP_Var& var) = 0;
88 const std::string** str_ptr_out) = 0;
89 virtual void EndSendPassRef(const PP_Var& var, Dispatcher* dispatcher) = 0; 78 virtual void EndSendPassRef(const PP_Var& var, Dispatcher* dispatcher) = 0;
90 79
91 // --------------------------------------------------------------------------- 80 // ---------------------------------------------------------------------------
92 81
93 virtual void ReleaseObjectRef(const PP_Var& var) = 0; 82 virtual void ReleaseObjectRef(const PP_Var& var) = 0;
94 83
95 protected: 84 protected:
96 VarSerializationRules() {} 85 VarSerializationRules() {}
97 }; 86 };
98 87
99 } // namespace proxy 88 } // namespace proxy
100 } // namespace ppapi 89 } // namespace ppapi
101 90
102 #endif // PPAPI_PROXY_VAR_SERIALIZATION_RULES_H_ 91 #endif // PPAPI_PROXY_VAR_SERIALIZATION_RULES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698