| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef EXTENSIONS_BROWSER_EXTENSION_ERROR_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_ERROR_H_ |
| 6 #define EXTENSIONS_BROWSER_EXTENSION_ERROR_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_ERROR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/scoped_vector.h" |
| 13 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "url/gurl.h" |
| 14 | 17 |
| 15 namespace extensions { | 18 namespace extensions { |
| 16 | 19 |
| 17 class ExtensionError { | 20 class ExtensionError { |
| 18 public: | 21 public: |
| 19 enum Type { | 22 enum Type { |
| 20 MANIFEST_PARSING_ERROR, | 23 MANIFEST_PARSING_ERROR, |
| 21 JAVASCRIPT_RUNTIME_ERROR | 24 JAVASCRIPT_RUNTIME_ERROR |
| 22 }; | 25 }; |
| 23 | 26 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 class JavascriptRuntimeError : public ExtensionError { | 71 class JavascriptRuntimeError : public ExtensionError { |
| 69 public: | 72 public: |
| 70 struct StackFrame { | 73 struct StackFrame { |
| 71 size_t line_number; | 74 size_t line_number; |
| 72 size_t column_number; | 75 size_t column_number; |
| 73 // This is stored as a string (rather than a url) since it can be a | 76 // This is stored as a string (rather than a url) since it can be a |
| 74 // Chrome script file (e.g., event_bindings.js). | 77 // Chrome script file (e.g., event_bindings.js). |
| 75 base::string16 url; | 78 base::string16 url; |
| 76 base::string16 function; // optional | 79 base::string16 function; // optional |
| 77 | 80 |
| 78 // STL-Required constructor | |
| 79 StackFrame(); | |
| 80 | |
| 81 StackFrame(size_t frame_line, | 81 StackFrame(size_t frame_line, |
| 82 size_t frame_column, | 82 size_t frame_column, |
| 83 const base::string16& frame_url, | 83 const base::string16& frame_url, |
| 84 const base::string16& frame_function /* can be empty */); | 84 const base::string16& frame_function /* can be empty */); |
| 85 ~StackFrame(); |
| 85 | 86 |
| 86 ~StackFrame(); | 87 static scoped_ptr<StackFrame> CreateFromText(const base::string16& text); |
| 87 }; | 88 }; |
| 88 typedef std::vector<StackFrame> StackTrace; | 89 typedef ScopedVector<StackFrame> StackTrace; |
| 89 | 90 |
| 90 JavascriptRuntimeError(bool from_incognito, | 91 JavascriptRuntimeError(bool from_incognito, |
| 91 const base::string16& source, | 92 const base::string16& source, |
| 92 const base::string16& message, | 93 const base::string16& message, |
| 93 logging::LogSeverity level, | 94 const base::string16& stack_trace, |
| 94 const base::string16& details); | 95 int32 line_number, |
| 96 const GURL& context_url, |
| 97 logging::LogSeverity level); |
| 95 virtual ~JavascriptRuntimeError(); | 98 virtual ~JavascriptRuntimeError(); |
| 96 | 99 |
| 97 virtual std::string PrintForTest() const OVERRIDE; | 100 virtual std::string PrintForTest() const OVERRIDE; |
| 98 | 101 |
| 102 const GURL& context_url() const { return context_url_; } |
| 99 logging::LogSeverity level() const { return level_; } | 103 logging::LogSeverity level() const { return level_; } |
| 100 const base::string16& execution_context_url() const { | |
| 101 return execution_context_url_; | |
| 102 } | |
| 103 const StackTrace& stack_trace() const { return stack_trace_; } | 104 const StackTrace& stack_trace() const { return stack_trace_; } |
| 104 private: | 105 private: |
| 105 // Parse the JSON |details| passed to the error. This includes a stack trace | 106 // Parse the stack trace from either the |message| or the |stack_trace| |
| 106 // and an execution context url. | 107 // string. |
| 107 void ParseDetails(const base::string16& details); | 108 void GetStackTrace(const base::string16& message, |
| 108 // Try to determine the ID of the extension. This may be obtained through the | 109 const base::string16& stack_trace, |
| 109 // reported source, or through the execution context url. | 110 int32 line_number); |
| 110 void DetermineExtensionID(); | 111 // Since we piggy-back onto other error reporting systems (like V8 and |
| 112 // WebKit), the reported information may need to be cleaned up in order to be |
| 113 // in a consistent format. |
| 114 void CleanUpInit(); |
| 111 | 115 |
| 116 GURL context_url_; |
| 112 logging::LogSeverity level_; | 117 logging::LogSeverity level_; |
| 113 base::string16 execution_context_url_; | |
| 114 StackTrace stack_trace_; | 118 StackTrace stack_trace_; |
| 115 | 119 |
| 116 DISALLOW_COPY_AND_ASSIGN(JavascriptRuntimeError); | 120 DISALLOW_COPY_AND_ASSIGN(JavascriptRuntimeError); |
| 117 }; | 121 }; |
| 118 | 122 |
| 119 } // namespace extensions | 123 } // namespace extensions |
| 120 | 124 |
| 121 #endif // EXTENSIONS_BROWSER_EXTENSION_ERROR_H_ | 125 #endif // EXTENSIONS_BROWSER_EXTENSION_ERROR_H_ |
| OLD | NEW |