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

Side by Side Diff: third_party/WebKit/Source/modules/webdatabase/SQLStatementBackend.cpp

Issue 2813433002: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in modules/webdatabase (Closed)
Patch Set: rebase and assert -> dcheck Created 3 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2013 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 SQLErrorData* SQLStatementBackend::SqlError() const { 118 SQLErrorData* SQLStatementBackend::SqlError() const {
119 return error_.get(); 119 return error_.get();
120 } 120 }
121 121
122 SQLResultSet* SQLStatementBackend::SqlResultSet() const { 122 SQLResultSet* SQLStatementBackend::SqlResultSet() const {
123 return result_set_->IsValid() ? result_set_.Get() : 0; 123 return result_set_->IsValid() ? result_set_.Get() : 0;
124 } 124 }
125 125
126 bool SQLStatementBackend::Execute(Database* db) { 126 bool SQLStatementBackend::Execute(Database* db) {
127 ASSERT(!result_set_->IsValid()); 127 DCHECK(!result_set_->IsValid());
128 128
129 // If we're re-running this statement after a quota violation, we need to 129 // If we're re-running this statement after a quota violation, we need to
130 // clear that error now 130 // clear that error now
131 ClearFailureDueToQuota(); 131 ClearFailureDueToQuota();
132 132
133 // This transaction might have been marked bad while it was being set up on 133 // This transaction might have been marked bad while it was being set up on
134 // the main thread, so if there is still an error, return false. 134 // the main thread, so if there is still an error, return false.
135 if (error_) 135 if (error_)
136 return false; 136 return false;
137 137
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // different way, we'd use sqlite3_total_changes() here instead of 240 // different way, we'd use sqlite3_total_changes() here instead of
241 // sqlite3_changed, because that includes rows modified from within a trigger. 241 // sqlite3_changed, because that includes rows modified from within a trigger.
242 // For now, this seems sufficient. 242 // For now, this seems sufficient.
243 result_set_->SetRowsAffected(database->LastChanges()); 243 result_set_->SetRowsAffected(database->LastChanges());
244 244
245 db->ReportExecuteStatementResult(0, -1, 0); // OK 245 db->ReportExecuteStatementResult(0, -1, 0); // OK
246 return true; 246 return true;
247 } 247 }
248 248
249 void SQLStatementBackend::SetVersionMismatchedError(Database* database) { 249 void SQLStatementBackend::SetVersionMismatchedError(Database* database) {
250 ASSERT(!error_ && !result_set_->IsValid()); 250 DCHECK(!error_);
251 DHCECK(!result_set_->IsValid());
michaeln 2017/04/10 22:59:00 lgtm % typo here
Hwanseung Lee 2017/04/11 08:26:09 Done.
251 database->ReportExecuteStatementResult(7, SQLError::kVersionErr, 0); 252 database->ReportExecuteStatementResult(7, SQLError::kVersionErr, 0);
252 error_ = SQLErrorData::Create( 253 error_ = SQLErrorData::Create(
253 SQLError::kVersionErr, 254 SQLError::kVersionErr,
254 "current version of the database and `oldVersion` argument do not match"); 255 "current version of the database and `oldVersion` argument do not match");
255 } 256 }
256 257
257 void SQLStatementBackend::SetFailureDueToQuota(Database* database) { 258 void SQLStatementBackend::SetFailureDueToQuota(Database* database) {
258 ASSERT(!error_ && !result_set_->IsValid()); 259 DCHECK(!error_);
260 DCHECK(!result_set_->IsValid());
259 database->ReportExecuteStatementResult(8, SQLError::kQuotaErr, 0); 261 database->ReportExecuteStatementResult(8, SQLError::kQuotaErr, 0);
260 error_ = SQLErrorData::Create(SQLError::kQuotaErr, 262 error_ = SQLErrorData::Create(SQLError::kQuotaErr,
261 "there was not enough remaining storage " 263 "there was not enough remaining storage "
262 "space, or the storage quota was reached and " 264 "space, or the storage quota was reached and "
263 "the user declined to allow more space"); 265 "the user declined to allow more space");
264 } 266 }
265 267
266 void SQLStatementBackend::ClearFailureDueToQuota() { 268 void SQLStatementBackend::ClearFailureDueToQuota() {
267 if (LastExecutionFailedDueToQuota()) 269 if (LastExecutionFailedDueToQuota())
268 error_ = nullptr; 270 error_ = nullptr;
269 } 271 }
270 272
271 bool SQLStatementBackend::LastExecutionFailedDueToQuota() const { 273 bool SQLStatementBackend::LastExecutionFailedDueToQuota() const {
272 return error_ && error_->Code() == SQLError::kQuotaErr; 274 return error_ && error_->Code() == SQLError::kQuotaErr;
273 } 275 }
274 276
275 } // namespace blink 277 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698