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
3 // found in the LICENSE file.
5 #include "chrome/browser/history/android/android_urls_sql_handler.h"
7 #include "base/logging.h"
8 #include "chrome/browser/history/history_database.h"
14 // The interesting columns of this handler.
15 const HistoryAndBookmarkRow::ColumnID kInterestingColumns[] = {
16 HistoryAndBookmarkRow::RAW_URL, HistoryAndBookmarkRow::URL_ID };
20 AndroidURLsSQLHandler::AndroidURLsSQLHandler(HistoryDatabase* history_db)
21 : SQLHandler(kInterestingColumns, arraysize(kInterestingColumns)),
22 history_db_(history_db) {
25 AndroidURLsSQLHandler::~AndroidURLsSQLHandler() {
28 bool AndroidURLsSQLHandler::Update(const HistoryAndBookmarkRow& row,
29 const TableIDRows& ids_set) {
30 DCHECK(row.is_value_set_explicitly(HistoryAndBookmarkRow::URL_ID));
31 DCHECK(row.is_value_set_explicitly(HistoryAndBookmarkRow::RAW_URL));
32 if (ids_set.size() != 1)
35 AndroidURLRow android_url_row;
36 if (!history_db_->GetAndroidURLRow(ids_set[0].url_id, &android_url_row))
39 return history_db_->UpdateAndroidURLRow(android_url_row.id, row.raw_url(),
43 bool AndroidURLsSQLHandler::Insert(HistoryAndBookmarkRow* row) {
44 AndroidURLID new_id = history_db_->AddAndroidURLRow(row->raw_url(),
50 bool AndroidURLsSQLHandler::Delete(const TableIDRows& ids_set) {
51 std::vector<URLID> ids;
52 for (TableIDRows::const_iterator id = ids_set.begin();
53 id != ids_set.end(); ++id)
54 ids.push_back(id->url_id);
59 return history_db_->DeleteAndroidURLRows(ids);
62 } // namespace history.