15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Copyright (c) 2011 The Chromium Authors. All rights reserved. 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Use of this source code is governed by a BSD-style license that can be 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * found in the LICENSE file. 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Error codes and data structures used to report errors when loading a nexe. 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_ERROR_H 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_ERROR_H 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "native_client/src/include/nacl_macros.h" 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace plugin { 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// These error codes are reported via UMA so, if you edit them: 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1) make sure you understand UMA, first. 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 2) update src/tools/histograms/histograms.xml in 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// svn://svn.chromium.org/chrome-internal/trunk/src-internal 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Values are explicitly specified to make sure they don't shift around when 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// edited, and also to make reading about:histograms easier. 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)enum PluginErrorCode { 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_LOAD_SUCCESS = 0, 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_LOAD_ABORTED = 1, 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_UNKNOWN = 2, 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_MANIFEST_RESOLVE_URL = 3, 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_MANIFEST_LOAD_URL = 4, 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_MANIFEST_STAT = 5, 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_MANIFEST_TOO_LARGE = 6, 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_MANIFEST_OPEN = 7, 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_MANIFEST_MEMORY_ALLOC = 8, 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_MANIFEST_READ = 9, 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_MANIFEST_PARSING = 10, 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_MANIFEST_SCHEMA_VALIDATE = 11, 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_MANIFEST_GET_NEXE_URL = 12, 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_NEXE_LOAD_URL = 13, 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_NEXE_ORIGIN_PROTOCOL = 14, 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_NEXE_FH_DUP = 15, 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_NEXE_STAT = 16, 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_ELF_CHECK_IO = 17, 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_ELF_CHECK_FAIL = 18, 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_SEL_LDR_INIT = 19, 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_SEL_LDR_CREATE_LAUNCHER = 20, 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_SEL_LDR_FD = 21, 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_SEL_LDR_LAUNCH = 22, 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Deprecated, safe to reuse the # because never logged in UMA. 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ERROR_SEL_LDR_COMMUNICATION = 23, 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_SEL_LDR_SEND_NEXE = 24, 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_SEL_LDR_HANDLE_PASSING = 25, 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_SEL_LDR_START_MODULE = 26, 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_SEL_LDR_START_STATUS = 27, 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_SRPC_CONNECTION_FAIL = 28, 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_START_PROXY_CHECK_PPP = 29, 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_START_PROXY_ALLOC = 30, 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_START_PROXY_MODULE = 31, 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_START_PROXY_INSTANCE = 32, 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL = 33, 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_SEL_LDR_COMMUNICATION_REV_SETUP = 34, 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_SEL_LDR_COMMUNICATION_WRAPPER = 35, 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_SEL_LDR_COMMUNICATION_REV_SERVICE = 36, 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_START_PROXY_CRASH = 37, 662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_MANIFEST_PROGRAM_MISSING_ARCH = 38, 672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_OPEN_INPROGRESS = 39, 682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_OPEN_NOACCESS = 40, 692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_OPEN_NOQUOTA = 41, 702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_OPEN_NOSPACE = 42, 712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_OPEN_OTHER = 43, 722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_DIRECTORY_CREATE = 44, 732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_FILEOPEN_NOACCESS = 45, 742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_FILEOPEN_NOQUOTA = 46, 752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_FILEOPEN_NOSPACE = 47, 762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_FILEOPEN_NOTAFILE = 48, 772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_FILEOPEN_OTHER = 49, 782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_FETCH_NOACCESS = 50, 792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_FETCH_NOTFOUND = 51, 802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_FETCH_OTHER = 52, 812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_FINALIZE_COPY_NOQUOTA = 53, 822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_FINALIZE_COPY_NOSPACE = 54, 832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_FINALIZE_COPY_OTHER = 55, 842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_FINALIZE_RENAME_NOACCESS = 56, 852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CACHE_FINALIZE_RENAME_OTHER = 57, 862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_RESOURCE_FETCH = 58, 872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_PEXE_FETCH_ABORTED = 59, 882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_PEXE_FETCH_NOACCESS = 60, 892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_PEXE_FETCH_OTHER = 61, 902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_THREAD_CREATE = 62, 912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_LLC_SETUP = 63, 922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_LD_SETUP = 64, 932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_LLC_INTERNAL = 65, 942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_LD_INTERNAL = 66, 952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_CREATE_TEMP = 67, 963551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // This entry is no longer used, but should not be removed, because UMA 973551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // numbers need to be kept consistent. 982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_PNACL_NOT_ENABLED = 68, 992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_MANIFEST_NOACCESS_URL = 69, 1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ERROR_NEXE_NOACCESS_URL = 70, 101ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch ERROR_PNACL_CRASH_THROTTLED = 71, 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If you add a code, read the enum comment above on how to update histograms. 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_MAX 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ErrorInfo { 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ErrorInfo() { 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Reset(); 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void Reset() { 113c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SetReport(ERROR_UNKNOWN, std::string()); 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetReport(PluginErrorCode error_code, const std::string& message) { 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) error_code_ = error_code; 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) message_ = message; 119ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch console_message_ = message; 120ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch } 121ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 122ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // console_message is a part of the error that is logged to 123ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // the JavaScript console but is not reported to JavaScript via 124ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // the lastError property. This is used to report internal errors which 125ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // may easily change in new versions of the browser and we don't want apps 126ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // to come to depend on the details of these errors. 127ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch void SetReportWithConsoleOnlyError(PluginErrorCode error_code, 128ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch const std::string& message, 129ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch const std::string& console_message) { 130ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch error_code_ = error_code; 131ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch message_ = message; 132ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch console_message_ = message + "; " + console_message; 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PluginErrorCode error_code() const { 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return error_code_; 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void PrependMessage(const std::string& prefix) { 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) message_ = prefix + message_; 141ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch console_message_ = prefix + console_message_; 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& message() const { 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return message_; 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 148ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch const std::string& console_message() const { 149ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch return console_message_; 150ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch } 151ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PluginErrorCode error_code_; 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string message_; 155ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch std::string console_message_; 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NACL_DISALLOW_COPY_AND_ASSIGN(ErrorInfo); 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace plugin 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_ERROR_H 162