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

Side by Side Diff: chrome/tools/ipclist/ipclist.cc

Issue 6646005: Creates the ipclist utility that chrome security team has wanted to dump... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 | « chrome/tools/ipclist/all_messages.h ('k') | content/common/resource_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 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.
4
5 #include <algorithm>
6 #include <iostream>
7 #include <string>
8 #include <vector>
9
10 // Include once to get the type definitions
11 #include "chrome/tools/ipclist/all_messages.h"
12
13 struct msginfo {
14 const char* name;
15 int id;
16 int in_count;
17 int out_count;
18
19 bool operator< (const msginfo other) const {
20 return id < other.id;
21 }
22 };
23
24 // Redefine macros to generate table
25 #include "ipc/ipc_message_null_macros.h"
26 #undef IPC_MESSAGE_DECL
27 #define IPC_MESSAGE_DECL(kind, type, name, in, out, ilist, olist) \
28 { #name, IPC_MESSAGE_ID(), in, out },
29
30 static msginfo msgtable[] = {
31 #include "chrome/tools/ipclist/all_messages.h"
32 };
33 #define MSGTABLE_SIZE (sizeof(msgtable)/sizeof(msgtable[0]))
34
35 static bool check_msgtable() {
36 bool result = true;
37 int previous_class_id = 0;
38 int highest_class_id = 0;
39 std::vector<int> exemptions;
40
41 // Exclude test files from consideration. Do not include message
42 // files used inside the actual chrome browser in this list.
43 exemptions.push_back(TestMsgStart);
44 exemptions.push_back(FirefoxImporterUnittestMsgStart);
45
46 for (size_t i = 0; i < MSGTABLE_SIZE; ++i) {
47 int class_id = IPC_MESSAGE_ID_CLASS(msgtable[i].id);
48 if (class_id >= LastIPCMsgStart) {
49 std::cout << "Invalid LastIPCMsgStart setting\n";
50 result = false;
51 }
52 while (class_id > previous_class_id + 1) {
53 std::vector<int>::iterator iter;
54 iter = find(exemptions.begin(), exemptions.end(), previous_class_id+1);
55 if (iter == exemptions.end()) {
56 std::cout << "Missing message file: gap before " << class_id << "\n";
57 result = false;
58 break;
59 }
60 ++previous_class_id;
61 }
62 previous_class_id = class_id;
63 if (class_id > highest_class_id)
64 highest_class_id = class_id;
65 }
66
67 if (LastIPCMsgStart > highest_class_id + 1) {
68 std::cout << "Missing message file: gap before LastIPCMsgStart\n";
69 result = false;
70 }
71
72 if (!result)
73 std::cout << "Please check chrome/tools/ipclist/all_messages.h.\n";
74
75 return result;
76 }
77
78 static void dump_msgtable(bool show_args, bool show_ids) {
79 for (size_t i = 0; i < MSGTABLE_SIZE; ++i) {
80 if (show_ids) {
81 std::cout << "{" << IPC_MESSAGE_ID_CLASS(msgtable[i].id) << ", " <<
82 IPC_MESSAGE_ID_LINE(msgtable[i].id) << "}: ";
83 }
84 std::cout << msgtable[i].name;
85 if (show_args) {
86 std::cout << "(" << msgtable[i].in_count << " IN, " <<
87 msgtable[i].out_count << " OUT)";
88 }
89 std::cout << "\n";
90 }
91 }
92
93 int main(int argc, char **argv) {
94 bool show_args = false;
95 bool show_ids = false;
96 bool skip_check = false;
97
98 while (--argc > 0) {
99 ++argv;
100 if (std::string("--args") == *argv) {
101 show_args = true;
102 } else if (std::string("--ids") == *argv) {
103 show_ids = true;
104 } else if (std::string("--no-check") == *argv) {
105 skip_check = true;
106 } else {
107 std::cout << "usage: ipclist [--args] [--ids] [--no-check]\n";
108 return 1;
109 }
110 }
111
112 std::sort(msgtable, msgtable + MSGTABLE_SIZE);
113
114 if (!skip_check && check_msgtable() == false)
115 return 1;
116
117 dump_msgtable(show_args, show_ids);
118 return 0;
119 }
120
OLDNEW
« no previous file with comments | « chrome/tools/ipclist/all_messages.h ('k') | content/common/resource_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698