OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /* | 7 /* |
8 * Error codes and data structures used to report errors when loading a nexe. | 8 * Error codes and data structures used to report errors when loading a nexe. |
9 */ | 9 */ |
10 | 10 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 Reset(); | 108 Reset(); |
109 } | 109 } |
110 | 110 |
111 void Reset() { | 111 void Reset() { |
112 SetReport(ERROR_UNKNOWN, std::string()); | 112 SetReport(ERROR_UNKNOWN, std::string()); |
113 } | 113 } |
114 | 114 |
115 void SetReport(PluginErrorCode error_code, const std::string& message) { | 115 void SetReport(PluginErrorCode error_code, const std::string& message) { |
116 error_code_ = error_code; | 116 error_code_ = error_code; |
117 message_ = message; | 117 message_ = message; |
| 118 console_message_ = message; |
| 119 } |
| 120 |
| 121 // console_message is a part of the error that is logged to |
| 122 // the JavaScript console but is not reported to JavaScript via |
| 123 // the lastError property. This is used to report internal errors which |
| 124 // may easily change in new versions of the browser and we don't want apps |
| 125 // to come to depend on the details of these errors. |
| 126 void SetReportWithConsoleOnlyError(PluginErrorCode error_code, |
| 127 const std::string& message, |
| 128 const std::string& console_message) { |
| 129 error_code_ = error_code; |
| 130 message_ = message; |
| 131 console_message_ = message + "; " + console_message; |
118 } | 132 } |
119 | 133 |
120 PluginErrorCode error_code() const { | 134 PluginErrorCode error_code() const { |
121 return error_code_; | 135 return error_code_; |
122 } | 136 } |
123 | 137 |
124 void PrependMessage(const std::string& prefix) { | 138 void PrependMessage(const std::string& prefix) { |
125 message_ = prefix + message_; | 139 message_ = prefix + message_; |
| 140 console_message_ = prefix + console_message_; |
126 } | 141 } |
127 | 142 |
128 const std::string& message() const { | 143 const std::string& message() const { |
129 return message_; | 144 return message_; |
130 } | 145 } |
131 | 146 |
| 147 const std::string& console_message() const { |
| 148 return console_message_; |
| 149 } |
| 150 |
132 private: | 151 private: |
133 PluginErrorCode error_code_; | 152 PluginErrorCode error_code_; |
134 std::string message_; | 153 std::string message_; |
| 154 std::string console_message_; |
135 NACL_DISALLOW_COPY_AND_ASSIGN(ErrorInfo); | 155 NACL_DISALLOW_COPY_AND_ASSIGN(ErrorInfo); |
136 }; | 156 }; |
137 | 157 |
138 } // namespace plugin | 158 } // namespace plugin |
139 | 159 |
140 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_ERROR_H | 160 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_ERROR_H |
OLD | NEW |