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

Side by Side Diff: chrome/browser/history/history_service.h

Issue 484213002: Refactor HistoryService to not send NOTIFICATION_FAVICON_CHANGED (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix android unit tests Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_
6 #define CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ 6 #define CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/callback_list.h"
14 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
19 #include "base/observer_list.h" 20 #include "base/observer_list.h"
20 #include "base/strings/string16.h" 21 #include "base/strings/string16.h"
21 #include "base/task/cancelable_task_tracker.h" 22 #include "base/task/cancelable_task_tracker.h"
22 #include "base/threading/thread_checker.h" 23 #include "base/threading/thread_checker.h"
23 #include "base/time/time.h" 24 #include "base/time/time.h"
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // HistoryDBTask for details on what this does. Takes ownership of |task|. 436 // HistoryDBTask for details on what this does. Takes ownership of |task|.
436 virtual void ScheduleDBTask(scoped_ptr<history::HistoryDBTask> task, 437 virtual void ScheduleDBTask(scoped_ptr<history::HistoryDBTask> task,
437 base::CancelableTaskTracker* tracker); 438 base::CancelableTaskTracker* tracker);
438 439
439 // Adds or removes observers for the VisitDatabase. 440 // Adds or removes observers for the VisitDatabase.
440 void AddVisitDatabaseObserver(history::VisitDatabaseObserver* observer); 441 void AddVisitDatabaseObserver(history::VisitDatabaseObserver* observer);
441 void RemoveVisitDatabaseObserver(history::VisitDatabaseObserver* observer); 442 void RemoveVisitDatabaseObserver(history::VisitDatabaseObserver* observer);
442 443
443 void NotifyVisitDBObserversOnAddVisit(const history::BriefVisitInfo& info); 444 void NotifyVisitDBObserversOnAddVisit(const history::BriefVisitInfo& info);
444 445
446 // This callback is invoked when favicon change for urls.
447 typedef base::Callback<void(const std::set<GURL>&)> OnFaviconChangedCallback;
448
449 // Add a callback to the list. The callback will remain registered until the
450 // returned Subscription is destroyed. This must occurs before HistoryService
451 // is destroyed.
452 scoped_ptr<base::CallbackList<void(const std::set<GURL>&)>::Subscription>
453 AddFaviconChangedCallback(const OnFaviconChangedCallback& callback)
454 WARN_UNUSED_RESULT;
455
445 // Testing ------------------------------------------------------------------- 456 // Testing -------------------------------------------------------------------
446 457
447 // Runs |flushed| after bouncing off the history thread. 458 // Runs |flushed| after bouncing off the history thread.
448 void FlushForTest(const base::Closure& flushed); 459 void FlushForTest(const base::Closure& flushed);
449 460
450 // Designed for unit tests, this passes the given task on to the history 461 // Designed for unit tests, this passes the given task on to the history
451 // backend to be called once the history backend has terminated. This allows 462 // backend to be called once the history backend has terminated. This allows
452 // callers to know when the history thread is complete and the database files 463 // callers to know when the history thread is complete and the database files
453 // can be deleted and the next test run. Otherwise, the history thread may 464 // can be deleted and the next test run. Otherwise, the history thread may
454 // still be running, causing problems in subsequent tests. 465 // still be running, causing problems in subsequent tests.
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 void SetInMemoryBackend( 738 void SetInMemoryBackend(
728 scoped_ptr<history::InMemoryHistoryBackend> mem_backend); 739 scoped_ptr<history::InMemoryHistoryBackend> mem_backend);
729 740
730 // Called by our BackendDelegate when there is a problem reading the database. 741 // Called by our BackendDelegate when there is a problem reading the database.
731 void NotifyProfileError(sql::InitStatus init_status); 742 void NotifyProfileError(sql::InitStatus init_status);
732 743
733 // Call to schedule a given task for running on the history thread with the 744 // Call to schedule a given task for running on the history thread with the
734 // specified priority. The task will have ownership taken. 745 // specified priority. The task will have ownership taken.
735 void ScheduleTask(SchedulePriority priority, const base::Closure& task); 746 void ScheduleTask(SchedulePriority priority, const base::Closure& task);
736 747
748 // Invokes all callback registered by AddFaviconChangedCallback.
749 void NotifyFaviconChanged(const std::set<GURL>& changed_favicons);
750
737 // ScheduleAndForget --------------------------------------------------------- 751 // ScheduleAndForget ---------------------------------------------------------
738 // 752 //
739 // Functions for scheduling operations on the history thread that do not need 753 // Functions for scheduling operations on the history thread that do not need
740 // any callbacks and are not cancelable. 754 // any callbacks and are not cancelable.
741 755
742 template<typename BackendFunc> 756 template<typename BackendFunc>
743 void ScheduleAndForget(SchedulePriority priority, 757 void ScheduleAndForget(SchedulePriority priority,
744 BackendFunc func) { // Function to call on backend. 758 BackendFunc func) { // Function to call on backend.
745 DCHECK(thread_) << "History service being called after cleanup"; 759 DCHECK(thread_) << "History service being called after cleanup";
746 DCHECK(thread_checker_.CalledOnValidThread()); 760 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 base::FilePath history_dir_; 871 base::FilePath history_dir_;
858 bool no_db_; 872 bool no_db_;
859 873
860 // The index used for quick history lookups. 874 // The index used for quick history lookups.
861 // TODO(mrossetti): Move in_memory_url_index out of history_service. 875 // TODO(mrossetti): Move in_memory_url_index out of history_service.
862 // See http://crbug.com/138321 876 // See http://crbug.com/138321
863 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; 877 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_;
864 878
865 ObserverList<history::VisitDatabaseObserver> visit_database_observers_; 879 ObserverList<history::VisitDatabaseObserver> visit_database_observers_;
866 880
881 base::CallbackList<void(const std::set<GURL>&)>
882 favicon_changed_callback_list_;
883
867 history::DeleteDirectiveHandler delete_directive_handler_; 884 history::DeleteDirectiveHandler delete_directive_handler_;
868 885
869 DISALLOW_COPY_AND_ASSIGN(HistoryService); 886 DISALLOW_COPY_AND_ASSIGN(HistoryService);
870 }; 887 };
871 888
872 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ 889 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend_unittest.cc ('k') | chrome/browser/history/history_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698