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

Side by Side Diff: chrome/browser/history/android/android_urls_sql_handler.cc

Issue 813503003: Move files from chrome/browser/history to components/history (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@favicon-owners
Patch Set: Created 5 years, 11 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
(Empty)
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.
4
5 #include "chrome/browser/history/android/android_urls_sql_handler.h"
6
7 #include "base/logging.h"
8 #include "components/history/core/android/android_urls_database.h"
9
10 namespace history {
11
12 namespace {
13
14 // The interesting columns of this handler.
15 const HistoryAndBookmarkRow::ColumnID kInterestingColumns[] = {
16 HistoryAndBookmarkRow::RAW_URL, HistoryAndBookmarkRow::URL_ID };
17
18 } // namespace
19
20 AndroidURLsSQLHandler::AndroidURLsSQLHandler(
21 AndroidURLsDatabase* android_urls_db)
22 : SQLHandler(kInterestingColumns, arraysize(kInterestingColumns)),
23 android_urls_db_(android_urls_db) {
24 }
25
26 AndroidURLsSQLHandler::~AndroidURLsSQLHandler() {
27 }
28
29 bool AndroidURLsSQLHandler::Update(const HistoryAndBookmarkRow& row,
30 const TableIDRows& ids_set) {
31 DCHECK(row.is_value_set_explicitly(HistoryAndBookmarkRow::URL_ID));
32 DCHECK(row.is_value_set_explicitly(HistoryAndBookmarkRow::RAW_URL));
33 if (ids_set.size() != 1)
34 return false;
35
36 AndroidURLRow android_url_row;
37 if (!android_urls_db_->GetAndroidURLRow(ids_set[0].url_id, &android_url_row))
38 return false;
39
40 return android_urls_db_->UpdateAndroidURLRow(android_url_row.id,
41 row.raw_url(), row.url_id());
42 }
43
44 bool AndroidURLsSQLHandler::Insert(HistoryAndBookmarkRow* row) {
45 AndroidURLID new_id =
46 android_urls_db_->AddAndroidURLRow(row->raw_url(), row->url_id());
47 row->set_id(new_id);
48 return new_id;
49 }
50
51 bool AndroidURLsSQLHandler::Delete(const TableIDRows& ids_set) {
52 std::vector<URLID> ids;
53 for (TableIDRows::const_iterator id = ids_set.begin();
54 id != ids_set.end(); ++id)
55 ids.push_back(id->url_id);
56
57 if (!ids.size())
58 return true;
59
60 return android_urls_db_->DeleteAndroidURLRows(ids);
61 }
62
63 } // namespace history.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698