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

Unified Diff: chrome/browser/history/android/android_history_provider_service.cc

Issue 10217010: Completed the code path from AndroidProviderService to HistoryBackend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address the comments 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
Index: chrome/browser/history/android/android_history_provider_service.cc
diff --git a/chrome/browser/history/android/android_history_provider_service.cc b/chrome/browser/history/android/android_history_provider_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e70667cc10146bcd8122d054fb31378f00288aae
--- /dev/null
+++ b/chrome/browser/history/android/android_history_provider_service.cc
@@ -0,0 +1,171 @@
+// 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/android/android_history_provider_service.h"
+
+#include "chrome/browser/history/history.h"
+#include "chrome/browser/profiles/profile.h"
+
+AndroidHistoryProviderService::AndroidHistoryProviderService(Profile* profile)
+ : profile_(profile) {
+}
+
+AndroidHistoryProviderService::~AndroidHistoryProviderService() {
+}
+
+void AndroidHistoryProviderService::QueryHistoryAndBookmarks(
+ const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections,
+ const std::string selection,
+ const std::vector<string16>& selection_args,
+ const std::string sort_order,
+ CancelableRequestConsumerBase* consumer,
+ const QueryCallback& callback) {
+ QueryRequest* request = new QueryRequest(callback);
+ AddRequest(request, consumer);
+ HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
+ if (hs) {
+ hs->QueryHistoryAndBookmarks(request, projections, selection,
+ selection_args, sort_order);
+ } else {
+ request->ForwardResultAsync(request->handle(), false, 0);
+ }
+}
+
+void AndroidHistoryProviderService::UpdateHistoryAndBookmarks(
+ const history::HistoryAndBookmarkRow& row,
+ const std::string& selection,
+ const std::vector<string16>& selection_args,
+ CancelableRequestConsumerBase* consumer,
+ const UpdateCallback& callback) {
+ UpdateRequest* request = new UpdateRequest(callback);
+ AddRequest(request, consumer);
+ HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
+ if (hs)
+ hs->UpdateHistoryAndBookmarks(request, row, selection, selection_args);
+ else
+ request->ForwardResultAsync(request->handle(), false, 0);
+}
+
+void AndroidHistoryProviderService::DeleteHistoryAndBookmarks(
+ const std::string& selection,
+ const std::vector<string16>& selection_args,
+ CancelableRequestConsumerBase* consumer,
+ const DeleteCallback& callback) {
+ DeleteRequest* request = new DeleteRequest(callback);
+ AddRequest(request, consumer);
+ HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
+ if (hs)
+ hs->DeleteHistoryAndBookmarks(request, selection, selection_args);
+ else
+ request->ForwardResultAsync(request->handle(), false, 0);
+}
+
+void AndroidHistoryProviderService::InsertHistoryAndBookmark(
+ const history::HistoryAndBookmarkRow& values,
+ CancelableRequestConsumerBase* consumer,
+ const InsertCallback& callback) {
+ InsertRequest* request = new InsertRequest(callback);
+ AddRequest(request, consumer);
+ HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
+ if (hs)
+ hs->InsertHistoryAndBookmark(request, values);
+ else
+ request->ForwardResultAsync(request->handle(), false, 0);
+}
+
+void AndroidHistoryProviderService::DeleteHistory(
+ const std::string& selection,
+ const std::vector<string16>& selection_args,
+ CancelableRequestConsumerBase* consumer,
+ const DeleteCallback& callback) {
+ DeleteRequest* request = new DeleteRequest(callback);
+ AddRequest(request, consumer);
+ HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
+ if (hs)
+ hs->DeleteHistory(request, selection, selection_args);
+ else
+ request->ForwardResultAsync(request->handle(), false, 0);
+}
+
+void AndroidHistoryProviderService::MoveStatement(
+ history::AndroidStatement* statement,
+ int current_pos,
+ int destination,
+ CancelableRequestConsumerBase* consumer,
+ const MoveStatementCallback& callback) {
+ MoveStatementRequest* request = new MoveStatementRequest(callback);
+ AddRequest(request, consumer);
+ HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
+ if (hs)
+ hs->MoveStatement(request, statement, current_pos, destination);
+ else
+ request->ForwardResultAsync(request->handle(), current_pos);
+}
+
+void AndroidHistoryProviderService::CloseStatement(
+ history::AndroidStatement* statement) {
+ HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
+ if (hs)
+ hs->CloseStatement(statement);
+}
sky 2012/04/27 21:37:22 This leaks if hs is NULL.
michaelbai 2012/04/27 23:26:04 Done.
+
+void AndroidHistoryProviderService::InsertSearchTerm(
+ const history::SearchRow& row,
+ CancelableRequestConsumerBase* consumer,
+ const InsertCallback& callback) {
+ InsertRequest* request = new InsertRequest(callback);
+ AddRequest(request, consumer);
+ HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
+ if (hs)
+ hs->InsertSearchTerm(request, row);
+ else
+ request->ForwardResultAsync(request->handle(), false, 0);
+}
+
+void AndroidHistoryProviderService::UpdateSearchTerms(
+ const history::SearchRow& row,
+ const std::string& selection,
+ const std::vector<string16>& selection_args,
+ CancelableRequestConsumerBase* consumer,
+ const UpdateCallback& callback) {
+ UpdateRequest* request = new UpdateRequest(callback);
+ AddRequest(request, consumer);
+ HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
+ if (hs)
+ hs->UpdateSearchTerms(request, row, selection, selection_args);
+ else
+ request->ForwardResultAsync(request->handle(), false, 0);
+}
+
+void AndroidHistoryProviderService::DeleteSearchTerms(
+ const std::string& selection,
+ const std::vector<string16>& selection_args,
+ CancelableRequestConsumerBase* consumer,
+ const DeleteCallback& callback) {
+ DeleteRequest* request = new DeleteRequest(callback);
+ AddRequest(request, consumer);
+ HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
+ if (hs)
+ hs->DeleteSearchTerms(request, selection, selection_args);
+ else
+ request->ForwardResultAsync(request->handle(), false, 0);
+}
+
+void AndroidHistoryProviderService::QuerySearchTerms(
+ const std::vector<history::SearchRow::ColumnID>& projections,
+ const std::string selection,
+ const std::vector<string16>& selection_args,
+ const std::string sort_order,
+ CancelableRequestConsumerBase* consumer,
+ const QueryCallback& callback) {
+ QueryRequest* request = new QueryRequest(callback);
+ AddRequest(request, consumer);
+ HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
+ if (hs) {
+ hs->QuerySearchTerms(request, projections, selection, selection_args,
+ sort_order);
+ } else {
+ request->ForwardResultAsync(request->handle(), false, 0);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698