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/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "extensions/common/stack_frame.h" |
| 15 #include "url/gurl.h" |
14 | 16 |
15 namespace extensions { | 17 namespace extensions { |
16 | 18 |
17 class ExtensionError { | 19 class ExtensionError { |
18 public: | 20 public: |
19 enum Type { | 21 enum Type { |
20 MANIFEST_ERROR, | 22 MANIFEST_ERROR, |
21 RUNTIME_ERROR | 23 RUNTIME_ERROR |
22 }; | 24 }; |
23 | 25 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 78 |
77 virtual std::string PrintForTest() const OVERRIDE; | 79 virtual std::string PrintForTest() const OVERRIDE; |
78 private: | 80 private: |
79 virtual bool IsEqualImpl(const ExtensionError* rhs) const OVERRIDE; | 81 virtual bool IsEqualImpl(const ExtensionError* rhs) const OVERRIDE; |
80 | 82 |
81 DISALLOW_COPY_AND_ASSIGN(ManifestError); | 83 DISALLOW_COPY_AND_ASSIGN(ManifestError); |
82 }; | 84 }; |
83 | 85 |
84 class RuntimeError : public ExtensionError { | 86 class RuntimeError : public ExtensionError { |
85 public: | 87 public: |
86 struct StackFrame { | |
87 size_t line_number; | |
88 size_t column_number; | |
89 // This is stored as a string (rather than a url) since it can be a | |
90 // Chrome script file (e.g., event_bindings.js). | |
91 base::string16 url; | |
92 base::string16 function; // optional | |
93 | |
94 // STL-Required constructor | |
95 StackFrame(); | |
96 | |
97 StackFrame(size_t frame_line, | |
98 size_t frame_column, | |
99 const base::string16& frame_url, | |
100 const base::string16& frame_function /* can be empty */); | |
101 | |
102 ~StackFrame(); | |
103 | |
104 bool operator==(const StackFrame& rhs) const; | |
105 }; | |
106 typedef std::vector<StackFrame> StackTrace; | |
107 | |
108 RuntimeError(bool from_incognito, | 88 RuntimeError(bool from_incognito, |
109 const base::string16& source, | 89 const base::string16& source, |
110 const base::string16& message, | 90 const base::string16& message, |
111 logging::LogSeverity level, | 91 const StackTrace& stack_trace, |
112 const base::string16& details); | 92 const GURL& context_url, |
| 93 logging::LogSeverity level); |
113 virtual ~RuntimeError(); | 94 virtual ~RuntimeError(); |
114 | 95 |
115 virtual std::string PrintForTest() const OVERRIDE; | 96 virtual std::string PrintForTest() const OVERRIDE; |
116 | 97 |
117 const base::string16& execution_context_url() const { | 98 const GURL& context_url() const { return context_url_; } |
118 return execution_context_url_; | |
119 } | |
120 const StackTrace& stack_trace() const { return stack_trace_; } | 99 const StackTrace& stack_trace() const { return stack_trace_; } |
121 private: | 100 private: |
122 virtual bool IsEqualImpl(const ExtensionError* rhs) const OVERRIDE; | 101 virtual bool IsEqualImpl(const ExtensionError* rhs) const OVERRIDE; |
123 | 102 |
124 // Parse the JSON |details| passed to the error. This includes a stack trace | 103 // Since we piggy-back onto other error reporting systems (like V8 and |
125 // and an execution context url. | 104 // WebKit), the reported information may need to be cleaned up in order to be |
126 void ParseDetails(const base::string16& details); | 105 // in a consistent format. |
127 // Try to determine the ID of the extension. This may be obtained through the | 106 void CleanUpInit(); |
128 // reported source, or through the execution context url. | |
129 void DetermineExtensionID(); | |
130 | 107 |
131 base::string16 execution_context_url_; | 108 GURL context_url_; |
132 StackTrace stack_trace_; | 109 StackTrace stack_trace_; |
133 | 110 |
134 DISALLOW_COPY_AND_ASSIGN(RuntimeError); | 111 DISALLOW_COPY_AND_ASSIGN(RuntimeError); |
135 }; | 112 }; |
136 | 113 |
137 } // namespace extensions | 114 } // namespace extensions |
138 | 115 |
139 #endif // EXTENSIONS_BROWSER_EXTENSION_ERROR_H_ | 116 #endif // EXTENSIONS_BROWSER_EXTENSION_ERROR_H_ |
OLD | NEW |