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

Side by Side Diff: Source/modules/webdatabase/SQLStatementSync.cpp

Issue 24469004: Amusingly deprecate the generic version of 'ExceptionState::throwDOMException'. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 PassRefPtr<SQLResultSet> SQLStatementSync::execute(DatabaseSync* db, ExceptionSt ate& es) 54 PassRefPtr<SQLResultSet> SQLStatementSync::execute(DatabaseSync* db, ExceptionSt ate& es)
55 { 55 {
56 db->setAuthorizerPermissions(m_permissions); 56 db->setAuthorizerPermissions(m_permissions);
57 57
58 SQLiteDatabase* database = &db->sqliteDatabase(); 58 SQLiteDatabase* database = &db->sqliteDatabase();
59 59
60 SQLiteStatement statement(*database, m_statement); 60 SQLiteStatement statement(*database, m_statement);
61 int result = statement.prepare(); 61 int result = statement.prepare();
62 if (result != SQLResultOk) { 62 if (result != SQLResultOk) {
63 if (result == SQLResultInterrupt) 63 if (result == SQLResultInterrupt)
64 es.throwDOMException(SQLDatabaseError); 64 es.throwUninformativeAndGenericDOMException(SQLDatabaseError);
65 else 65 else
66 es.throwDOMException(SyntaxError, SQLError::syntaxErrorMessage); 66 es.throwDOMException(SyntaxError, SQLError::syntaxErrorMessage);
67 db->setLastErrorMessage("could not prepare statement", result, database- >lastErrorMsg()); 67 db->setLastErrorMessage("could not prepare statement", result, database- >lastErrorMsg());
68 return 0; 68 return 0;
69 } 69 }
70 70
71 if (statement.bindParameterCount() != m_arguments.size()) { 71 if (statement.bindParameterCount() != m_arguments.size()) {
72 if (db->isInterrupted()) 72 if (db->isInterrupted())
73 es.throwDOMException(SQLDatabaseError); 73 es.throwUninformativeAndGenericDOMException(SQLDatabaseError);
74 else 74 else
75 es.throwDOMException(SyntaxError, SQLError::syntaxErrorMessage); 75 es.throwDOMException(SyntaxError, SQLError::syntaxErrorMessage);
76 db->setLastErrorMessage("number of '?'s in statement string does not mat ch argument count"); 76 db->setLastErrorMessage("number of '?'s in statement string does not mat ch argument count");
77 return 0; 77 return 0;
78 } 78 }
79 79
80 for (unsigned i = 0; i < m_arguments.size(); ++i) { 80 for (unsigned i = 0; i < m_arguments.size(); ++i) {
81 result = statement.bindValue(i + 1, m_arguments[i]); 81 result = statement.bindValue(i + 1, m_arguments[i]);
82 if (result == SQLResultFull) { 82 if (result == SQLResultFull) {
83 es.throwDOMException(QuotaExceededError, SQLError::quotaExceededErro rMessage); 83 es.throwDOMException(QuotaExceededError, SQLError::quotaExceededErro rMessage);
84 db->setLastErrorMessage("there was not enough remaining storage spac e"); 84 db->setLastErrorMessage("there was not enough remaining storage spac e");
85 return 0; 85 return 0;
86 } 86 }
87 87
88 if (result != SQLResultOk) { 88 if (result != SQLResultOk) {
89 es.throwDOMException(SQLDatabaseError); 89 es.throwUninformativeAndGenericDOMException(SQLDatabaseError);
90 db->setLastErrorMessage("could not bind value", result, database->la stErrorMsg()); 90 db->setLastErrorMessage("could not bind value", result, database->la stErrorMsg());
91 return 0; 91 return 0;
92 } 92 }
93 } 93 }
94 94
95 RefPtr<SQLResultSet> resultSet = SQLResultSet::create(); 95 RefPtr<SQLResultSet> resultSet = SQLResultSet::create();
96 96
97 // Step so we can fetch the column names. 97 // Step so we can fetch the column names.
98 result = statement.step(); 98 result = statement.step();
99 if (result == SQLResultRow) { 99 if (result == SQLResultRow) {
100 int columnCount = statement.columnCount(); 100 int columnCount = statement.columnCount();
101 SQLResultSetRowList* rows = resultSet->rows(); 101 SQLResultSetRowList* rows = resultSet->rows();
102 102
103 for (int i = 0; i < columnCount; i++) 103 for (int i = 0; i < columnCount; i++)
104 rows->addColumn(statement.getColumnName(i)); 104 rows->addColumn(statement.getColumnName(i));
105 105
106 do { 106 do {
107 for (int i = 0; i < columnCount; i++) 107 for (int i = 0; i < columnCount; i++)
108 rows->addResult(statement.getColumnValue(i)); 108 rows->addResult(statement.getColumnValue(i));
109 109
110 result = statement.step(); 110 result = statement.step();
111 } while (result == SQLResultRow); 111 } while (result == SQLResultRow);
112 112
113 if (result != SQLResultDone) { 113 if (result != SQLResultDone) {
114 es.throwDOMException(SQLDatabaseError); 114 es.throwUninformativeAndGenericDOMException(SQLDatabaseError);
115 db->setLastErrorMessage("could not iterate results", result, databas e->lastErrorMsg()); 115 db->setLastErrorMessage("could not iterate results", result, databas e->lastErrorMsg());
116 return 0; 116 return 0;
117 } 117 }
118 } else if (result == SQLResultDone) { 118 } else if (result == SQLResultDone) {
119 // Didn't find anything, or was an insert. 119 // Didn't find anything, or was an insert.
120 if (db->lastActionWasInsert()) 120 if (db->lastActionWasInsert())
121 resultSet->setInsertId(database->lastInsertRowID()); 121 resultSet->setInsertId(database->lastInsertRowID());
122 } else if (result == SQLResultFull) { 122 } else if (result == SQLResultFull) {
123 // Quota error, the delegate will be asked for more space and this state ment might be re-run. 123 // Quota error, the delegate will be asked for more space and this state ment might be re-run.
124 es.throwDOMException(QuotaExceededError, SQLError::quotaExceededErrorMes sage); 124 es.throwDOMException(QuotaExceededError, SQLError::quotaExceededErrorMes sage);
125 db->setLastErrorMessage("there was not enough remaining storage space"); 125 db->setLastErrorMessage("there was not enough remaining storage space");
126 return 0; 126 return 0;
127 } else if (result == SQLResultConstraint) { 127 } else if (result == SQLResultConstraint) {
128 es.throwDOMException(ConstraintError, "A constraint was violated."); 128 es.throwDOMException(ConstraintError, "A constraint was violated.");
129 db->setLastErrorMessage("statement failed due to a constraint failure"); 129 db->setLastErrorMessage("statement failed due to a constraint failure");
130 return 0; 130 return 0;
131 } else { 131 } else {
132 es.throwDOMException(SQLDatabaseError); 132 es.throwUninformativeAndGenericDOMException(SQLDatabaseError);
133 db->setLastErrorMessage("could not execute statement", result, database- >lastErrorMsg()); 133 db->setLastErrorMessage("could not execute statement", result, database- >lastErrorMsg());
134 return 0; 134 return 0;
135 } 135 }
136 136
137 resultSet->setRowsAffected(database->lastChanges()); 137 resultSet->setRowsAffected(database->lastChanges());
138 return resultSet.release(); 138 return resultSet.release();
139 } 139 }
140 140
141 } // namespace WebCore 141 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/webdatabase/SQLResultSet.cpp ('k') | Source/modules/webdatabase/SQLTransaction.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698