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

Unified Diff: ppapi/proxy/plugin_var_serialization_rules.cc

Issue 6282007: First pass at making the proxy handle multiple renderers. This associates the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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/plugin_var_serialization_rules.h ('k') | ppapi/proxy/plugin_var_tracker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/plugin_var_serialization_rules.cc
===================================================================
--- ppapi/proxy/plugin_var_serialization_rules.cc (revision 71973)
+++ ppapi/proxy/plugin_var_serialization_rules.cc (working copy)
@@ -1,33 +1,39 @@
-// 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.
#include "ppapi/proxy/plugin_var_serialization_rules.h"
+#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/plugin_var_tracker.h"
namespace pp {
namespace proxy {
-PluginVarSerializationRules::PluginVarSerializationRules(
- PluginVarTracker* var_tracker)
- : var_tracker_(var_tracker) {
+PluginVarSerializationRules::PluginVarSerializationRules()
+ : var_tracker_(PluginVarTracker::GetInstance()) {
}
PluginVarSerializationRules::~PluginVarSerializationRules() {
}
-void PluginVarSerializationRules::SendCallerOwned(const PP_Var& var,
- std::string* str_val) {
+PP_Var PluginVarSerializationRules::SendCallerOwned(const PP_Var& var,
+ std::string* str_val) {
+ // Objects need special translations to get the IDs valid in the host.
+ if (var.type == PP_VARTYPE_OBJECT)
+ return var_tracker_->GetHostObject(var);
+
// Nothing to do since we manage the refcount, other than retrieve the string
// to use for IPC.
if (var.type == PP_VARTYPE_STRING)
*str_val = var_tracker_->GetString(var);
+ return var;
}
PP_Var PluginVarSerializationRules::BeginReceiveCallerOwned(
const PP_Var& var,
- const std::string* str_val) {
+ const std::string* str_val,
+ Dispatcher* dispatcher) {
if (var.type == PP_VARTYPE_STRING) {
// Convert the string to the context of the current process.
PP_Var ret;
@@ -36,6 +42,9 @@
return ret;
}
+ if (var.type == PP_VARTYPE_OBJECT)
+ return var_tracker_->TrackObjectWithNoReference(var, dispatcher);
+
return var;
}
@@ -43,11 +52,14 @@
if (var.type == PP_VARTYPE_STRING) {
// Destroy the string BeginReceiveCallerOwned created above.
var_tracker_->Release(var);
+ } else if (var.type == PP_VARTYPE_OBJECT) {
+ var_tracker_->StopTrackingObjectWithNoReference(var);
}
}
PP_Var PluginVarSerializationRules::ReceivePassRef(const PP_Var& var,
- const std::string& str_val) {
+ const std::string& str_val,
+ Dispatcher* dispatcher) {
if (var.type == PP_VARTYPE_STRING) {
// Convert the string to the context of the current process.
PP_Var ret;
@@ -72,13 +84,16 @@
// on behalf of the caller. This needs to be transferred to the plugin and
// folded in to its set of refs it maintains (with one ref representing all
// fo them in the browser).
- if (var.type == PP_VARTYPE_OBJECT)
- var_tracker_->ReceiveObjectPassRef(var);
+ if (var.type == PP_VARTYPE_OBJECT) {
+ return var_tracker_->ReceiveObjectPassRef(var, dispatcher);
+ }
+
+ // Other types are unchanged.
return var;
}
-void PluginVarSerializationRules::BeginSendPassRef(const PP_Var& var,
- std::string* str_val) {
+PP_Var PluginVarSerializationRules::BeginSendPassRef(const PP_Var& var,
+ std::string* str_val) {
// Overview of sending an object with "pass ref" from the plugin to the
// browser:
// Example 1 Example 2
@@ -94,8 +109,13 @@
// transferring the object ref to the browser involves no net change in the
// browser's refcount.
+ // Objects need special translations to get the IDs valid in the host.
+ if (var.type == PP_VARTYPE_OBJECT)
+ return var_tracker_->GetHostObject(var);
+
if (var.type == PP_VARTYPE_STRING)
*str_val = var_tracker_->GetString(var);
+ return var;
}
void PluginVarSerializationRules::EndSendPassRef(const PP_Var& var) {
« no previous file with comments | « ppapi/proxy/plugin_var_serialization_rules.h ('k') | ppapi/proxy/plugin_var_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698