summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/plugin_var_tracker.h
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-08 20:22:02 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-08 20:22:02 +0000
commit0925622c1495325dfe3d3b25273f4439361936bc (patch)
treed84e13ff0c89660b3c0353095a59e296f3582ccb /ppapi/proxy/plugin_var_tracker.h
parent67b85487bf8e376297a8cc0cbf5fa3f0fa1d078b (diff)
downloadchromium_src-0925622c1495325dfe3d3b25273f4439361936bc.zip
chromium_src-0925622c1495325dfe3d3b25273f4439361936bc.tar.gz
chromium_src-0925622c1495325dfe3d3b25273f4439361936bc.tar.bz2
Proxy PPB_Var, fix o-o-p string var id tracking.
Note this doesn't need to use IPC at all, so it's a little strange. Made test for pp::Var/PPB_Var that does only strings (copied from test_var_deprecated.cc). Fixed string var tracking so test can pass out-of-process (aside from invalid UTF8 checking, which is still not implemented o-o-p). BUG=85236 TEST=test_var.cc, run tests manually out-of-process. Review URL: http://codereview.chromium.org/6995083 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88384 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/plugin_var_tracker.h')
-rw-r--r--ppapi/proxy/plugin_var_tracker.h39
1 files changed, 32 insertions, 7 deletions
diff --git a/ppapi/proxy/plugin_var_tracker.h b/ppapi/proxy/plugin_var_tracker.h
index 24f6818..1587736 100644
--- a/ppapi/proxy/plugin_var_tracker.h
+++ b/ppapi/proxy/plugin_var_tracker.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,6 +8,7 @@
#include <map>
#include <string>
+#include "base/memory/ref_counted.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_var.h"
@@ -51,10 +52,6 @@ class PluginVarTracker {
VarID MakeString(const std::string& str);
VarID MakeString(const char* str, uint32_t len);
- // Returns the string associated with the given string var. The var must be
- // of type string and must be valid or this function will crash.
- std::string GetString(const PP_Var& plugin_var) const;
-
// Returns a pointer to the given string if it exists, or NULL if the var
// isn't a string var.
const std::string* GetExistingString(const PP_Var& plugin_var) const;
@@ -93,6 +90,27 @@ class PluginVarTracker {
friend struct DefaultSingletonTraits<PluginVarTracker>;
friend class PluginProxyTest;
+ class RefCountedString : public base::RefCounted<RefCountedString> {
+ public:
+ RefCountedString() {
+ }
+ RefCountedString(const std::string& str) : value_(str) {
+ }
+ RefCountedString(const char* data, size_t len)
+ : value_(data, len) {
+ }
+
+ const std::string& value() const { return value_; }
+
+ private:
+ std::string value_;
+
+ // Ensure only base::RefCounted can delete a RefCountedString.
+ friend void base::RefCounted<RefCountedString>::Release() const;
+ virtual ~RefCountedString() {}
+ };
+ typedef scoped_refptr<RefCountedString> RefCountedStringPtr;
+
// Represents a var as received from the host.
struct HostVar {
HostVar(PluginDispatcher* d, int64_t i);
@@ -160,9 +178,16 @@ class PluginVarTracker {
typedef std::map<HostVar, VarID> HostVarToPluginVarMap;
HostVarToPluginVarMap host_var_to_plugin_var_;
- // The last plugin object ID we've handed out. This must be unique for the
+ // Maps plugin var IDs to ref counted strings.
+ typedef std::map<VarID, RefCountedStringPtr> VarIDStringMap;
+ VarIDStringMap var_id_to_string_;
+
+ // The last plugin PP_Var ID we've handed out. This must be unique for the
// process.
- VarID last_plugin_object_id_;
+ VarID last_plugin_var_id_;
+
+ // Get a new Var ID and increment last_plugin_var_id_.
+ VarID GetNewVarID();
};
} // namespace proxy