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

Unified Diff: ppapi/shared_impl/var.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/var_serialization_rules.h ('k') | ppapi/shared_impl/var.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/var.h
diff --git a/ppapi/shared_impl/var.h b/ppapi/shared_impl/var.h
index 4d833ae12b247bc57beee738949eebab958d6547..ed7f4f135bbfcd04322e036840dbedcf2bbfa19d 100644
--- a/ppapi/shared_impl/var.h
+++ b/ppapi/shared_impl/var.h
@@ -9,6 +9,7 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "ppapi/c/pp_var.h"
#include "ppapi/shared_impl/ppapi_shared_export.h"
@@ -93,9 +94,16 @@ class PPAPI_SHARED_EXPORT StringVar : public Var {
public:
StringVar(const std::string& str);
StringVar(const char* str, uint32 len);
+ StringVar(scoped_ptr<std::string> str);
virtual ~StringVar();
const std::string& value() const { return value_; }
+ // Return a pointer to the internal string. This allows other objects to
+ // temporarily store a weak pointer to our internal string. Use with care; the
+ // pointer *will* become invalid if this StringVar is removed from the
+ // tracker. (All of this applies to value(), but this one's even easier to use
+ // dangerously).
+ const std::string* ptr() const { return &value_; }
// Var override.
virtual StringVar* AsStringVar() OVERRIDE;
@@ -109,6 +117,7 @@ class PPAPI_SHARED_EXPORT StringVar : public Var {
// create a StringVar and return the reference to it in the var.
static PP_Var StringToPPVar(const std::string& str);
static PP_Var StringToPPVar(const char* str, uint32 len);
+ static PP_Var StringToPPVar(scoped_ptr<std::string> str);
// Helper function that converts a PP_Var to a string. This will return NULL
// if the PP_Var is not of string type or the string is invalid.
« no previous file with comments | « ppapi/proxy/var_serialization_rules.h ('k') | ppapi/shared_impl/var.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698