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..69f5e12225b1789db6f16ccef5ac4d588198922c 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); |
James Hawkins
2011/10/29 21:41:32
FYI this DCHECK is about the pointer |s| being non
Greg Billock
2011/10/31 17:07:09
There's an operator overload on !Statement which i
James Hawkins
2011/11/02 07:23:46
As I said previously, |s| is a pointer so if (!s)
|
+ if (!s) |
+ return false; |
+ |
while (s->Step()) { |
WebIntentServiceData service; |
string16 tmp = s->ColumnString16(0); |
@@ -30,7 +34,8 @@ bool ExtractIntents(sql::Statement* s, |
} |
return true; |
} |
-} |
+ |
+} // namespace |
WebIntentsTable::WebIntentsTable(sql::Connection* db, |
sql::MetaTable* meta_table) |
@@ -51,11 +56,11 @@ bool WebIntentsTable::Init() { |
"title VARCHAR," |
"disposition VARCHAR," |
"UNIQUE (service_url, action, type))")) { |
- NOTREACHED(); |
+ 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) |
- 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); |