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

Unified Diff: ppapi/proxy/ppb_var_proxy.cc

Issue 6995083: Proxy PPB_Var, fix o-o-p string var id tracking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated copyright header Created 9 years, 6 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/ppb_var_proxy.h ('k') | ppapi/tests/test_var.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/ppb_var_proxy.cc
diff --git a/ppapi/proxy/ppb_var_proxy.cc b/ppapi/proxy/ppb_var_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..063d4d3437b70251989159a168e71191852f99d1
--- /dev/null
+++ b/ppapi/proxy/ppb_var_proxy.cc
@@ -0,0 +1,85 @@
+// 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.
+
+#include "ppapi/proxy/ppb_var_proxy.h"
+
+#include "ppapi/c/pp_var.h"
+#include "ppapi/c/ppb_var.h"
+#include "ppapi/proxy/plugin_var_tracker.h"
+
+namespace pp {
+namespace proxy {
+
+namespace {
+
+// PPP_Var plugin --------------------------------------------------------------
+
+void AddRefVar(PP_Var var) {
+ PluginVarTracker::GetInstance()->AddRef(var);
+}
+
+void ReleaseVar(PP_Var var) {
+ PluginVarTracker::GetInstance()->Release(var);
+}
+
+PP_Var VarFromUtf8(PP_Module module, const char* data, uint32_t len) {
+ PP_Var ret = {};
+ ret.type = PP_VARTYPE_STRING;
+ ret.value.as_id = PluginVarTracker::GetInstance()->MakeString(data, len);
+ return ret;
+}
+
+const char* VarToUtf8(PP_Var var, uint32_t* len) {
+ const std::string* str =
+ PluginVarTracker::GetInstance()->GetExistingString(var);
+ if (str) {
+ *len = static_cast<uint32_t>(str->size());
+ return str->c_str();
+ }
+ *len = 0;
+ return NULL;
+}
+
+const PPB_Var var_interface = {
+ &AddRefVar,
+ &ReleaseVar,
+ &VarFromUtf8,
+ &VarToUtf8
+};
+
+InterfaceProxy* CreateVarProxy(Dispatcher* dispatcher,
+ const void* target_interface) {
+ return new PPB_Var_Proxy(dispatcher, target_interface);
+}
+
+} // namespace
+
+PPB_Var_Proxy::PPB_Var_Proxy(Dispatcher* dispatcher,
+ const void* target_interface)
+ : InterfaceProxy(dispatcher, target_interface) {
+}
+
+PPB_Var_Proxy::~PPB_Var_Proxy() {
+}
+
+// static
+const InterfaceProxy::Info* PPB_Var_Proxy::GetInfo() {
+ static const Info info = {
+ &var_interface,
+ PPB_VAR_INTERFACE,
+ INTERFACE_ID_PPB_VAR,
+ false,
+ &CreateVarProxy,
+ };
+ return &info;
+}
+
+bool PPB_Var_Proxy::OnMessageReceived(const IPC::Message& msg) {
+ // All PPB_Var calls are handled locally; there is no need to send or receive
+ // messages here.
+ return false;
+}
+
+} // namespace proxy
+} // namespace pp
« no previous file with comments | « ppapi/proxy/ppb_var_proxy.h ('k') | ppapi/tests/test_var.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698