OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
3 * Use of this source code is governed by a BSD-style license that can be | |
4 * found in the LICENSE file. | |
5 */ | |
6 | |
7 /* | |
8 * Error codes and data structures used to report errors when loading a nexe. | |
9 */ | |
10 | |
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_ERROR_H | |
12 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_ERROR_H | |
13 | |
14 #include <string> | |
15 | |
16 namespace plugin { | |
17 | |
18 // These error codes are reported via UMA so, if you edit them: | |
19 // 1) make sure you understand UMA, first. | |
20 // 2) update src/tools/histograms/histograms.xml in | |
21 // svn://svn.chromium.org/chrome-internal/trunk/src-internal | |
22 // Values are explicitly specified to make sure they don't shift around when | |
23 // edited, and also to make reading about:histograms easier. | |
24 enum PluginErrorCode { | |
25 ERROR_LOAD_SUCCESS = 0, | |
26 ERROR_LOAD_ABORTED = 1, | |
27 ERROR_UNKNOWN = 2, | |
28 ERROR_MANIFEST_RESOLVE_URL = 3, | |
29 ERROR_MANIFEST_LOAD_URL = 4, | |
30 ERROR_MANIFEST_STAT = 5, | |
31 ERROR_MANIFEST_TOO_LARGE = 6, | |
32 ERROR_MANIFEST_OPEN = 7, | |
33 ERROR_MANIFEST_MEMORY_ALLOC = 8, | |
34 ERROR_MANIFEST_READ = 9, | |
35 ERROR_MANIFEST_PARSING = 10, | |
36 ERROR_MANIFEST_SCHEMA_VALIDATE = 11, | |
37 ERROR_MANIFEST_GET_NEXE_URL = 12, | |
38 ERROR_NEXE_LOAD_URL = 13, | |
39 ERROR_NEXE_ORIGIN_PROTOCOL = 14, | |
40 ERROR_NEXE_FH_DUP = 15, | |
41 ERROR_NEXE_STAT = 16, | |
42 ERROR_ELF_CHECK_IO = 17, | |
43 ERROR_ELF_CHECK_FAIL = 18, | |
44 ERROR_SEL_LDR_INIT = 19, | |
45 ERROR_SEL_LDR_CREATE_LAUNCHER = 20, | |
46 ERROR_SEL_LDR_FD = 21, | |
47 ERROR_SEL_LDR_LAUNCH = 22, | |
48 // Deprecated, safe to reuse the # because never logged in UMA. | |
49 // ERROR_SEL_LDR_COMMUNICATION = 23, | |
50 ERROR_SEL_LDR_SEND_NEXE = 24, | |
51 ERROR_SEL_LDR_HANDLE_PASSING = 25, | |
52 ERROR_SEL_LDR_START_MODULE = 26, | |
53 ERROR_SEL_LDR_START_STATUS = 27, | |
54 ERROR_SRPC_CONNECTION_FAIL = 28, | |
55 ERROR_START_PROXY_CHECK_PPP = 29, | |
56 ERROR_START_PROXY_ALLOC = 30, | |
57 ERROR_START_PROXY_MODULE = 31, | |
58 ERROR_START_PROXY_INSTANCE = 32, | |
59 ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL = 33, | |
60 ERROR_SEL_LDR_COMMUNICATION_REV_SETUP = 34, | |
61 ERROR_SEL_LDR_COMMUNICATION_WRAPPER = 35, | |
62 ERROR_SEL_LDR_COMMUNICATION_REV_SERVICE = 36, | |
63 ERROR_START_PROXY_CRASH = 37, | |
64 // If you add a code, read the enum comment above on how to update histograms. | |
65 ERROR_MAX | |
66 }; | |
67 | |
68 class ErrorInfo { | |
69 public: | |
70 ErrorInfo() { | |
71 Reset(); | |
72 } | |
73 | |
74 void Reset() { | |
75 SetReport(ERROR_UNKNOWN, ""); | |
76 } | |
77 | |
78 void SetReport(PluginErrorCode error_code, const std::string& message) { | |
79 error_code_ = error_code; | |
80 message_ = message; | |
81 } | |
82 | |
83 PluginErrorCode error_code() const { | |
84 return error_code_; | |
85 } | |
86 | |
87 void PrependMessage(const std::string& prefix) { | |
88 message_ = prefix + message_; | |
89 } | |
90 | |
91 const std::string& message() const { | |
92 return message_; | |
93 } | |
94 | |
95 private: | |
96 PluginErrorCode error_code_; | |
97 std::string message_; | |
98 NACL_DISALLOW_COPY_AND_ASSIGN(ErrorInfo); | |
99 }; | |
100 | |
101 } // namespace plugin | |
102 | |
103 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_ERROR_H | |
OLD | NEW |