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

Side by Side Diff: chrome/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, 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
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 // Get basic type definitions.
5 #include "chrome/common/common_param_traits.h" 6 #include "chrome/common/common_param_traits.h"
6 7
7 #include "ipc/ipc_message.h" 8 // Generate param traits write methods.
8 #include "ipc/ipc_message_utils.h" 9 #include "ipc/param_traits_write_macros.h"
10 namespace IPC {
11 #undef CHROME_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
12 #include "chrome/common/common_param_traits_macros.h"
13 } // namespace IPC
9 14
15 // Generate param traits read methods.
16 #include "ipc/param_traits_read_macros.h"
10 namespace IPC { 17 namespace IPC {
18 #undef CHROME_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
19 #include "chrome/common/common_param_traits_macros.h"
20 } // namespace IPC
11 21
12 void ParamTraits<ContentSetting>::Write(Message* m, const param_type& p) { 22 // Generate param traits log methods.
13 m->WriteInt(static_cast<int>(p)); 23 #include "ipc/param_traits_log_macros.h"
14 } 24 namespace IPC {
15 25 #undef CHROME_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
16 bool ParamTraits<ContentSetting>::Read(const Message* m, PickleIterator* iter, 26 #include "chrome/common/common_param_traits_macros.h"
17 param_type* p) {
18 int type;
19 if (!m->ReadInt(iter, &type))
20 return false;
21 *p = static_cast<param_type>(type);
22 return true;
23 }
24
25 void ParamTraits<ContentSetting>::Log(const param_type& p, std::string* l) {
26 std::string content_setting;
27 switch (p) {
28 case CONTENT_SETTING_DEFAULT:
29 content_setting = "CONTENT_SETTING_DEFAULT";
30 break;
31 case CONTENT_SETTING_ALLOW:
32 content_setting = "CONTENT_SETTING_ALLOW";
33 break;
34 case CONTENT_SETTING_BLOCK:
35 content_setting = "CONTENT_SETTING_BLOCK";
36 break;
37 case CONTENT_SETTING_ASK:
38 content_setting = "CONTENT_SETTING_ASK";
39 break;
40 case CONTENT_SETTING_SESSION_ONLY:
41 content_setting = "CONTENT_SETTING_SESSION_ONLY";
42 break;
43 default:
44 content_setting = "UNKNOWN";
45 break;
46 }
47 LogParam(content_setting, l);
48 }
49
50 void ParamTraits<ContentSettingsType>::Write(Message* m, const param_type& p) {
51 m->WriteInt(static_cast<int>(p));
52 }
53
54 bool ParamTraits<ContentSettingsType>::Read(const Message* m,
55 PickleIterator* iter,
56 param_type* p) {
57 int type;
58 if (!m->ReadInt(iter, &type))
59 return false;
60 *p = static_cast<param_type>(type);
61 return true;
62 }
63
64 void ParamTraits<ContentSettingsType>::Log(const param_type& p,
65 std::string* l) {
66 std::string setting_type;
67 switch (p) {
68 case CONTENT_SETTINGS_TYPE_DEFAULT:
69 setting_type = "CONTENT_SETTINGS_TYPE_DEFAULT";
70 break;
71 case CONTENT_SETTINGS_TYPE_COOKIES:
72 setting_type = "CONTENT_SETTINGS_TYPE_COOKIES";
73 break;
74 case CONTENT_SETTINGS_TYPE_IMAGES:
75 setting_type = "CONTENT_SETTINGS_TYPE_IMAGES";
76 break;
77 case CONTENT_SETTINGS_TYPE_JAVASCRIPT:
78 setting_type = "CONTENT_SETTINGS_TYPE_JAVASCRIPT";
79 break;
80 case CONTENT_SETTINGS_TYPE_PLUGINS:
81 setting_type = "CONTENT_SETTINGS_TYPE_PLUGINS";
82 break;
83 case CONTENT_SETTINGS_TYPE_POPUPS:
84 setting_type = "CONTENT_SETTINGS_TYPE_POPUPS";
85 break;
86 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
87 setting_type = "CONTENT_SETTINGS_TYPE_GEOLOCATION";
88 break;
89 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
90 setting_type = "CONTENT_SETTINGS_TYPE_NOTIFICATIONS";
91 break;
92 case CONTENT_SETTINGS_TYPE_INTENTS:
93 setting_type = "CONTENT_SETTINGS_TYPE_INTENTS";
94 break;
95 case CONTENT_SETTINGS_TYPE_MIXEDSCRIPT:
96 setting_type = "CONTENT_SETTINGS_TYPE_MIXEDSCRIPT";
97 break;
98 default:
99 setting_type = "UNKNOWN";
100 break;
101 }
102 LogParam(setting_type, l);
103 }
104
105 } // namespace IPC 27 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698