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

Side by Side Diff: content/child/plugin_param_traits.cc

Issue 17208003: Track NPObject ownership by the originating plugins' NPP identifier. [4/6] (Chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove DCHECKs on proxy and stub maps. Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/child/plugin_param_traits.h ('k') | content/content_plugin.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/plugin_param_traits.h" 5 #include "content/child/plugin_param_traits.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "ipc/ipc_message_utils.h" 8 #include "ipc/ipc_message_utils.h"
9 #include "third_party/WebKit/public/web/WebBindings.h" 9 #include "third_party/WebKit/public/web/WebBindings.h"
10 #include "webkit/glue/npruntime_util.h" 10 #include "webkit/glue/npruntime_util.h"
11 #include "webkit/plugins/npapi/plugin_host.h" 11 #include "webkit/plugins/npapi/plugin_host.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 NPIdentifier_Param::NPIdentifier_Param() 15 NPIdentifier_Param::NPIdentifier_Param()
16 : identifier() { 16 : identifier() {
17 } 17 }
18 18
19 NPIdentifier_Param::~NPIdentifier_Param() { 19 NPIdentifier_Param::~NPIdentifier_Param() {
20 } 20 }
21 21
22 NPVariant_Param::NPVariant_Param() 22 NPVariant_Param::NPVariant_Param()
23 : type(NPVARIANT_PARAM_VOID), 23 : type(NPVARIANT_PARAM_VOID),
24 bool_value(false), 24 bool_value(false),
25 int_value(0), 25 int_value(0),
26 double_value(0), 26 double_value(0),
27 npobject_routing_id(-1) { 27 npobject_routing_id(-1),
28 npobject_owner_id(-1) {
28 } 29 }
29 30
30 NPVariant_Param::~NPVariant_Param() { 31 NPVariant_Param::~NPVariant_Param() {
31 } 32 }
32 33
33 } // namespace content 34 } // namespace content
34 35
35 using content::NPIdentifier_Param; 36 using content::NPIdentifier_Param;
36 using content::NPVariant_Param; 37 using content::NPVariant_Param;
37 38
38 namespace IPC { 39 namespace IPC {
39 40
40 void ParamTraits<NPVariant_Param>::Write(Message* m, const param_type& p) { 41 void ParamTraits<NPVariant_Param>::Write(Message* m, const param_type& p) {
41 WriteParam(m, static_cast<int>(p.type)); 42 WriteParam(m, static_cast<int>(p.type));
42 if (p.type == content::NPVARIANT_PARAM_BOOL) { 43 if (p.type == content::NPVARIANT_PARAM_BOOL) {
43 WriteParam(m, p.bool_value); 44 WriteParam(m, p.bool_value);
44 } else if (p.type == content::NPVARIANT_PARAM_INT) { 45 } else if (p.type == content::NPVARIANT_PARAM_INT) {
45 WriteParam(m, p.int_value); 46 WriteParam(m, p.int_value);
46 } else if (p.type == content::NPVARIANT_PARAM_DOUBLE) { 47 } else if (p.type == content::NPVARIANT_PARAM_DOUBLE) {
47 WriteParam(m, p.double_value); 48 WriteParam(m, p.double_value);
48 } else if (p.type == content::NPVARIANT_PARAM_STRING) { 49 } else if (p.type == content::NPVARIANT_PARAM_STRING) {
49 WriteParam(m, p.string_value); 50 WriteParam(m, p.string_value);
50 } else if (p.type == content::NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID || 51 } else if (p.type == content::NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID ||
51 p.type == content::NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) { 52 p.type == content::NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) {
52 // This is the routing id used to connect NPObjectProxy in the other 53 // This is the routing id used to connect NPObjectProxy in the other
53 // process with NPObjectStub in this process or to identify the raw 54 // process with NPObjectStub in this process or to identify the raw
54 // npobject pointer to be used in the callee process. 55 // npobject pointer to be used in the callee process.
55 WriteParam(m, p.npobject_routing_id); 56 WriteParam(m, p.npobject_routing_id);
57 // This is a routing Id used to identify the plugin instance that owns
58 // the object, for ownership-tracking purposes.
59 WriteParam(m, p.npobject_owner_id);
56 } else { 60 } else {
57 DCHECK(p.type == content::NPVARIANT_PARAM_VOID || 61 DCHECK(p.type == content::NPVARIANT_PARAM_VOID ||
58 p.type == content::NPVARIANT_PARAM_NULL); 62 p.type == content::NPVARIANT_PARAM_NULL);
59 } 63 }
60 } 64 }
61 65
62 bool ParamTraits<NPVariant_Param>::Read(const Message* m, 66 bool ParamTraits<NPVariant_Param>::Read(const Message* m,
63 PickleIterator* iter, 67 PickleIterator* iter,
64 param_type* r) { 68 param_type* r) {
65 int type; 69 int type;
66 if (!ReadParam(m, iter, &type)) 70 if (!ReadParam(m, iter, &type))
67 return false; 71 return false;
68 72
69 bool result = false; 73 bool result = false;
70 r->type = static_cast<content::NPVariant_ParamEnum>(type); 74 r->type = static_cast<content::NPVariant_ParamEnum>(type);
71 if (r->type == content::NPVARIANT_PARAM_BOOL) { 75 if (r->type == content::NPVARIANT_PARAM_BOOL) {
72 result = ReadParam(m, iter, &r->bool_value); 76 result = ReadParam(m, iter, &r->bool_value);
73 } else if (r->type == content::NPVARIANT_PARAM_INT) { 77 } else if (r->type == content::NPVARIANT_PARAM_INT) {
74 result = ReadParam(m, iter, &r->int_value); 78 result = ReadParam(m, iter, &r->int_value);
75 } else if (r->type == content::NPVARIANT_PARAM_DOUBLE) { 79 } else if (r->type == content::NPVARIANT_PARAM_DOUBLE) {
76 result = ReadParam(m, iter, &r->double_value); 80 result = ReadParam(m, iter, &r->double_value);
77 } else if (r->type == content::NPVARIANT_PARAM_STRING) { 81 } else if (r->type == content::NPVARIANT_PARAM_STRING) {
78 result = ReadParam(m, iter, &r->string_value); 82 result = ReadParam(m, iter, &r->string_value);
79 } else if (r->type == content::NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID || 83 } else if (r->type == content::NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID ||
80 r->type == content::NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) { 84 r->type == content::NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) {
81 result = ReadParam(m, iter, &r->npobject_routing_id); 85 result = ReadParam(m, iter, &r->npobject_routing_id);
86 result = ReadParam(m, iter, &r->npobject_owner_id);
82 } else if ((r->type == content::NPVARIANT_PARAM_VOID) || 87 } else if ((r->type == content::NPVARIANT_PARAM_VOID) ||
83 (r->type == content::NPVARIANT_PARAM_NULL)) { 88 (r->type == content::NPVARIANT_PARAM_NULL)) {
84 result = true; 89 result = true;
85 } else { 90 } else {
86 NOTREACHED(); 91 NOTREACHED();
87 } 92 }
88 93
89 return result; 94 return result;
90 } 95 }
91 96
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 NPUTF8* str = WebKit::WebBindings::utf8FromIdentifier(p.identifier); 129 NPUTF8* str = WebKit::WebBindings::utf8FromIdentifier(p.identifier);
125 l->append(str); 130 l->append(str);
126 webkit::npapi::PluginHost::Singleton()->host_functions()->memfree(str); 131 webkit::npapi::PluginHost::Singleton()->host_functions()->memfree(str);
127 } else { 132 } else {
128 l->append(base::IntToString( 133 l->append(base::IntToString(
129 WebKit::WebBindings::intFromIdentifier(p.identifier))); 134 WebKit::WebBindings::intFromIdentifier(p.identifier)));
130 } 135 }
131 } 136 }
132 137
133 } // namespace IPC 138 } // namespace IPC
OLDNEW
« no previous file with comments | « content/child/plugin_param_traits.h ('k') | content/content_plugin.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698