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

Unified Diff: ppapi/proxy/var_serialization_rules.h

Issue 9138027: PPAPI: Reduce string copying in SerializedVar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Duh Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/serialized_var_unittest.cc ('k') | ppapi/shared_impl/var.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/var_serialization_rules.h
diff --git a/ppapi/proxy/var_serialization_rules.h b/ppapi/proxy/var_serialization_rules.h
index b77e834b7e8f2dd4b2c6bbebd090640ba56348d3..1db8eb9945ce26b90e91e7fb5d873701cd59599a 100644
--- a/ppapi/proxy/var_serialization_rules.h
+++ b/ppapi/proxy/var_serialization_rules.h
@@ -5,6 +5,7 @@
#ifndef PPAPI_PROXY_VAR_SERIALIZATION_RULES_H_
#define PPAPI_PROXY_VAR_SERIALIZATION_RULES_H_
+#include "base/memory/scoped_ptr.h"
#include "ppapi/c/pp_var.h"
#include <string>
@@ -27,27 +28,32 @@ class VarSerializationRules {
// argument. The caller has a reference to the var, and the caller is
// responsible for freeing that reference.
- // Prepares the given var for sending to the callee. If the var is a string,
- // the value of that string will be placed in *str_val. If the var is not
- // a string, str_val will be untouched and may be NULL. The return value will
- // be the var valid for the host process.
- virtual PP_Var SendCallerOwned(const PP_Var& var, std::string* str_val) = 0;
+ // Prepares the given var for sending to the remote process. If the var is a
+ // string, *str_ptr_out will be set to point to the string in the tracker
+ // referenced by var. If the var is not a string, *str_ptr_out will be
+ // untouched and may be NULL. For object vars, the returned var will contain
+ // the id valid for the host process. Otherwise, the returned var is valid in
+ // the local process.
+ virtual PP_Var SendCallerOwned(const PP_Var& var,
+ const std::string** str_ptr_out) = 0;
// When receiving a caller-owned variable, normally we don't have to do
// anything. However, in the case of strings, we need to deserialize the
// string from IPC, create a new PP_Var string in the local process, call the
// function, and then destroy the temporary string. These two functions
- // handle that process
+ // handle that process.
//
// BeginReceiveCallerOwned takes a var from IPC and an optional pointer to
// the deserialized string (which will be used only when var is a
// VARTYPE_STRING and may be NULL otherwise) and returns a new var
// representing the input in the local process.
//
- // EndReceiveCallerOwned destroys the string created by Begin* and does
- // nothing otherwise. It should be called with the result of Begin*.
+ // EndReceiveCallerOwned releases the reference count in the Var tracker for
+ // the object or string that was added to the tracker. (Note, if the recipient
+ // took a reference to the Var, it will remain in the tracker after
+ // EndReceiveCallerOwned).
virtual PP_Var BeginReceiveCallerOwned(const PP_Var& var,
- const std::string* str_val,
+ scoped_ptr<std::string> str,
Dispatcher* dispatcher) = 0;
virtual void EndReceiveCallerOwned(const PP_Var& var) = 0;
@@ -65,18 +71,21 @@ class VarSerializationRules {
// deserialized var and deserialized string (which will be used only when var
// is a VARTYPE_STRING and may be NULL otherwise). The input var/string
// should be the result of calling SendPassRef in the remote process. The
- // return value is the var valid in the plugin process.
+ // return value is the var valid in the host process for object vars.
+ // Otherwise, the return value is a var which is valid in the local process.
virtual PP_Var ReceivePassRef(const PP_Var& var,
- const std::string& str_val,
+ scoped_ptr<std::string> str,
Dispatcher* dispatcher) = 0;
// Prepares a var to be sent to the remote side. One local reference will
// be passed to the remote side. Call Begin* before doing the send and End*
// after doing the send. See SendCallerOwned for a description of the string.
//
- // The return value from BeginSendPassRef will be the var valid for the host
- // process. This same value must be passed to EndSendPassRef.
- virtual PP_Var BeginSendPassRef(const PP_Var& var, std::string* str_val) = 0;
+ // For object vars, the return value from BeginSendPassRef will be the var
+ // valid for the host process. Otherwise, it is a var that is valid in the
+ // local process. This same var must be passed to EndSendPassRef.
+ virtual PP_Var BeginSendPassRef(const PP_Var& var,
+ const std::string** str_ptr_out) = 0;
virtual void EndSendPassRef(const PP_Var& var, Dispatcher* dispatcher) = 0;
// ---------------------------------------------------------------------------
« no previous file with comments | « ppapi/proxy/serialized_var_unittest.cc ('k') | ppapi/shared_impl/var.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698