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

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

Issue 170603003: Use nullptr_t for RefPtr, PassRefPtr and RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final rebase Created 6 years, 10 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 SQLiteDatabase* database = &db->sqliteDatabase(); 57 SQLiteDatabase* database = &db->sqliteDatabase();
58 58
59 SQLiteStatement statement(*database, m_statement); 59 SQLiteStatement statement(*database, m_statement);
60 int result = statement.prepare(); 60 int result = statement.prepare();
61 if (result != SQLResultOk) { 61 if (result != SQLResultOk) {
62 if (result == SQLResultInterrupt) 62 if (result == SQLResultInterrupt)
63 exceptionState.throwDOMException(SQLDatabaseError, "Connection to th e database interrupted."); 63 exceptionState.throwDOMException(SQLDatabaseError, "Connection to th e database interrupted.");
64 else 64 else
65 exceptionState.throwDOMException(SyntaxError, "Could not prepare sta tement."); 65 exceptionState.throwDOMException(SyntaxError, "Could not prepare sta tement.");
66 db->setLastErrorMessage("could not prepare statement", result, database- >lastErrorMsg()); 66 db->setLastErrorMessage("could not prepare statement", result, database- >lastErrorMsg());
67 return 0; 67 return nullptr;
68 } 68 }
69 69
70 if (statement.bindParameterCount() != m_arguments.size()) { 70 if (statement.bindParameterCount() != m_arguments.size()) {
71 if (db->isInterrupted()) 71 if (db->isInterrupted())
72 exceptionState.throwDOMException(SQLDatabaseError, "Connection to th e database interrupted."); 72 exceptionState.throwDOMException(SQLDatabaseError, "Connection to th e database interrupted.");
73 else 73 else
74 exceptionState.throwDOMException(SyntaxError, "Number of '?'s in sta tement string (" + String::number(statement.bindParameterCount()) + ") does not match the arguments provided (" + String::number(m_arguments.size()) + ")."); 74 exceptionState.throwDOMException(SyntaxError, "Number of '?'s in sta tement string (" + String::number(statement.bindParameterCount()) + ") does not match the arguments provided (" + String::number(m_arguments.size()) + ").");
75 db->setLastErrorMessage("number of '?'s in statement string does not mat ch argument count"); 75 db->setLastErrorMessage("number of '?'s in statement string does not mat ch argument count");
76 return 0; 76 return nullptr;
77 } 77 }
78 78
79 for (unsigned i = 0; i < m_arguments.size(); ++i) { 79 for (unsigned i = 0; i < m_arguments.size(); ++i) {
80 result = statement.bindValue(i + 1, m_arguments[i]); 80 result = statement.bindValue(i + 1, m_arguments[i]);
81 if (result == SQLResultFull) { 81 if (result == SQLResultFull) {
82 exceptionState.throwDOMException(QuotaExceededError, SQLError::quota ExceededErrorMessage); 82 exceptionState.throwDOMException(QuotaExceededError, SQLError::quota ExceededErrorMessage);
83 db->setLastErrorMessage("there was not enough remaining storage spac e"); 83 db->setLastErrorMessage("there was not enough remaining storage spac e");
84 return 0; 84 return nullptr;
85 } 85 }
86 86
87 if (result != SQLResultOk) { 87 if (result != SQLResultOk) {
88 exceptionState.throwDOMException(SQLDatabaseError, "Could not bind v alue."); 88 exceptionState.throwDOMException(SQLDatabaseError, "Could not bind v alue.");
89 db->setLastErrorMessage("could not bind value", result, database->la stErrorMsg()); 89 db->setLastErrorMessage("could not bind value", result, database->la stErrorMsg());
90 return 0; 90 return nullptr;
91 } 91 }
92 } 92 }
93 93
94 RefPtr<SQLResultSet> resultSet = SQLResultSet::create(); 94 RefPtr<SQLResultSet> resultSet = SQLResultSet::create();
95 95
96 // Step so we can fetch the column names. 96 // Step so we can fetch the column names.
97 result = statement.step(); 97 result = statement.step();
98 if (result == SQLResultRow) { 98 if (result == SQLResultRow) {
99 int columnCount = statement.columnCount(); 99 int columnCount = statement.columnCount();
100 SQLResultSetRowList* rows = resultSet->rows(); 100 SQLResultSetRowList* rows = resultSet->rows();
101 101
102 for (int i = 0; i < columnCount; i++) 102 for (int i = 0; i < columnCount; i++)
103 rows->addColumn(statement.getColumnName(i)); 103 rows->addColumn(statement.getColumnName(i));
104 104
105 do { 105 do {
106 for (int i = 0; i < columnCount; i++) 106 for (int i = 0; i < columnCount; i++)
107 rows->addResult(statement.getColumnValue(i)); 107 rows->addResult(statement.getColumnValue(i));
108 108
109 result = statement.step(); 109 result = statement.step();
110 } while (result == SQLResultRow); 110 } while (result == SQLResultRow);
111 111
112 if (result != SQLResultDone) { 112 if (result != SQLResultDone) {
113 exceptionState.throwDOMException(SQLDatabaseError, "Could not iterat e results."); 113 exceptionState.throwDOMException(SQLDatabaseError, "Could not iterat e results.");
114 db->setLastErrorMessage("could not iterate results", result, databas e->lastErrorMsg()); 114 db->setLastErrorMessage("could not iterate results", result, databas e->lastErrorMsg());
115 return 0; 115 return nullptr;
116 } 116 }
117 } else if (result == SQLResultDone) { 117 } else if (result == SQLResultDone) {
118 // Didn't find anything, or was an insert. 118 // Didn't find anything, or was an insert.
119 if (db->lastActionWasInsert()) 119 if (db->lastActionWasInsert())
120 resultSet->setInsertId(database->lastInsertRowID()); 120 resultSet->setInsertId(database->lastInsertRowID());
121 } else if (result == SQLResultFull) { 121 } else if (result == SQLResultFull) {
122 // Quota error, the delegate will be asked for more space and this state ment might be re-run. 122 // Quota error, the delegate will be asked for more space and this state ment might be re-run.
123 exceptionState.throwDOMException(QuotaExceededError, SQLError::quotaExce ededErrorMessage); 123 exceptionState.throwDOMException(QuotaExceededError, SQLError::quotaExce ededErrorMessage);
124 db->setLastErrorMessage("there was not enough remaining storage space"); 124 db->setLastErrorMessage("there was not enough remaining storage space");
125 return 0; 125 return nullptr;
126 } else if (result == SQLResultConstraint) { 126 } else if (result == SQLResultConstraint) {
127 exceptionState.throwDOMException(ConstraintError, "A constraint was viol ated."); 127 exceptionState.throwDOMException(ConstraintError, "A constraint was viol ated.");
128 db->setLastErrorMessage("statement failed due to a constraint failure"); 128 db->setLastErrorMessage("statement failed due to a constraint failure");
129 return 0; 129 return nullptr;
130 } else { 130 } else {
131 exceptionState.throwDOMException(SQLDatabaseError, "Could not execute st atement."); 131 exceptionState.throwDOMException(SQLDatabaseError, "Could not execute st atement.");
132 db->setLastErrorMessage("could not execute statement", result, database- >lastErrorMsg()); 132 db->setLastErrorMessage("could not execute statement", result, database- >lastErrorMsg());
133 return 0; 133 return nullptr;
134 } 134 }
135 135
136 resultSet->setRowsAffected(database->lastChanges()); 136 resultSet->setRowsAffected(database->lastChanges());
137 return resultSet.release(); 137 return resultSet.release();
138 } 138 }
139 139
140 } // namespace WebCore 140 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/webdatabase/SQLStatementBackend.cpp ('k') | Source/modules/webdatabase/SQLTransaction.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698