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

Side by Side Diff: content/common/content_param_traits.cc

Issue 11235068: Move the remaning files in content\common to the content namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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/common/content_param_traits.h ('k') | content/common/debug_flags.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/common/content_param_traits.h" 5 #include "content/common/content_param_traits.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "net/base/ip_endpoint.h" 8 #include "net/base/ip_endpoint.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/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 #include "ui/base/range/range.h" 12 #include "ui/base/range/range.h"
13 13
14 namespace content {
15
14 NPIdentifier_Param::NPIdentifier_Param() 16 NPIdentifier_Param::NPIdentifier_Param()
15 : identifier() { 17 : identifier() {
16 } 18 }
17 19
18 NPIdentifier_Param::~NPIdentifier_Param() { 20 NPIdentifier_Param::~NPIdentifier_Param() {
19 } 21 }
20 22
21 NPVariant_Param::NPVariant_Param() 23 NPVariant_Param::NPVariant_Param()
22 : type(NPVARIANT_PARAM_VOID), 24 : type(NPVARIANT_PARAM_VOID),
23 bool_value(false), 25 bool_value(false),
24 int_value(0), 26 int_value(0),
25 double_value(0), 27 double_value(0),
26 npobject_routing_id(-1) { 28 npobject_routing_id(-1) {
27 } 29 }
28 30
29 NPVariant_Param::~NPVariant_Param() { 31 NPVariant_Param::~NPVariant_Param() {
30 } 32 }
31 33
34 } // namespace content
35
36 using content::NPIdentifier_Param;
37 using content::NPVariant_Param;
38
32 namespace IPC { 39 namespace IPC {
33 40
34 void ParamTraits<net::IPEndPoint>::Write(Message* m, const param_type& p) { 41 void ParamTraits<net::IPEndPoint>::Write(Message* m, const param_type& p) {
35 WriteParam(m, p.address()); 42 WriteParam(m, p.address());
36 WriteParam(m, p.port()); 43 WriteParam(m, p.port());
37 } 44 }
38 45
39 bool ParamTraits<net::IPEndPoint>::Read(const Message* m, PickleIterator* iter, 46 bool ParamTraits<net::IPEndPoint>::Read(const Message* m, PickleIterator* iter,
40 param_type* p) { 47 param_type* p) {
41 net::IPAddressNumber address; 48 net::IPAddressNumber address;
42 int port; 49 int port;
43 if (!ReadParam(m, iter, &address) || !ReadParam(m, iter, &port)) 50 if (!ReadParam(m, iter, &address) || !ReadParam(m, iter, &port))
44 return false; 51 return false;
45 *p = net::IPEndPoint(address, port); 52 *p = net::IPEndPoint(address, port);
46 return true; 53 return true;
47 } 54 }
48 55
49 void ParamTraits<net::IPEndPoint>::Log(const param_type& p, std::string* l) { 56 void ParamTraits<net::IPEndPoint>::Log(const param_type& p, std::string* l) {
50 LogParam("IPEndPoint:" + p.ToString(), l); 57 LogParam("IPEndPoint:" + p.ToString(), l);
51 } 58 }
52 59
53 void ParamTraits<NPVariant_Param>::Write(Message* m, const param_type& p) { 60 void ParamTraits<NPVariant_Param>::Write(Message* m, const param_type& p) {
54 WriteParam(m, static_cast<int>(p.type)); 61 WriteParam(m, static_cast<int>(p.type));
55 if (p.type == NPVARIANT_PARAM_BOOL) { 62 if (p.type == content::NPVARIANT_PARAM_BOOL) {
56 WriteParam(m, p.bool_value); 63 WriteParam(m, p.bool_value);
57 } else if (p.type == NPVARIANT_PARAM_INT) { 64 } else if (p.type == content::NPVARIANT_PARAM_INT) {
58 WriteParam(m, p.int_value); 65 WriteParam(m, p.int_value);
59 } else if (p.type == NPVARIANT_PARAM_DOUBLE) { 66 } else if (p.type == content::NPVARIANT_PARAM_DOUBLE) {
60 WriteParam(m, p.double_value); 67 WriteParam(m, p.double_value);
61 } else if (p.type == NPVARIANT_PARAM_STRING) { 68 } else if (p.type == content::NPVARIANT_PARAM_STRING) {
62 WriteParam(m, p.string_value); 69 WriteParam(m, p.string_value);
63 } else if (p.type == NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID || 70 } else if (p.type == content::NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID ||
64 p.type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) { 71 p.type == content::NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) {
65 // This is the routing id used to connect NPObjectProxy in the other 72 // This is the routing id used to connect NPObjectProxy in the other
66 // process with NPObjectStub in this process or to identify the raw 73 // process with NPObjectStub in this process or to identify the raw
67 // npobject pointer to be used in the callee process. 74 // npobject pointer to be used in the callee process.
68 WriteParam(m, p.npobject_routing_id); 75 WriteParam(m, p.npobject_routing_id);
69 } else { 76 } else {
70 DCHECK(p.type == NPVARIANT_PARAM_VOID || p.type == NPVARIANT_PARAM_NULL); 77 DCHECK(p.type == content::NPVARIANT_PARAM_VOID ||
78 p.type == content::NPVARIANT_PARAM_NULL);
71 } 79 }
72 } 80 }
73 81
74 bool ParamTraits<NPVariant_Param>::Read(const Message* m, 82 bool ParamTraits<NPVariant_Param>::Read(const Message* m,
75 PickleIterator* iter, 83 PickleIterator* iter,
76 param_type* r) { 84 param_type* r) {
77 int type; 85 int type;
78 if (!ReadParam(m, iter, &type)) 86 if (!ReadParam(m, iter, &type))
79 return false; 87 return false;
80 88
81 bool result = false; 89 bool result = false;
82 r->type = static_cast<NPVariant_ParamEnum>(type); 90 r->type = static_cast<content::NPVariant_ParamEnum>(type);
83 if (r->type == NPVARIANT_PARAM_BOOL) { 91 if (r->type == content::NPVARIANT_PARAM_BOOL) {
84 result = ReadParam(m, iter, &r->bool_value); 92 result = ReadParam(m, iter, &r->bool_value);
85 } else if (r->type == NPVARIANT_PARAM_INT) { 93 } else if (r->type == content::NPVARIANT_PARAM_INT) {
86 result = ReadParam(m, iter, &r->int_value); 94 result = ReadParam(m, iter, &r->int_value);
87 } else if (r->type == NPVARIANT_PARAM_DOUBLE) { 95 } else if (r->type == content::NPVARIANT_PARAM_DOUBLE) {
88 result = ReadParam(m, iter, &r->double_value); 96 result = ReadParam(m, iter, &r->double_value);
89 } else if (r->type == NPVARIANT_PARAM_STRING) { 97 } else if (r->type == content::NPVARIANT_PARAM_STRING) {
90 result = ReadParam(m, iter, &r->string_value); 98 result = ReadParam(m, iter, &r->string_value);
91 } else if (r->type == NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID || 99 } else if (r->type == content::NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID ||
92 r->type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) { 100 r->type == content::NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) {
93 result = ReadParam(m, iter, &r->npobject_routing_id); 101 result = ReadParam(m, iter, &r->npobject_routing_id);
94 } else if ((r->type == NPVARIANT_PARAM_VOID) || 102 } else if ((r->type == content::NPVARIANT_PARAM_VOID) ||
95 (r->type == NPVARIANT_PARAM_NULL)) { 103 (r->type == content::NPVARIANT_PARAM_NULL)) {
96 result = true; 104 result = true;
97 } else { 105 } else {
98 NOTREACHED(); 106 NOTREACHED();
99 } 107 }
100 108
101 return result; 109 return result;
102 } 110 }
103 111
104 void ParamTraits<NPVariant_Param>::Log(const param_type& p, std::string* l) { 112 void ParamTraits<NPVariant_Param>::Log(const param_type& p, std::string* l) {
105 l->append(StringPrintf("NPVariant_Param(%d, ", static_cast<int>(p.type))); 113 l->append(StringPrintf("NPVariant_Param(%d, ", static_cast<int>(p.type)));
106 if (p.type == NPVARIANT_PARAM_BOOL) { 114 if (p.type == content::NPVARIANT_PARAM_BOOL) {
107 LogParam(p.bool_value, l); 115 LogParam(p.bool_value, l);
108 } else if (p.type == NPVARIANT_PARAM_INT) { 116 } else if (p.type == content::NPVARIANT_PARAM_INT) {
109 LogParam(p.int_value, l); 117 LogParam(p.int_value, l);
110 } else if (p.type == NPVARIANT_PARAM_DOUBLE) { 118 } else if (p.type == content::NPVARIANT_PARAM_DOUBLE) {
111 LogParam(p.double_value, l); 119 LogParam(p.double_value, l);
112 } else if (p.type == NPVARIANT_PARAM_STRING) { 120 } else if (p.type == content::NPVARIANT_PARAM_STRING) {
113 LogParam(p.string_value, l); 121 LogParam(p.string_value, l);
114 } else if (p.type == NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID || 122 } else if (p.type == content::NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID ||
115 p.type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) { 123 p.type == content::NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID) {
116 LogParam(p.npobject_routing_id, l); 124 LogParam(p.npobject_routing_id, l);
117 } else { 125 } else {
118 l->append("<none>"); 126 l->append("<none>");
119 } 127 }
120 l->append(")"); 128 l->append(")");
121 } 129 }
122 130
123 void ParamTraits<NPIdentifier_Param>::Write(Message* m, const param_type& p) { 131 void ParamTraits<NPIdentifier_Param>::Write(Message* m, const param_type& p) {
124 webkit_glue::SerializeNPIdentifier(p.identifier, m); 132 webkit_glue::SerializeNPIdentifier(p.identifier, m);
125 } 133 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ 184 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_
177 #include "content/common/content_param_traits_macros.h" 185 #include "content/common/content_param_traits_macros.h"
178 } // namespace IPC 186 } // namespace IPC
179 187
180 // Generate param traits log methods. 188 // Generate param traits log methods.
181 #include "ipc/param_traits_log_macros.h" 189 #include "ipc/param_traits_log_macros.h"
182 namespace IPC { 190 namespace IPC {
183 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_ 191 #undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_
184 #include "content/common/content_param_traits_macros.h" 192 #include "content/common/content_param_traits_macros.h"
185 } // namespace IPC 193 } // namespace IPC
OLDNEW
« no previous file with comments | « content/common/content_param_traits.h ('k') | content/common/debug_flags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698