1 // Copyright 2015 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.
5 #ifndef CHROME_BROWSER_ANDROID_HISTORY_REPORT_DATA_OBSERVER_H_
6 #define CHROME_BROWSER_ANDROID_HISTORY_REPORT_DATA_OBSERVER_H_
10 #include "base/callback.h"
11 #include "base/time/time.h"
12 #include "components/bookmarks/browser/bookmark_model_observer.h"
13 #include "components/history/core/browser/history_service_observer.h"
14 #include "components/history/core/browser/history_types.h"
15 #include "components/history/core/browser/url_row.h"
22 namespace history_report
{
24 class DeltaFileService
;
25 class UsageReportsBufferService
;
27 // Observes history data for changes and updates delta file accordingly.
28 class DataObserver
: public bookmarks::BookmarkModelObserver
,
29 public history::HistoryServiceObserver
{
31 DataObserver(base::Callback
<void(void)> data_changed_callback
,
32 base::Callback
<void(void)> data_cleared_callback
,
33 base::Callback
<void(void)> stop_reporting_callback
,
34 DeltaFileService
* delta_file_service
,
35 UsageReportsBufferService
* usage_reports_buffer_service
,
36 bookmarks::BookmarkModel
* bookmark_model
,
37 history::HistoryService
* history_service
);
38 ~DataObserver() override
;
40 // BookmarkModelObserver implementation.
41 void BookmarkModelLoaded(bookmarks::BookmarkModel
* model
,
42 bool ids_reassigned
) override
;
43 void BookmarkModelBeingDeleted(bookmarks::BookmarkModel
* model
) override
;
44 void BookmarkNodeMoved(bookmarks::BookmarkModel
* model
,
45 const bookmarks::BookmarkNode
* old_parent
,
47 const bookmarks::BookmarkNode
* new_parent
,
48 int new_index
) override
;
49 void BookmarkNodeAdded(bookmarks::BookmarkModel
* model
,
50 const bookmarks::BookmarkNode
* parent
,
52 void BookmarkNodeRemoved(bookmarks::BookmarkModel
* model
,
53 const bookmarks::BookmarkNode
* parent
,
55 const bookmarks::BookmarkNode
* node
,
56 const std::set
<GURL
>& removed_urls
) override
;
57 void BookmarkAllUserNodesRemoved(
58 bookmarks::BookmarkModel
* model
,
59 const std::set
<GURL
>& removed_urls
) override
;
60 void BookmarkNodeChanged(bookmarks::BookmarkModel
* model
,
61 const bookmarks::BookmarkNode
* node
) override
;
62 void BookmarkNodeFaviconChanged(bookmarks::BookmarkModel
* model
,
63 const bookmarks::BookmarkNode
* node
) override
;
64 void BookmarkNodeChildrenReordered(
65 bookmarks::BookmarkModel
* model
,
66 const bookmarks::BookmarkNode
* node
) override
;
68 // HistoryServiceObserver implementation.
69 void OnURLVisited(history::HistoryService
* history_service
,
70 ui::PageTransition transition
,
71 const history::URLRow
& row
,
72 const history::RedirectList
& redirects
,
73 base::Time visit_time
) override
;
74 void OnURLsModified(history::HistoryService
* history_service
,
75 const history::URLRows
& changed_urls
) override
;
76 void OnURLsDeleted(history::HistoryService
* history_service
,
79 const history::URLRows
& deleted_rows
,
80 const std::set
<GURL
>& favicon_urls
) override
;
83 void DeleteBookmarks(const std::set
<GURL
>& removed_urls
);
85 base::Callback
<void(void)> data_changed_callback_
;
86 base::Callback
<void(void)> data_cleared_callback_
;
87 base::Callback
<void(void)> stop_reporting_callback_
;
88 DeltaFileService
* delta_file_service_
;
89 UsageReportsBufferService
* usage_reports_buffer_service_
;
91 DISALLOW_COPY_AND_ASSIGN(DataObserver
);
94 } // namespace history_report
96 #endif // CHROME_BROWSER_ANDROID_HISTORY_REPORT_DATA_OBSERVER_H_