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

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

Issue 9655019: Fix a crash related to PPAPI scripting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 9 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/serialized_var.cc ('k') | webkit/plugins/ppapi/message_channel.h » ('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_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/ref_counted.h"
9 #include "ppapi/c/pp_var.h" 9 #include "ppapi/c/pp_var.h"
10 10
11 #include <string> 11 #include <string>
12 12
13 namespace ppapi { 13 namespace ppapi {
14 namespace proxy { 14 namespace proxy {
15 15
16 class Dispatcher;
17
18 // Encapsulates the rules for serializing and deserializing vars to and from 16 // Encapsulates the rules for serializing and deserializing vars to and from
19 // the local process. The renderer and the plugin process each have separate 17 // the local process. The renderer and the plugin process each have separate
20 // bookkeeping rules. 18 // bookkeeping rules.
21 class VarSerializationRules { 19 class VarSerializationRules : public base::RefCounted<VarSerializationRules> {
22 public: 20 public:
23 virtual ~VarSerializationRules() {} 21 virtual ~VarSerializationRules() {}
24 22
25 // Caller-owned calls -------------------------------------------------------- 23 // Caller-owned calls --------------------------------------------------------
26 // 24 //
27 // A caller-owned call is when doing a function call with a "normal" input 25 // 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 26 // argument. The caller has a reference to the var, and the caller is
29 // responsible for freeing that reference. 27 // responsible for freeing that reference.
30 28
31 // Prepares the given var for sending to the remote process. For object vars, 29 // Prepares the given var for sending to the remote process. For object vars,
32 // the returned var will contain the id valid for the host process. 30 // the returned var will contain the id valid for the host process.
33 // Otherwise, the returned var is valid in the local process. 31 // Otherwise, the returned var is valid in the local process.
34 virtual PP_Var SendCallerOwned(const PP_Var& var) = 0; 32 virtual PP_Var SendCallerOwned(const PP_Var& var) = 0;
35 33
36 // When receiving a caller-owned variable, normally we don't have to do 34 // When receiving a caller-owned variable, normally we don't have to do
37 // anything. However, in the case of strings, we need to deserialize the 35 // anything. However, in the case of strings, we need to deserialize the
38 // string from IPC, call the function, and then destroy the temporary string. 36 // string from IPC, call the function, and then destroy the temporary string.
39 // These two functions handle that process. 37 // These two functions handle that process.
40 // 38 //
41 // BeginReceiveCallerOwned takes a var from IPC and returns a new var 39 // BeginReceiveCallerOwned takes a var from IPC and returns a new var
42 // representing the input in the local process. 40 // representing the input in the local process.
43 // 41 //
44 // EndReceiveCallerOwned releases the reference count in the Var tracker for 42 // EndReceiveCallerOwned releases the reference count in the Var tracker for
45 // the object or string that was added to the tracker. (Note, if the recipient 43 // the object or string that was added to the tracker. (Note, if the recipient
46 // took a reference to the Var, it will remain in the tracker after 44 // took a reference to the Var, it will remain in the tracker after
47 // EndReceiveCallerOwned). 45 // EndReceiveCallerOwned).
48 virtual PP_Var BeginReceiveCallerOwned(const PP_Var& var, 46 virtual PP_Var BeginReceiveCallerOwned(const PP_Var& var) = 0;
49 Dispatcher* dispatcher) = 0;
50 virtual void EndReceiveCallerOwned(const PP_Var& var) = 0; 47 virtual void EndReceiveCallerOwned(const PP_Var& var) = 0;
51 48
52 // Passing refs ------------------------------------------------------------- 49 // Passing refs -------------------------------------------------------------
53 // 50 //
54 // A pass-ref transfer is when ownership of a reference is passed from 51 // A pass-ref transfer is when ownership of a reference is passed from
55 // one side to the other. Normally, this happens via return values and 52 // one side to the other. Normally, this happens via return values and
56 // output arguments, as for exceptions. The code generating the value 53 // output arguments, as for exceptions. The code generating the value
57 // (the function returning it in the case of a return value) will AddRef 54 // (the function returning it in the case of a return value) will AddRef
58 // the var on behalf of the consumer of the value. Responsibility for 55 // the var on behalf of the consumer of the value. Responsibility for
59 // Release is on the consumer (the caller of the function in the case of a 56 // Release is on the consumer (the caller of the function in the case of a
60 // return value). 57 // return value).
61 58
62 // Creates a var in the context of the local process from the given 59 // Creates a var in the context of the local process from the given
63 // deserialized var. The input var should be the result of calling 60 // deserialized var. The input var should be the result of calling
64 // SendPassRef in the remote process. The return value is the var valid in 61 // SendPassRef in the remote process. The return value is the var valid in
65 // the host process for object vars. Otherwise, the return value is a var 62 // the host process for object vars. Otherwise, the return value is a var
66 // which is valid in the local process. 63 // which is valid in the local process.
67 virtual PP_Var ReceivePassRef(const PP_Var& var, 64 virtual PP_Var ReceivePassRef(const PP_Var& var) = 0;
68 Dispatcher* dispatcher) = 0;
69 65
70 // Prepares a var to be sent to the remote side. One local reference will 66 // Prepares a var to be sent to the remote side. One local reference will
71 // be passed to the remote side. Call Begin* before doing the send and End* 67 // be passed to the remote side. Call Begin* before doing the send and End*
72 // after doing the send 68 // after doing the send
73 // 69 //
74 // For object vars, the return value from BeginSendPassRef will be the var 70 // For object vars, the return value from BeginSendPassRef will be the var
75 // valid for the host process. Otherwise, it is a var that is valid in the 71 // valid for the host process. Otherwise, it is a var that is valid in the
76 // local process. This same var must be passed to EndSendPassRef. 72 // local process. This same var must be passed to EndSendPassRef.
77 virtual PP_Var BeginSendPassRef(const PP_Var& var) = 0; 73 virtual PP_Var BeginSendPassRef(const PP_Var& var) = 0;
78 virtual void EndSendPassRef(const PP_Var& var, Dispatcher* dispatcher) = 0; 74 virtual void EndSendPassRef(const PP_Var& var) = 0;
79 75
80 // --------------------------------------------------------------------------- 76 // ---------------------------------------------------------------------------
81 77
82 virtual void ReleaseObjectRef(const PP_Var& var) = 0; 78 virtual void ReleaseObjectRef(const PP_Var& var) = 0;
83 79
84 protected: 80 protected:
85 VarSerializationRules() {} 81 VarSerializationRules() {}
86 }; 82 };
87 83
88 } // namespace proxy 84 } // namespace proxy
89 } // namespace ppapi 85 } // namespace ppapi
90 86
91 #endif // PPAPI_PROXY_VAR_SERIALIZATION_RULES_H_ 87 #endif // PPAPI_PROXY_VAR_SERIALIZATION_RULES_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/serialized_var.cc ('k') | webkit/plugins/ppapi/message_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698