| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <iostream> | 6 #include <iostream> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 // Include once to get the type definitions | 10 // Include once to get the type definitions |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "chrome/common/all_messages.h" | 31 #include "chrome/common/all_messages.h" |
| 32 }; | 32 }; |
| 33 #define MSGTABLE_SIZE (sizeof(msgtable)/sizeof(msgtable[0])) | 33 #define MSGTABLE_SIZE (sizeof(msgtable)/sizeof(msgtable[0])) |
| 34 | 34 |
| 35 static bool check_msgtable() { | 35 static bool check_msgtable() { |
| 36 bool result = true; | 36 bool result = true; |
| 37 int previous_class_id = 0; | 37 int previous_class_id = 0; |
| 38 int highest_class_id = 0; | 38 int highest_class_id = 0; |
| 39 std::vector<int> exemptions; | 39 std::vector<int> exemptions; |
| 40 | 40 |
| 41 // Exclude test files from consideration. Do not include message | 41 // Exclude test and other non-browser files from consideration. Do not |
| 42 // files used inside the actual chrome browser in this list. | 42 // include message files used inside the actual chrome browser in this list. |
| 43 exemptions.push_back(TestMsgStart); | 43 exemptions.push_back(TestMsgStart); |
| 44 exemptions.push_back(FirefoxImporterUnittestMsgStart); | 44 exemptions.push_back(FirefoxImporterUnittestMsgStart); |
| 45 exemptions.push_back(ShellMsgStart); |
| 45 | 46 |
| 46 for (size_t i = 0; i < MSGTABLE_SIZE; ++i) { | 47 for (size_t i = 0; i < MSGTABLE_SIZE; ++i) { |
| 47 int class_id = IPC_MESSAGE_ID_CLASS(msgtable[i].id); | 48 int class_id = IPC_MESSAGE_ID_CLASS(msgtable[i].id); |
| 48 if (class_id >= LastIPCMsgStart) { | 49 if (class_id >= LastIPCMsgStart) { |
| 49 std::cout << "Invalid LastIPCMsgStart setting\n"; | 50 std::cout << "Invalid LastIPCMsgStart setting\n"; |
| 50 result = false; | 51 result = false; |
| 51 } | 52 } |
| 52 while (class_id > previous_class_id + 1) { | 53 while (class_id > previous_class_id + 1) { |
| 53 std::vector<int>::iterator iter; | 54 std::vector<int>::iterator iter; |
| 54 iter = find(exemptions.begin(), exemptions.end(), previous_class_id+1); | 55 iter = find(exemptions.begin(), exemptions.end(), previous_class_id+1); |
| 55 if (iter == exemptions.end()) { | 56 if (iter == exemptions.end()) { |
| 56 std::cout << "Missing message file: gap before " << class_id << "\n"; | 57 std::cout << "Missing message file: gap before " << class_id << "\n"; |
| 57 result = false; | 58 result = false; |
| 58 break; | 59 break; |
| 59 } | 60 } |
| 60 ++previous_class_id; | 61 ++previous_class_id; |
| 61 } | 62 } |
| 62 previous_class_id = class_id; | 63 previous_class_id = class_id; |
| 63 if (class_id > highest_class_id) | 64 if (class_id > highest_class_id) |
| 64 highest_class_id = class_id; | 65 highest_class_id = class_id; |
| 65 } | 66 } |
| 66 | 67 |
| 67 if (LastIPCMsgStart > highest_class_id + 1) { | 68 while (LastIPCMsgStart > highest_class_id + 1) { |
| 69 std::vector<int>::iterator iter; |
| 70 iter = find(exemptions.begin(), exemptions.end(), highest_class_id+1); |
| 71 if (iter == exemptions.end()) { |
| 68 std::cout << "Missing message file: gap before LastIPCMsgStart\n"; | 72 std::cout << "Missing message file: gap before LastIPCMsgStart\n"; |
| 69 result = false; | 73 result = false; |
| 74 break; |
| 75 } |
| 76 ++highest_class_id; |
| 70 } | 77 } |
| 71 | 78 |
| 72 if (!result) | 79 if (!result) |
| 73 std::cout << "Please check chrome/common/all_messages.h.\n"; | 80 std::cout << "Please check chrome/common/all_messages.h.\n"; |
| 74 | 81 |
| 75 return result; | 82 return result; |
| 76 } | 83 } |
| 77 | 84 |
| 78 static void dump_msgtable(bool show_args, bool show_ids, | 85 static void dump_msgtable(bool show_args, bool show_ids, |
| 79 bool show_comma, const char *prefix) { | 86 bool show_comma, const char *prefix) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 140 |
| 134 std::sort(msgtable, msgtable + MSGTABLE_SIZE); | 141 std::sort(msgtable, msgtable + MSGTABLE_SIZE); |
| 135 | 142 |
| 136 if (!skip_check && check_msgtable() == false) | 143 if (!skip_check && check_msgtable() == false) |
| 137 return 1; | 144 return 1; |
| 138 | 145 |
| 139 dump_msgtable(show_args, show_ids, show_comma, filter); | 146 dump_msgtable(show_args, show_ids, show_comma, filter); |
| 140 return 0; | 147 return 0; |
| 141 } | 148 } |
| 142 | 149 |
| OLD | NEW |