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

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

Issue 901803005: Remove dependency of HistoryService on WebHistoryServiceFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@DEPS
Patch Set: Created 5 years, 10 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/history_utils.cc
diff --git a/chrome/browser/history/history_utils.cc b/chrome/browser/history/history_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..24af0a161a42701f3d53a74074d5b807965adddd
--- /dev/null
+++ b/chrome/browser/history/history_utils.cc
@@ -0,0 +1,60 @@
+// Copyright 2015 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_utils.h"
+
+#include "base/callback.h"
+#include "base/logging.h"
+#include "base/task/cancelable_task_tracker.h"
+#include "base/time/time.h"
+#include "chrome/browser/history/delete_directive_handler.h"
+#include "chrome/browser/history/history_service.h"
+#include "chrome/browser/history/web_history_service.h"
+
+namespace history {
+namespace {
+
+// Callback for WebHistoryService::ExpireWebHistory().
+void ExpireWebHistoryComplete(bool success) {
+ // Ignore the result.
+ //
+ // TODO(davidben): ExpireLocalAndRemoteHistoryBetween callback should not fire
+ // until this completes.
+}
+
+} // namespace
+
+void ExpireLocalAndRemoteHistoryBetween(HistoryService* local_history,
+ WebHistoryService* web_history,
+ const std::set<GURL>& restrict_urls,
+ base::Time begin_time,
+ base::Time end_time,
+ const base::Closure& callback,
+ base::CancelableTaskTracker* tracker) {
+ DCHECK(local_history);
+
+ // TODO(dubroy): This should be factored out into a separate class that
+ // dispatches deletions to the proper places.
+
+ if (web_history) {
+ // TODO(dubroy): This API does not yet support deletion of specific URLs.
+ DCHECK(restrict_urls.empty());
+
+ local_history->delete_directive_handler_.CreateDeleteDirectives(
+ std::set<int64>(), begin_time, end_time);
+
+ // Attempt online deletion from the history server, but ignore the result.
+ // Deletion directives ensure that the results will eventually be deleted.
+ //
+ // TODO(davidben): |callback| should not run until this operation completes
+ // too.
+ web_history->ExpireHistoryBetween(restrict_urls, begin_time, end_time,
+ base::Bind(&ExpireWebHistoryComplete));
+ }
+
+ local_history->ExpireHistoryBetween(restrict_urls, begin_time, end_time,
+ callback, tracker);
+}
+
+} // namespace history

Powered by Google App Engine
This is Rietveld 408576698