diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-04 16:44:37 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-04 16:44:37 +0000 |
commit | d8f868a635906d720e5a717e5a81f36df211b719 (patch) | |
tree | 651dcc089710d43e0bc217112a57f85877a7f3be /ppapi/shared_impl/var.h | |
parent | 6b85493985ec994cd82977ea088bb7a3de955a66 (diff) | |
download | chromium_src-d8f868a635906d720e5a717e5a81f36df211b719.zip chromium_src-d8f868a635906d720e5a717e5a81f36df211b719.tar.gz chromium_src-d8f868a635906d720e5a717e5a81f36df211b719.tar.bz2 |
PPAPI: Reduce string copying in SerializedVar.
My performance test shows somewhere from 6-12% improvement. That's not bad, considering the test uses IPC, which outweighs most other work the proxy does.
I wanted to do this before proxying ArrayBuffer. I might try to do a little further refactoring in another CL.
BUG=
TEST=
Review URL: http://codereview.chromium.org/9138027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl/var.h')
-rw-r--r-- | ppapi/shared_impl/var.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/ppapi/shared_impl/var.h b/ppapi/shared_impl/var.h index 4d833ae..ed7f4f1 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. |