Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/database/databases_table.h" | 5 #include "webkit/database/databases_table.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "sql/statement.h" | 9 #include "sql/statement.h" |
| 10 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool DatabasesTable::InsertDatabaseDetails(const DatabaseDetails& details) { | 75 bool DatabasesTable::InsertDatabaseDetails(const DatabaseDetails& details) { |
| 76 sql::Statement insert_statement(db_->GetCachedStatement( | 76 sql::Statement insert_statement(db_->GetCachedStatement( |
| 77 SQL_FROM_HERE, "INSERT INTO Databases (origin, name, description, " | 77 SQL_FROM_HERE, "INSERT INTO Databases (origin, name, description, " |
| 78 "estimated_size) VALUES (?, ?, ?, ?)")); | 78 "estimated_size) VALUES (?, ?, ?, ?)")); |
| 79 insert_statement.BindString16(0, details.origin_identifier); | 79 insert_statement.BindString16(0, details.origin_identifier); |
| 80 insert_statement.BindString16(1, details.database_name); | 80 insert_statement.BindString16(1, details.database_name); |
| 81 insert_statement.BindString16(2, details.description); | 81 insert_statement.BindString16(2, details.description); |
| 82 insert_statement.BindInt64(3, details.estimated_size); | 82 insert_statement.BindInt64(3, details.estimated_size); |
| 83 | |
|
Scott Hess - ex-Googler
2012/02/13 22:04:04
Egregious whitespace changes are egregious. I'd r
Greg Billock
2012/02/13 22:48:59
I've been using this formatting everywhere else. I
Scott Hess - ex-Googler
2012/02/13 22:52:58
OK. I do kind of think that's tilting against win
| |
| 83 return insert_statement.Run(); | 84 return insert_statement.Run(); |
| 84 } | 85 } |
| 85 | 86 |
| 86 bool DatabasesTable::UpdateDatabaseDetails(const DatabaseDetails& details) { | 87 bool DatabasesTable::UpdateDatabaseDetails(const DatabaseDetails& details) { |
| 87 sql::Statement update_statement(db_->GetCachedStatement( | 88 sql::Statement update_statement(db_->GetCachedStatement( |
| 88 SQL_FROM_HERE, "UPDATE Databases SET description = ?, " | 89 SQL_FROM_HERE, "UPDATE Databases SET description = ?, " |
| 89 "estimated_size = ? WHERE origin = ? AND name = ?")); | 90 "estimated_size = ? WHERE origin = ? AND name = ?")); |
| 90 update_statement.BindString16(0, details.description); | 91 update_statement.BindString16(0, details.description); |
| 91 update_statement.BindInt64(1, details.estimated_size); | 92 update_statement.BindInt64(1, details.estimated_size); |
| 92 update_statement.BindString16(2, details.origin_identifier); | 93 update_statement.BindString16(2, details.origin_identifier); |
| 93 update_statement.BindString16(3, details.database_name); | 94 update_statement.BindString16(3, details.database_name); |
| 95 | |
| 94 return (update_statement.Run() && db_->GetLastChangeCount()); | 96 return (update_statement.Run() && db_->GetLastChangeCount()); |
| 95 } | 97 } |
| 96 | 98 |
| 97 bool DatabasesTable::DeleteDatabaseDetails(const string16& origin_identifier, | 99 bool DatabasesTable::DeleteDatabaseDetails(const string16& origin_identifier, |
| 98 const string16& database_name) { | 100 const string16& database_name) { |
| 99 sql::Statement delete_statement(db_->GetCachedStatement( | 101 sql::Statement delete_statement(db_->GetCachedStatement( |
| 100 SQL_FROM_HERE, "DELETE FROM Databases WHERE origin = ? AND name = ?")); | 102 SQL_FROM_HERE, "DELETE FROM Databases WHERE origin = ? AND name = ?")); |
| 101 delete_statement.BindString16(0, origin_identifier); | 103 delete_statement.BindString16(0, origin_identifier); |
| 102 delete_statement.BindString16(1, database_name); | 104 delete_statement.BindString16(1, database_name); |
| 105 | |
| 103 return (delete_statement.Run() && db_->GetLastChangeCount()); | 106 return (delete_statement.Run() && db_->GetLastChangeCount()); |
| 104 } | 107 } |
| 105 | 108 |
| 106 bool DatabasesTable::GetAllOrigins(std::vector<string16>* origins) { | 109 bool DatabasesTable::GetAllOrigins(std::vector<string16>* origins) { |
| 107 sql::Statement statement(db_->GetCachedStatement( | 110 sql::Statement statement(db_->GetCachedStatement( |
| 108 SQL_FROM_HERE, "SELECT DISTINCT origin FROM Databases ORDER BY origin")); | 111 SQL_FROM_HERE, "SELECT DISTINCT origin FROM Databases ORDER BY origin")); |
| 109 | 112 |
| 110 while (statement.Step()) | 113 while (statement.Step()) |
| 111 origins->push_back(statement.ColumnString16(0)); | 114 origins->push_back(statement.ColumnString16(0)); |
| 112 | 115 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 130 details_vector->push_back(details); | 133 details_vector->push_back(details); |
| 131 } | 134 } |
| 132 | 135 |
| 133 return statement.Succeeded(); | 136 return statement.Succeeded(); |
| 134 } | 137 } |
| 135 | 138 |
| 136 bool DatabasesTable::DeleteOrigin(const string16& origin_identifier) { | 139 bool DatabasesTable::DeleteOrigin(const string16& origin_identifier) { |
| 137 sql::Statement delete_statement(db_->GetCachedStatement( | 140 sql::Statement delete_statement(db_->GetCachedStatement( |
| 138 SQL_FROM_HERE, "DELETE FROM Databases WHERE origin = ?")); | 141 SQL_FROM_HERE, "DELETE FROM Databases WHERE origin = ?")); |
| 139 delete_statement.BindString16(0, origin_identifier); | 142 delete_statement.BindString16(0, origin_identifier); |
| 143 | |
| 140 return (delete_statement.Run() && db_->GetLastChangeCount()); | 144 return (delete_statement.Run() && db_->GetLastChangeCount()); |
| 141 } | 145 } |
| 142 | 146 |
| 143 } // namespace webkit_database | 147 } // namespace webkit_database |
| OLD | NEW |