| OLD | NEW |
| 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 12 matching lines...) Expand all Loading... |
| 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/core/v8/ScriptWrappable.h" | 32 #include "bindings/core/v8/ScriptWrappable.h" |
| 33 #include "wtf/PtrUtil.h" |
| 33 #include "wtf/text/WTFString.h" | 34 #include "wtf/text/WTFString.h" |
| 35 #include <memory> |
| 34 | 36 |
| 35 namespace blink { | 37 namespace blink { |
| 36 | 38 |
| 37 class SQLErrorData { | 39 class SQLErrorData { |
| 38 USING_FAST_MALLOC(SQLErrorData); | 40 USING_FAST_MALLOC(SQLErrorData); |
| 39 public: | 41 public: |
| 40 static PassOwnPtr<SQLErrorData> create(unsigned code, const String& message) | 42 static std::unique_ptr<SQLErrorData> create(unsigned code, const String& mes
sage) |
| 41 { | 43 { |
| 42 return adoptPtr(new SQLErrorData(code, message)); | 44 return wrapUnique(new SQLErrorData(code, message)); |
| 43 } | 45 } |
| 44 | 46 |
| 45 static PassOwnPtr<SQLErrorData> create(unsigned code, const char* message, i
nt sqliteCode, const char* sqliteMessage) | 47 static std::unique_ptr<SQLErrorData> create(unsigned code, const char* messa
ge, int sqliteCode, const char* sqliteMessage) |
| 46 { | 48 { |
| 47 return create(code, String::format("%s (%d %s)", message, sqliteCode, sq
liteMessage)); | 49 return create(code, String::format("%s (%d %s)", message, sqliteCode, sq
liteMessage)); |
| 48 } | 50 } |
| 49 | 51 |
| 50 static PassOwnPtr<SQLErrorData> create(const SQLErrorData& data) | 52 static std::unique_ptr<SQLErrorData> create(const SQLErrorData& data) |
| 51 { | 53 { |
| 52 return create(data.code(), data.message()); | 54 return create(data.code(), data.message()); |
| 53 } | 55 } |
| 54 | 56 |
| 55 SQLErrorData(const SQLErrorData& data) : m_code(data.m_code), m_message(data
.m_message.isolatedCopy()) { } | 57 SQLErrorData(const SQLErrorData& data) : m_code(data.m_code), m_message(data
.m_message.isolatedCopy()) { } |
| 56 | 58 |
| 57 unsigned code() const { return m_code; } | 59 unsigned code() const { return m_code; } |
| 58 String message() const { return m_message.isolatedCopy(); } | 60 String message() const { return m_message.isolatedCopy(); } |
| 59 | 61 |
| 60 private: | 62 private: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 91 private: | 93 private: |
| 92 explicit SQLError(const SQLErrorData& data) | 94 explicit SQLError(const SQLErrorData& data) |
| 93 : m_data(data) { } | 95 : m_data(data) { } |
| 94 | 96 |
| 95 const SQLErrorData m_data; | 97 const SQLErrorData m_data; |
| 96 }; | 98 }; |
| 97 | 99 |
| 98 } // namespace blink | 100 } // namespace blink |
| 99 | 101 |
| 100 #endif // SQLError_h | 102 #endif // SQLError_h |
| OLD | NEW |