OLD | NEW |
| (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/history_backend.h" | |
6 | |
7 #include "chrome/browser/history/android/android_provider_backend.h" | |
8 | |
9 namespace history { | |
10 | |
11 AndroidURLID HistoryBackend::InsertHistoryAndBookmark( | |
12 const HistoryAndBookmarkRow& row) { | |
13 AndroidURLID id = 0; | |
14 if (android_provider_backend_) | |
15 id = android_provider_backend_->InsertHistoryAndBookmark(row); | |
16 return id; | |
17 } | |
18 | |
19 AndroidStatement* HistoryBackend::QueryHistoryAndBookmarks( | |
20 const std::vector<HistoryAndBookmarkRow::ColumnID>& projections, | |
21 const std::string& selection, | |
22 const std::vector<base::string16>& selection_args, | |
23 const std::string& sort_order) { | |
24 AndroidStatement* statement = NULL; | |
25 if (android_provider_backend_) { | |
26 statement = android_provider_backend_->QueryHistoryAndBookmarks( | |
27 projections, selection, selection_args, sort_order); | |
28 } | |
29 return statement; | |
30 } | |
31 | |
32 int HistoryBackend::UpdateHistoryAndBookmarks( | |
33 const HistoryAndBookmarkRow& row, | |
34 const std::string& selection, | |
35 const std::vector<base::string16>& selection_args) { | |
36 int count = 0; | |
37 if (android_provider_backend_) { | |
38 android_provider_backend_->UpdateHistoryAndBookmarks( | |
39 row, selection, selection_args, &count); | |
40 } | |
41 return count; | |
42 } | |
43 | |
44 int HistoryBackend::DeleteHistoryAndBookmarks( | |
45 const std::string& selection, | |
46 const std::vector<base::string16>& selection_args) { | |
47 int count = 0; | |
48 if (android_provider_backend_) { | |
49 android_provider_backend_->DeleteHistoryAndBookmarks( | |
50 selection, selection_args, &count); | |
51 } | |
52 return count; | |
53 } | |
54 | |
55 int HistoryBackend::DeleteHistory( | |
56 const std::string& selection, | |
57 const std::vector<base::string16>& selection_args) { | |
58 int count = 0; | |
59 if (android_provider_backend_) { | |
60 android_provider_backend_->DeleteHistory(selection, selection_args, &count); | |
61 } | |
62 return count; | |
63 } | |
64 | |
65 // Statement ------------------------------------------------------------------- | |
66 | |
67 int HistoryBackend::MoveStatement(history::AndroidStatement* statement, | |
68 int current_pos, | |
69 int destination) { | |
70 DCHECK_LE(-1, current_pos); | |
71 DCHECK_LE(-1, destination); | |
72 | |
73 int cur = current_pos; | |
74 if (current_pos > destination) { | |
75 statement->statement()->Reset(false); | |
76 cur = -1; | |
77 } | |
78 for (; cur < destination; ++cur) { | |
79 if (!statement->statement()->Step()) | |
80 break; | |
81 } | |
82 | |
83 return cur; | |
84 } | |
85 | |
86 void HistoryBackend::CloseStatement(AndroidStatement* statement) { | |
87 delete statement; | |
88 } | |
89 | |
90 // Search Term ----------------------------------------------------------------- | |
91 | |
92 SearchTermID HistoryBackend::InsertSearchTerm(const SearchRow& row) { | |
93 SearchTermID id = 0; | |
94 if (android_provider_backend_) | |
95 id = android_provider_backend_->InsertSearchTerm(row); | |
96 return id; | |
97 } | |
98 | |
99 int HistoryBackend::UpdateSearchTerms( | |
100 const SearchRow& row, | |
101 const std::string& selection, | |
102 const std::vector<base::string16> selection_args) { | |
103 int count = 0; | |
104 if (android_provider_backend_) { | |
105 android_provider_backend_->UpdateSearchTerms( | |
106 row, selection, selection_args, &count); | |
107 } | |
108 return count; | |
109 } | |
110 | |
111 int HistoryBackend::DeleteSearchTerms( | |
112 const std::string& selection, | |
113 const std::vector<base::string16> selection_args) { | |
114 int count = 0; | |
115 if (android_provider_backend_) { | |
116 android_provider_backend_->DeleteSearchTerms( | |
117 selection, selection_args, &count); | |
118 } | |
119 return count; | |
120 } | |
121 | |
122 AndroidStatement* HistoryBackend::QuerySearchTerms( | |
123 const std::vector<SearchRow::ColumnID>& projections, | |
124 const std::string& selection, | |
125 const std::vector<base::string16>& selection_args, | |
126 const std::string& sort_order) { | |
127 AndroidStatement* statement = NULL; | |
128 if (android_provider_backend_) { | |
129 statement = android_provider_backend_->QuerySearchTerms(projections, | |
130 selection, selection_args, sort_order); | |
131 } | |
132 return statement; | |
133 } | |
134 | |
135 } // namespace history | |
OLD | NEW |