// 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. #ifndef CHROME_BROWSER_ANDROID_HISTORY_REPORT_DATA_OBSERVER_H_ #define CHROME_BROWSER_ANDROID_HISTORY_REPORT_DATA_OBSERVER_H_ #include #include "base/callback.h" #include "base/macros.h" #include "base/time/time.h" #include "components/bookmarks/browser/bookmark_model_observer.h" #include "components/history/core/browser/history_service_observer.h" #include "components/history/core/browser/history_types.h" #include "components/history/core/browser/url_row.h" namespace history { class HistoryService; } namespace history_report { class DeltaFileService; class UsageReportsBufferService; // Observes history data for changes and updates delta file accordingly. class DataObserver : public bookmarks::BookmarkModelObserver, public history::HistoryServiceObserver { public: DataObserver(base::Callback data_changed_callback, base::Callback data_cleared_callback, base::Callback stop_reporting_callback, DeltaFileService* delta_file_service, UsageReportsBufferService* usage_reports_buffer_service, bookmarks::BookmarkModel* bookmark_model, history::HistoryService* history_service); ~DataObserver() override; // BookmarkModelObserver implementation. void BookmarkModelLoaded(bookmarks::BookmarkModel* model, bool ids_reassigned) override; void BookmarkModelBeingDeleted(bookmarks::BookmarkModel* model) override; void BookmarkNodeMoved(bookmarks::BookmarkModel* model, const bookmarks::BookmarkNode* old_parent, int old_index, const bookmarks::BookmarkNode* new_parent, int new_index) override; void BookmarkNodeAdded(bookmarks::BookmarkModel* model, const bookmarks::BookmarkNode* parent, int index) override; void BookmarkNodeRemoved(bookmarks::BookmarkModel* model, const bookmarks::BookmarkNode* parent, int old_index, const bookmarks::BookmarkNode* node, const std::set& removed_urls) override; void BookmarkAllUserNodesRemoved( bookmarks::BookmarkModel* model, const std::set& removed_urls) override; void BookmarkNodeChanged(bookmarks::BookmarkModel* model, const bookmarks::BookmarkNode* node) override; void BookmarkNodeFaviconChanged(bookmarks::BookmarkModel* model, const bookmarks::BookmarkNode* node) override; void BookmarkNodeChildrenReordered( bookmarks::BookmarkModel* model, const bookmarks::BookmarkNode* node) override; // HistoryServiceObserver implementation. void OnURLVisited(history::HistoryService* history_service, ui::PageTransition transition, const history::URLRow& row, const history::RedirectList& redirects, base::Time visit_time) override; void OnURLsModified(history::HistoryService* history_service, const history::URLRows& changed_urls) override; void OnURLsDeleted(history::HistoryService* history_service, bool all_history, bool expired, const history::URLRows& deleted_rows, const std::set& favicon_urls) override; private: void DeleteBookmarks(const std::set& removed_urls); base::Callback data_changed_callback_; base::Callback data_cleared_callback_; base::Callback stop_reporting_callback_; DeltaFileService* delta_file_service_; UsageReportsBufferService* usage_reports_buffer_service_; DISALLOW_COPY_AND_ASSIGN(DataObserver); }; } // namespace history_report #endif // CHROME_BROWSER_ANDROID_HISTORY_REPORT_DATA_OBSERVER_H_