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

Side by Side Diff: content/public/common/common_param_traits.cc

Issue 10577040: Generate param traits even when shared by mutliple message files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
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/public/common/common_param_traits.h" 5 #include "content/public/common/common_param_traits.h"
6 6
7 #include "content/public/common/content_constants.h" 7 #include "content/public/common/content_constants.h"
8 #include "content/public/common/referrer.h" 8 #include "content/public/common/referrer.h"
9 #include "net/base/host_port_pair.h" 9 #include "net/base/host_port_pair.h"
10 #include "net/base/upload_data.h" 10 #include "net/base/upload_data.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return false; 63 return false;
64 } 64 }
65 *p = GURL(s); 65 *p = GURL(s);
66 return true; 66 return true;
67 } 67 }
68 68
69 void ParamTraits<GURL>::Log(const GURL& p, std::string* l) { 69 void ParamTraits<GURL>::Log(const GURL& p, std::string* l) {
70 l->append(p.spec()); 70 l->append(p.spec());
71 } 71 }
72 72
73 void ParamTraits<ResourceType::Type>::Write(Message* m, const param_type& p) {
74 m->WriteInt(p);
75 }
76
77 bool ParamTraits<ResourceType::Type>::Read(const Message* m,
78 PickleIterator* iter,
79 param_type* p) {
80 int type;
81 if (!m->ReadInt(iter, &type) || !ResourceType::ValidType(type))
82 return false;
83 *p = ResourceType::FromInt(type);
84 return true;
85 }
86
87 void ParamTraits<ResourceType::Type>::Log(const param_type& p, std::string* l) {
88 std::string type;
89 switch (p) {
90 case ResourceType::MAIN_FRAME:
91 type = "MAIN_FRAME";
92 break;
93 case ResourceType::SUB_FRAME:
94 type = "SUB_FRAME";
95 break;
96 case ResourceType::STYLESHEET:
97 type = "STYLESHEET";
98 break;
99 case ResourceType::SCRIPT:
100 type = "SCRIPT";
101 break;
102 case ResourceType::IMAGE:
103 type = "IMAGE";
104 break;
105 case ResourceType::FONT_RESOURCE:
106 type = "FONT_RESOURCE";
107 break;
108 case ResourceType::SUB_RESOURCE:
109 type = "SUB_RESOURCE";
110 break;
111 case ResourceType::OBJECT:
112 type = "OBJECT";
113 break;
114 case ResourceType::MEDIA:
115 type = "MEDIA";
116 break;
117 case ResourceType::WORKER:
118 type = "WORKER";
119 break;
120 case ResourceType::SHARED_WORKER:
121 type = "SHARED_WORKER";
122 break;
123 case ResourceType::PREFETCH:
124 type = "PREFETCH";
125 break;
126 case ResourceType::PRERENDER:
127 type = "PRERENDER";
128 break;
129 case ResourceType::FAVICON:
130 type = "FAVICON";
131 break;
132 case ResourceType::XHR:
133 type = "XHR";
134 break;
135 default:
136 type = "UNKNOWN";
137 break;
138 }
139
140 LogParam(type, l);
141 }
142
143 void ParamTraits<net::URLRequestStatus>::Write(Message* m, 73 void ParamTraits<net::URLRequestStatus>::Write(Message* m,
144 const param_type& p) { 74 const param_type& p) {
145 WriteParam(m, static_cast<int>(p.status())); 75 WriteParam(m, static_cast<int>(p.status()));
146 WriteParam(m, p.error()); 76 WriteParam(m, p.error());
147 } 77 }
148 78
149 bool ParamTraits<net::URLRequestStatus>::Read(const Message* m, 79 bool ParamTraits<net::URLRequestStatus>::Read(const Message* m,
150 PickleIterator* iter, 80 PickleIterator* iter,
151 param_type* r) { 81 param_type* r) {
152 int status, error; 82 int status, error;
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 } 476 }
547 const SkBitmap_Data* bmp_data = 477 const SkBitmap_Data* bmp_data =
548 reinterpret_cast<const SkBitmap_Data*>(fixed_data); 478 reinterpret_cast<const SkBitmap_Data*>(fixed_data);
549 return bmp_data->InitSkBitmapFromData(r, variable_data, variable_data_size); 479 return bmp_data->InitSkBitmapFromData(r, variable_data, variable_data_size);
550 } 480 }
551 481
552 void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::string* l) { 482 void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::string* l) {
553 l->append("<SkBitmap>"); 483 l->append("<SkBitmap>");
554 } 484 }
555 485
556 void ParamTraits<content::ConsoleMessageLevel>::Write(Message* m, 486 } // namespace IPC
557 const param_type& p) {
558 m->WriteInt(static_cast<int>(p));
559 }
560 487
561 bool ParamTraits<content::ConsoleMessageLevel>::Read(const Message* m, 488 // Generate param traits write methods.
562 PickleIterator* iter, 489 #include "ipc/param_traits_write_macros.h"
563 param_type* p) { 490 namespace IPC {
564 int type; 491 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
565 if (!m->ReadInt(iter, &type)) 492 #include "content/public/common/common_param_traits_macros.h"
566 return false; 493 } // namespace IPC
567 *p = static_cast<param_type>(type);
568 return true;
569 }
570 494
571 void ParamTraits<content::ConsoleMessageLevel>::Log(const param_type& p, 495 // Generate param traits read methods.
572 std::string* l) { 496 #include "ipc/param_traits_read_macros.h"
573 std::string level; 497 namespace IPC {
574 switch (p) { 498 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
575 case content::CONSOLE_MESSAGE_LEVEL_TIP: 499 #include "content/public/common/common_param_traits_macros.h"
576 level = "CONSOLE_MESSAGE_LEVEL_TIP"; 500 } // namespace IPC
577 break;
578 case content::CONSOLE_MESSAGE_LEVEL_LOG:
579 level = "CONSOLE_MESSAGE_LEVEL_LOG";
580 break;
581 case content::CONSOLE_MESSAGE_LEVEL_WARNING:
582 level = "CONSOLE_MESSAGE_LEVEL_WARNING";
583 break;
584 case content::CONSOLE_MESSAGE_LEVEL_ERROR:
585 level = "CONSOLE_MESSAGE_LEVEL_ERROR";
586 break;
587 }
588 LogParam(level, l);
589 }
590 501
502 // Generate param traits log methods.
503 #include "ipc/param_traits_log_macros.h"
504 namespace IPC {
505 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
506 #include "content/public/common/common_param_traits_macros.h"
591 } // namespace IPC 507 } // namespace IPC
OLDNEW
« no previous file with comments | « content/public/common/common_param_traits.h ('k') | content/public/common/common_param_traits_macros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698