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

Unified Diff: chrome/browser/history/history_backend_android.cc

Issue 10217010: Completed the code path from AndroidProviderService to HistoryBackend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | chrome/browser/history/history_marshaling.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/history_backend_android.cc
diff --git a/chrome/browser/history/history_backend_android.cc b/chrome/browser/history/history_backend_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..763f70cdf65a6470572a4f12c67485e840dd2e33
--- /dev/null
+++ b/chrome/browser/history/history_backend_android.cc
@@ -0,0 +1,183 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/history/history_backend.h"
+
+#include "chrome/browser/history/android/android_provider_backend.h"
+
+namespace history {
+
+void HistoryBackend::InsertHistoryAndBookmark(
+ scoped_refptr<InsertRequest> request,
+ const HistoryAndBookmarkRow& row) {
+ if (request->canceled())
+ return;
+
+ AndroidURLID id = 0;
+ if (android_provider_backend_.get())
+ id = android_provider_backend_->InsertHistoryAndBookmark(row);
+
+ request->ForwardResult(request->handle(), id != 0, id);
+}
+
+void HistoryBackend::QueryHistoryAndBookmarks(
+ scoped_refptr<QueryRequest> request,
+ const std::vector<HistoryAndBookmarkRow::ColumnID>& projections,
+ const std::string& selection,
+ const std::vector<string16>& selection_args,
+ const std::string& sort_order) {
+ if (request->canceled())
+ return;
+
+ AndroidStatement* statement = NULL;
+ if (android_provider_backend_.get()) {
+ statement = android_provider_backend_->QueryHistoryAndBookmarks(
+ projections, selection, selection_args, sort_order);
+ }
+ request->ForwardResult(request->handle(), statement, statement);
+}
+
+void HistoryBackend::UpdateHistoryAndBookmarks(
+ scoped_refptr<UpdateRequest> request,
+ const HistoryAndBookmarkRow& row,
+ const std::string& selection,
+ const std::vector<string16>& selection_args) {
+ if (request->canceled())
+ return;
+
+ int count = 0;
+ bool result = false;
+ if (android_provider_backend_.get()) {
+ result = android_provider_backend_->UpdateHistoryAndBookmarks(row,
+ selection, selection_args, &count);
+ }
+
+ request->ForwardResult(request->handle(), result, count);
+}
+
+void HistoryBackend::DeleteHistoryAndBookmarks(
+ scoped_refptr<DeleteRequest> request,
+ const std::string& selection,
+ const std::vector<string16>& selection_args) {
+ if (request->canceled())
+ return;
+
+ int count = 0;
+ bool result = false;
+ if (android_provider_backend_.get())
+ result = android_provider_backend_->DeleteHistoryAndBookmarks(selection,
+ selection_args, &count);
+
+ request->ForwardResult(request->handle(), result, count);
+}
+
+void HistoryBackend::DeleteHistory(
+ scoped_refptr<DeleteRequest> request,
+ const std::string& selection,
+ const std::vector<string16>& selection_args) {
+ if (request->canceled())
+ return;
+
+ int count = 0;
+ bool result = false;
+ if (android_provider_backend_.get()) {
+ result = android_provider_backend_->DeleteHistory(selection, selection_args,
+ &count);
+ }
+ request->ForwardResult(request->handle(), result, count);
+}
+
+// Statement -------------------------------------------------------------------
+
+void HistoryBackend::MoveStatement(
+ scoped_refptr<MoveStatementRequest> request,
+ history::AndroidStatement* statement,
+ int current_pos,
+ int destination) {
+ DCHECK_LE(-1, current_pos);
+ DCHECK_LE(-1, destination);
+
+ int cur = current_pos;
+ if (current_pos > destination) {
+ statement->statement()->Reset(false);
+ cur = -1;
+ }
+ for (; cur < destination; ++cur) {
+ if (!statement->statement()->Step())
+ break;
+ }
+
+ request->ForwardResult(request->handle(), cur);
+}
+
+void HistoryBackend::CloseStatement(AndroidStatement* statement) {
+ delete statement;
+}
+
+// Search Term -----------------------------------------------------------------
+
+void HistoryBackend::InsertSearchTerm(scoped_refptr<InsertRequest> request,
+ const SearchRow& row) {
+ if (request->canceled())
+ return;
+
+ SearchTermID id = 0;
+ if (android_provider_backend_.get())
+ id = android_provider_backend_->InsertSearchTerm(row);
+
+ request->ForwardResult(request->handle(), id != 0, id);
+}
+
+void HistoryBackend::UpdateSearchTerms(
+ scoped_refptr<UpdateRequest> request,
+ const SearchRow& row,
+ const std::string& selection,
+ const std::vector<string16> selection_args) {
+ if (request->canceled())
+ return;
+
+ int count = 0;
+ bool result = false;
+ if (android_provider_backend_.get()) {
+ result = android_provider_backend_->UpdateSearchTerms(row, selection,
+ selection_args, &count);
+ }
+ request->ForwardResult(request->handle(), result, count);
+}
+
+void HistoryBackend::DeleteSearchTerms(
+ scoped_refptr<DeleteRequest> request,
+ const std::string& selection,
+ const std::vector<string16> selection_args) {
+ if (request->canceled())
+ return;
+
+ int count = 0;
+ bool result = false;
+ if (android_provider_backend_.get()) {
+ result = android_provider_backend_->DeleteSearchTerms(selection,
+ selection_args, &count);
+ }
+
+ request->ForwardResult(request->handle(), result, count);
+}
+
+void HistoryBackend::QuerySearchTerms(
+ scoped_refptr<QueryRequest> request,
+ const std::vector<SearchRow::ColumnID>& projections,
+ const std::string& selection,
+ const std::vector<string16>& selection_args,
+ const std::string& sort_order) {
+ if (request->canceled())
+ return;
+
+ AndroidStatement* statement = NULL;
+ if (android_provider_backend_.get())
+ statement = android_provider_backend_->QuerySearchTerms(projections,
+ selection, selection_args, sort_order);
+
+ request->ForwardResult(request->handle(), statement, statement);
+}
+
+} // namespace history
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | chrome/browser/history/history_marshaling.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698