#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/strings/string16.h"
+#include "base/task/cancelable_task_tracker.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "chrome/browser/common/cancelable_request.h"
#include "chrome/browser/history/history_types.h"
#include "chrome/browser/history/typed_url_syncable_service.h"
#include "chrome/browser/search_engines/template_url_id.h"
-#include "chrome/common/cancelable_task_tracker.h"
#include "chrome/common/ref_counted_util.h"
-#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
+#include "components/keyed_service/core/keyed_service.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"
#include "content/public/browser/download_manager_delegate.h"
#include "content/public/browser/notification_observer.h"
class HistoryService : public CancelableRequestProvider,
public content::NotificationObserver,
public syncer::SyncableService,
- public BrowserContextKeyedService,
+ public KeyedService,
public visitedlink::VisitedLinkDelegate {
public:
// Miscellaneous commonly-used types.
// Returns true if the backend has finished loading.
bool backend_loaded() const { return backend_loaded_; }
- // Unloads the backend without actually shutting down the history service.
- // This can be used to temporarily reduce the browser process' memory
- // footprint.
- void UnloadBackend();
-
// Called on shutdown, this will tell the history backend to complete and
// will release pointers to it. No other functions should be called once
// cleanup has happened that may dispatch to the history thread (because it
return in_memory_url_index_.get();
}
- // BrowserContextKeyedService:
+ // KeyedService:
virtual void Shutdown() OVERRIDE;
// Navigation ----------------------------------------------------------------
// Called when the results of QueryRedirectsFrom are available.
// The given vector will contain a list of all redirects, not counting
- // the original page. If A redirects to B, the vector will contain only B,
- // and A will be in 'source_url'.
+ // the original page. If A redirects to B which redirects to C, the vector
+ // will contain [B, C], and A will be in 'from_url'.
+ //
+ // For QueryRedirectsTo, the order is reversed. For A->B->C, the vector will
+ // contain [B, A] and C will be in 'to_url'.
//
// If there is no such URL in the database or the most recent visit has no
// redirect, the vector will be empty. If the history system failed for
// some reason, success will additionally be false. If the given page
// has redirected to multiple destinations, this will pick a random one.
typedef base::Callback<void(Handle,
- GURL, // from_url
+ GURL, // from_url / to_url
bool, // success
history::RedirectList*)> QueryRedirectsCallback;
base::Time begin_time,
base::Time end_time,
const base::Closure& callback,
- CancelableTaskTracker* tracker);
+ base::CancelableTaskTracker* tracker);
// Removes all visits to specified URLs in specific time ranges.
// This is the equivalent ExpireHistoryBetween() once for each element in the
// of ExpireHistoryBetween().
void ExpireHistory(const std::vector<history::ExpireHistoryArgs>& expire_list,
const base::Closure& callback,
- CancelableTaskTracker* tracker);
+ base::CancelableTaskTracker* tracker);
// Removes all visits to the given URLs in the specified time range. Calls
// ExpireHistoryBetween() to delete local visits, and handles deletion of
// synced visits if appropriate.
- void ExpireLocalAndRemoteHistoryBetween(
- const std::set<GURL>& restrict_urls,
- base::Time begin_time,
- base::Time end_time,
- const base::Closure& callback,
- CancelableTaskTracker* tracker);
+ void ExpireLocalAndRemoteHistoryBetween(const std::set<GURL>& restrict_urls,
+ base::Time begin_time,
+ base::Time end_time,
+ const base::Closure& callback,
+ base::CancelableTaskTracker* tracker);
// Processes the given |delete_directive| and sends it to the
// SyncChangeProcessor (if it exists). Returns any error resulting
// Broadcasts the given notification. This is called by the backend so that
// the notification will be broadcast on the main thread.
- //
- // Compared to BroadcastNotifications(), this function does not take
- // ownership of |details|.
- void BroadcastNotificationsHelper(int type,
- history::HistoryDetails* details);
-
- // Initializes the backend.
- void LoadBackendIfNecessary();
+ void BroadcastNotificationsHelper(
+ int type,
+ scoped_ptr<history::HistoryDetails> details);
// Notification from the backend that it has finished loading. Sends
// notification (NOTIFY_HISTORY_LOADED) and sets backend_loaded_ to true.
- void OnDBLoaded(int backend_id);
+ void OnDBLoaded();
// Helper function for getting URL information.
// Reads a URLRow from in-memory database. Returns false if database is not
// If |icon_types| has several types, results for only a single type will be
// returned in the priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, and
// FAVICON.
- CancelableTaskTracker::TaskId GetFavicons(
+ base::CancelableTaskTracker::TaskId GetFavicons(
const std::vector<GURL>& icon_urls,
int icon_types,
int desired_size_in_dip,
const std::vector<ui::ScaleFactor>& desired_scale_factors,
const FaviconService::FaviconResultsCallback& callback,
- CancelableTaskTracker* tracker);
+ base::CancelableTaskTracker* tracker);
// Used by the FaviconService to get favicons mapped to |page_url| for
// |icon_types| which most closely match |desired_size_in_dip| and
// there will be less results. If |icon_types| has several types, results for
// only a single type will be returned in the priority of
// TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, and FAVICON.
- CancelableTaskTracker::TaskId GetFaviconsForURL(
+ base::CancelableTaskTracker::TaskId GetFaviconsForURL(
const GURL& page_url,
int icon_types,
int desired_size_in_dip,
const std::vector<ui::ScaleFactor>& desired_scale_factors,
const FaviconService::FaviconResultsCallback& callback,
- CancelableTaskTracker* tracker);
+ base::CancelableTaskTracker* tracker);
// Used by FaviconService to find the first favicon bitmap whose width and
// height are greater than that of |minimum_size_in_pixels|. This searches
// icon types in |icon_types| is returned.
// This feature is especially useful when some types of icon is perfered as
// long as its size is larger than a specific value.
- CancelableTaskTracker::TaskId GetLargestFaviconForURL(
+ base::CancelableTaskTracker::TaskId GetLargestFaviconForURL(
const GURL& page_url,
const std::vector<int>& icon_types,
int minimum_size_in_pixels,
const FaviconService::FaviconRawCallback& callback,
- CancelableTaskTracker* tracker);
+ base::CancelableTaskTracker* tracker);
// Used by the FaviconService to get the favicon bitmap which most closely
// matches |desired_size_in_dip| and |desired_scale_factor| from the favicon
// with |favicon_id| from the history backend. If |desired_size_in_dip| is 0,
// the largest favicon bitmap for |favicon_id| is returned.
- CancelableTaskTracker::TaskId GetFaviconForID(
- chrome::FaviconID favicon_id,
+ base::CancelableTaskTracker::TaskId GetFaviconForID(
+ favicon_base::FaviconID favicon_id,
int desired_size_in_dip,
ui::ScaleFactor desired_scale_factor,
const FaviconService::FaviconResultsCallback& callback,
- CancelableTaskTracker* tracker);
+ base::CancelableTaskTracker* tracker);
// Used by the FaviconService to replace the favicon mappings to |page_url|
// for |icon_types| on the history backend.
// and |desired_scale_factors| from the favicons which were just mapped
// to |page_url| are returned. If |desired_size_in_dip| is 0, the
// largest favicon bitmap is returned.
- CancelableTaskTracker::TaskId UpdateFaviconMappingsAndFetch(
+ base::CancelableTaskTracker::TaskId UpdateFaviconMappingsAndFetch(
const GURL& page_url,
const std::vector<GURL>& icon_urls,
int icon_types,
int desired_size_in_dip,
const std::vector<ui::ScaleFactor>& desired_scale_factors,
const FaviconService::FaviconResultsCallback& callback,
- CancelableTaskTracker* tracker);
+ base::CancelableTaskTracker* tracker);
// Used by FaviconService to set a favicon for |page_url| and |icon_url| with
// |pixel_size|.
// TODO(pkotwicz): Remove once no longer required by sync.
void MergeFavicon(const GURL& page_url,
const GURL& icon_url,
- chrome::IconType icon_type,
+ favicon_base::IconType icon_type,
scoped_refptr<base::RefCountedMemory> bitmap_data,
const gfx::Size& pixel_size);
// criteria for |favicon_bitmap_data| to be valid.
void SetFavicons(
const GURL& page_url,
- chrome::IconType icon_type,
- const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data);
+ favicon_base::IconType icon_type,
+ const std::vector<favicon_base::FaviconBitmapData>& favicon_bitmap_data);
// Used by the FaviconService to mark the favicon for the page as being out
// of date.
// Sets the in-memory URL database. This is called by the backend once the
// database is loaded to make it available.
void SetInMemoryBackend(
- int backend_id,
scoped_ptr<history::InMemoryHistoryBackend> mem_backend);
// Called by our BackendDelegate when there is a problem reading the database.
- void NotifyProfileError(int backend_id, sql::InitStatus init_status);
+ void NotifyProfileError(sql::InitStatus init_status);
// Call to schedule a given task for running on the history thread with the
// specified priority. The task will have ownership taken.
RequestType* request) {
DCHECK(thread_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
- LoadBackendIfNecessary();
if (consumer)
AddRequest(request, consumer);
ScheduleTask(priority,
const ArgA& a) {
DCHECK(thread_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
- LoadBackendIfNecessary();
if (consumer)
AddRequest(request, consumer);
ScheduleTask(priority,
const ArgB& b) {
DCHECK(thread_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
- LoadBackendIfNecessary();
if (consumer)
AddRequest(request, consumer);
ScheduleTask(priority,
const ArgC& c) {
DCHECK(thread_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
- LoadBackendIfNecessary();
if (consumer)
AddRequest(request, consumer);
ScheduleTask(priority,
const ArgD& d) {
DCHECK(thread_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
- LoadBackendIfNecessary();
if (consumer)
AddRequest(request, consumer);
ScheduleTask(priority,
BackendFunc func) { // Function to call on backend.
DCHECK(thread_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
- LoadBackendIfNecessary();
ScheduleTask(priority, base::Bind(func, history_backend_.get()));
}
const ArgA& a) {
DCHECK(thread_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
- LoadBackendIfNecessary();
ScheduleTask(priority, base::Bind(func, history_backend_.get(), a));
}
const ArgB& b) {
DCHECK(thread_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
- LoadBackendIfNecessary();
ScheduleTask(priority, base::Bind(func, history_backend_.get(), a, b));
}
const ArgC& c) {
DCHECK(thread_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
- LoadBackendIfNecessary();
ScheduleTask(priority, base::Bind(func, history_backend_.get(), a, b, c));
}
const ArgD& d) {
DCHECK(thread_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
- LoadBackendIfNecessary();
ScheduleTask(priority, base::Bind(func, history_backend_.get(),
a, b, c, d));
}
const ArgE& e) {
DCHECK(thread_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
- LoadBackendIfNecessary();
ScheduleTask(priority, base::Bind(func, history_backend_.get(),
a, b, c, d, e));
}
// completed.
bool backend_loaded_;
- // The id of the current backend. This is only valid when history_backend_
- // is not NULL.
- int current_backend_id_;
-
// Cached values from Init(), used whenever we need to reload the backend.
base::FilePath history_dir_;
BookmarkService* bookmark_service_;