Chromium Code Reviews| Index: chrome/browser/webdata/web_intents_table.cc |
| diff --git a/chrome/browser/webdata/web_intents_table.cc b/chrome/browser/webdata/web_intents_table.cc |
| index 9be56b721d4a7a69de68032c443dc9460658ffb6..dbc5497382215747abd19a50744a32f5f5644666 100644 |
| --- a/chrome/browser/webdata/web_intents_table.cc |
| +++ b/chrome/browser/webdata/web_intents_table.cc |
| @@ -10,9 +10,13 @@ |
| #include "sql/statement.h" |
| namespace { |
| + |
| bool ExtractIntents(sql::Statement* s, |
| std::vector<WebIntentServiceData>* services) { |
| DCHECK(s); |
| + if (!s) |
|
James Hawkins
2011/10/26 23:50:06
You're going to remove this early return, right?
Greg Billock
2011/10/29 00:03:19
It needs to be here for the contract. Otherwise it
|
| + return false; |
| + |
| while (s->Step()) { |
| WebIntentServiceData service; |
| string16 tmp = s->ColumnString16(0); |
| @@ -30,6 +34,7 @@ bool ExtractIntents(sql::Statement* s, |
| } |
| return true; |
| } |
| + |
| } |
|
James Hawkins
2011/10/26 23:50:06
// namespace
Greg Billock
2011/10/29 00:03:19
Done.
|
| WebIntentsTable::WebIntentsTable(sql::Connection* db, |
| @@ -51,11 +56,11 @@ bool WebIntentsTable::Init() { |
| "title VARCHAR," |
| "disposition VARCHAR," |
| "UNIQUE (service_url, action, type))")) { |
| - NOTREACHED(); |
|
James Hawkins
2011/10/26 23:50:06
Please leave the NOTREACHEDs in place.
Greg Billock
2011/10/29 00:03:19
This is a bug in your change. These calls can fail
|
| + return false; |
| } |
| if (!db_->Execute("CREATE INDEX web_intents_index ON web_intents (action)")) |
| - NOTREACHED(); |
| + return false; |
| return true; |
| } |
| @@ -72,20 +77,31 @@ bool WebIntentsTable::GetWebIntents( |
| sql::Statement s(db_->GetUniqueStatement( |
| "SELECT service_url, action, type, title, disposition FROM web_intents " |
| "WHERE action=?")); |
| - if (!s) |
|
James Hawkins
2011/10/26 23:50:06
I prefer the existing construct.
|
| - NOTREACHED() << "Statement prepare failed"; |
| s.BindString16(0, action); |
| return ExtractIntents(&s, intents); |
| } |
| +// TODO(gbillock): This currently does a full-table scan. Eventually we will |
| +// store registrations by domain, and so have an indexed origin. At that time, |
| +// this should just change to do lookup by origin instead of URL. |
| +bool WebIntentsTable::GetWebIntentsForURL( |
| + const string16& service_url, |
| + std::vector<WebIntentServiceData>* intents) { |
| + DCHECK(intents); |
| + sql::Statement s(db_->GetUniqueStatement( |
| + "SELECT service_url, action, type, title, disposition FROM web_intents " |
| + "WHERE service_url=?")); |
| + |
| + s.BindString16(0, service_url); |
| + return ExtractIntents(&s, intents); |
| +} |
| + |
| bool WebIntentsTable::GetAllWebIntents( |
| std::vector<WebIntentServiceData>* intents) { |
| DCHECK(intents); |
| sql::Statement s(db_->GetUniqueStatement( |
| "SELECT service_url, action, type, title, disposition FROM web_intents")); |
| - if (!s) |
| - NOTREACHED() << "Statement prepare failed"; |
| return ExtractIntents(&s, intents); |
| } |
| @@ -95,8 +111,6 @@ bool WebIntentsTable::SetWebIntent(const WebIntentServiceData& intent) { |
| "INSERT OR REPLACE INTO web_intents " |
| "(service_url, type, action, title, disposition) " |
| "VALUES (?, ?, ?, ?, ?)")); |
| - if (!s) |
| - NOTREACHED() << "Statement prepare failed"; |
| // Default to window disposition. |
| string16 disposition = ASCIIToUTF16("window"); |
| @@ -117,8 +131,6 @@ bool WebIntentsTable::RemoveWebIntent(const WebIntentServiceData& intent) { |
| sql::Statement s(db_->GetUniqueStatement( |
| "DELETE FROM web_intents " |
| "WHERE service_url = ? AND action = ? AND type = ?")); |
| - if (!s) |
| - NOTREACHED() << "Statement prepare failed"; |
| s.BindString(0, intent.service_url.spec()); |
| s.BindString16(1, intent.action); |