SetNeedsRedraw directly when updating a visible tile.
[chromium-blink-merge.git] / tools / ipc_fuzzer / ipclist / ipclist.cc
blobf1d005029e567c606336a0a3b283edb3690c0574
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <algorithm>
6 #include <iostream>
7 #include <string>
8 #include <vector>
10 #include "base/basictypes.h"
12 // Include once to get the type definitions
13 #include "tools/ipc_fuzzer/message_lib/all_messages.h"
15 struct msginfo {
16 const char* name;
17 const char* file;
18 int id;
19 int in_count;
20 int out_count;
22 bool operator< (const msginfo& other) const {
23 return id < other.id;
27 // Redefine macros to generate table
28 #include "ipc/ipc_message_null_macros.h"
29 #undef IPC_MESSAGE_DECL
30 #define IPC_MESSAGE_DECL(kind, type, name, in, out, ilist, olist) \
31 { #name, __FILE__, IPC_MESSAGE_ID(), in, out },
33 static msginfo msgtable[] = {
34 #include "tools/ipc_fuzzer/message_lib/all_messages.h"
36 #define MSGTABLE_SIZE (sizeof(msgtable)/sizeof(msgtable[0]))
37 COMPILE_ASSERT(MSGTABLE_SIZE, CHECK_YOUR_HEADERS_FOR_AN_EXTRA_SEMICOLON);
39 static bool check_msgtable() {
40 bool result = true;
41 int previous_class_id = 0;
42 int highest_class_id = 0;
43 const char* file_name = "NONE";
44 const char* previous_file_name = "NONE";
45 std::vector<int> exemptions;
47 // Exclude test and other non-browser files from consideration. Do not
48 // include message files used inside the actual chrome browser in this list.
49 exemptions.push_back(TestMsgStart);
50 exemptions.push_back(FirefoxImporterUnittestMsgStart);
51 exemptions.push_back(ShellMsgStart);
52 exemptions.push_back(LayoutTestMsgStart);
53 exemptions.push_back(MetroViewerMsgStart);
54 exemptions.push_back(CCMsgStart); // Nothing but param traits.
55 exemptions.push_back(CldDataProviderMsgStart); // Conditional build.
56 #if !defined(OS_ANDROID)
57 exemptions.push_back(JavaBridgeMsgStart);
58 exemptions.push_back(MediaPlayerMsgStart);
59 exemptions.push_back(EncryptedMediaMsgStart);
60 exemptions.push_back(GinJavaBridgeMsgStart);
61 exemptions.push_back(AndroidWebViewMsgStart);
62 #endif // !defined(OS_ANDROID)
63 #if !defined(USE_OZONE)
64 exemptions.push_back(OzoneGpuMsgStart);
65 #endif // !defined(USE_OZONE)
67 for (size_t i = 0; i < MSGTABLE_SIZE; ++i) {
68 int class_id = IPC_MESSAGE_ID_CLASS(msgtable[i].id);
69 file_name = msgtable[i].file;
70 if (class_id >= LastIPCMsgStart) {
71 std::cout << "Invalid LastIPCMsgStart setting\n";
72 result = false;
74 if (class_id == previous_class_id &&
75 strcmp(file_name, previous_file_name) != 0) {
76 std::cerr << "enum used in multiple files: "
77 << file_name << " vs "
78 << previous_file_name << "\n";
79 result = false;
81 while (class_id > previous_class_id + 1) {
82 std::vector<int>::iterator iter;
83 iter = find(exemptions.begin(), exemptions.end(), previous_class_id + 1);
84 if (iter == exemptions.end()) {
85 std::cout << "Missing message file for enum "
86 << class_id - (previous_class_id + 1)
87 << " before enum used by " << file_name << "\n";
88 result = false;
90 ++previous_class_id;
92 previous_class_id = class_id;
93 previous_file_name = file_name;
94 if (class_id > highest_class_id)
95 highest_class_id = class_id;
98 while (LastIPCMsgStart > highest_class_id + 1) {
99 std::vector<int>::iterator iter;
100 iter = find(exemptions.begin(), exemptions.end(), highest_class_id+1);
101 if (iter == exemptions.end()) {
102 std::cout << "Missing message file for enum "
103 << LastIPCMsgStart - (highest_class_id + 1)
104 << " before enum LastIPCMsgStart\n";
105 break;
107 ++highest_class_id;
110 if (!result)
111 std::cout << "Please check tools/ipc_fuzzer/message_lib/all_messages.h\n";
113 return result;
116 static void dump_msgtable(bool show_args, bool show_ids,
117 bool show_comma, const char *prefix) {
118 bool first = true;
119 for (size_t i = 0; i < MSGTABLE_SIZE; ++i) {
120 if ((!prefix) || strstr(msgtable[i].name, prefix) == msgtable[i].name) {
121 if (show_comma) {
122 if (!first)
123 std::cout << ",";
124 first = false;
125 std::cout << msgtable[i].id;
126 } else {
127 if (show_ids)
128 std::cout << msgtable[i].id << " " <<
129 IPC_MESSAGE_ID_CLASS(msgtable[i].id) << "," <<
130 IPC_MESSAGE_ID_LINE(msgtable[i].id) << " ";
131 std::cout << msgtable[i].name;
132 if (show_args) {
133 std::cout << "(" << msgtable[i].in_count << " IN, " <<
134 msgtable[i].out_count << " OUT)";
136 std::cout << "\n";
140 if (show_comma)
141 std::cout << "\n";
144 int main(int argc, char **argv) {
145 bool show_args = false;
146 bool show_ids = false;
147 bool skip_check = false;
148 bool show_comma = false;
149 const char *filter = NULL;
151 while (--argc > 0) {
152 ++argv;
153 if (std::string("--args") == *argv) {
154 show_args = true;
155 } else if (std::string("--comma") == *argv) {
156 show_comma = true;
157 } else if (std::string("--filter") == *argv) {
158 filter = *(++argv);
159 --argc;
160 } else if (std::string("--ids") == *argv) {
161 show_ids = true;
162 } else if (std::string("--no-check") == *argv) {
163 skip_check = true;
164 } else {
165 std::cout <<
166 "usage: ipclist [--args] [--ids] [--no-check] [--filter prefix] "
167 "[--comma]\n";
168 return 1;
172 std::sort(msgtable, msgtable + MSGTABLE_SIZE);
174 if (!skip_check && check_msgtable() == false)
175 return 1;
177 dump_msgtable(show_args, show_ids, show_comma, filter);
178 return 0;