Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(810)

Side by Side Diff: Source/modules/webdatabase/SQLError.h

Issue 15605003: Make Exception and Error objects ScriptWrappable. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/geolocation/PositionError.h ('k') | Source/modules/webdatabase/SQLException.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 11 matching lines...) Expand all
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #ifndef SQLError_h 29 #ifndef SQLError_h
30 #define SQLError_h 30 #define SQLError_h
31 31
32 #include "bindings/v8/ScriptWrappable.h"
32 #include "wtf/ThreadSafeRefCounted.h" 33 #include "wtf/ThreadSafeRefCounted.h"
33 #include "wtf/text/WTFString.h" 34 #include "wtf/text/WTFString.h"
34 35
35 namespace WebCore { 36 namespace WebCore {
36 37
37 class SQLError : public ThreadSafeRefCounted<SQLError> { 38 class SQLError : public ThreadSafeRefCounted<SQLError>, public ScriptWrappable {
38 public: 39 public:
39 static PassRefPtr<SQLError> create(unsigned code, const String& message) { r eturn adoptRef(new SQLError(code, message)); } 40 static PassRefPtr<SQLError> create(unsigned code, const String& message) { r eturn adoptRef(new SQLError(code, message)); }
40 static PassRefPtr<SQLError> create(unsigned code, const char* message, int s qliteCode) 41 static PassRefPtr<SQLError> create(unsigned code, const char* message, int s qliteCode)
41 { 42 {
42 return create(code, String::format("%s (%d)", message, sqliteCode)); 43 return create(code, String::format("%s (%d)", message, sqliteCode));
43 } 44 }
44 static PassRefPtr<SQLError> create(unsigned code, const char* message, int s qliteCode, const char* sqliteMessage) 45 static PassRefPtr<SQLError> create(unsigned code, const char* message, int s qliteCode, const char* sqliteMessage)
45 { 46 {
46 return create(code, String::format("%s (%d %s)", message, sqliteCode, sq liteMessage)); 47 return create(code, String::format("%s (%d %s)", message, sqliteCode, sq liteMessage));
47 } 48 }
48 49
49 unsigned code() const { return m_code; } 50 unsigned code() const { return m_code; }
50 String message() const { return m_message.isolatedCopy(); } 51 String message() const { return m_message.isolatedCopy(); }
51 52
52 enum SQLErrorCode { 53 enum SQLErrorCode {
53 UNKNOWN_ERR = 0, 54 UNKNOWN_ERR = 0,
54 DATABASE_ERR = 1, 55 DATABASE_ERR = 1,
55 VERSION_ERR = 2, 56 VERSION_ERR = 2,
56 TOO_LARGE_ERR = 3, 57 TOO_LARGE_ERR = 3,
57 QUOTA_ERR = 4, 58 QUOTA_ERR = 4,
58 SYNTAX_ERR = 5, 59 SYNTAX_ERR = 5,
59 CONSTRAINT_ERR = 6, 60 CONSTRAINT_ERR = 6,
60 TIMEOUT_ERR = 7 61 TIMEOUT_ERR = 7
61 }; 62 };
62 63
63 private: 64 private:
64 SQLError(unsigned code, const String& message) : m_code(code), m_message(mes sage.isolatedCopy()) { } 65 SQLError(unsigned code, const String& message) : m_code(code), m_message(mes sage.isolatedCopy())
66 {
67 ScriptWrappable::init(this);
68 }
69
65 unsigned m_code; 70 unsigned m_code;
66 String m_message; 71 String m_message;
67 }; 72 };
68 73
69 } 74 }
70 75
71 #endif // SQLError_h 76 #endif // SQLError_h
OLDNEW
« no previous file with comments | « Source/modules/geolocation/PositionError.h ('k') | Source/modules/webdatabase/SQLException.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698