15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <set>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <utility>
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <vector>
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/containers/mru_cache.h"
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/files/file_path.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/gtest_prod_util.h"
16ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "base/memory/memory_pressure_listener.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/history/archived_database.h"
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/history/expire_history_backend.h"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/history/history_database.h"
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/history/history_marshaling.h"
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/history/history_types.h"
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/history/thumbnail_database.h"
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/history/visit_tracker.h"
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/search_engines/template_url_id.h"
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "sql/init_status.h"
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/layout.h"
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BookmarkService;
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TestingProfile;
31b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)class TypedUrlSyncableService;
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct ThumbnailScore;
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace history {
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID)
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class AndroidProviderBackend;
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CommitLaterTask;
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class HistoryPublisher;
41c6a03b665d27bf9b307170479657cbbf1b5bfe17Torne (Richard Coles)class PageCollector;
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class VisitFilter;
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct DownloadRow;
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The maximum number of icons URLs per page which can be stored in the
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// thumbnail database.
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)static const size_t kMaxFaviconsPerPage = 8;
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The maximum number of bitmaps for a single icon URL which can be stored in
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the thumbnail database.
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)static const size_t kMaxFaviconBitmapsPerIconURL = 8;
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// *See the .cc file for more information on the design.*
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Internal history implementation which does most of the work of the history
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// system. This runs on a background thread (to not block the browser when we
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// do expensive operations) and is NOT threadsafe, so it must only be called
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// from message handlers on the background thread. Invoking on another thread
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// requires threadsafe refcounting.
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Most functions here are just the implementations of the corresponding
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// functions in the history service. These functions are not documented
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// here, see the history service for behavior.
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                       public BroadcastNotificationDelegate {
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Interface implemented by the owner of the HistoryBackend object. Normally,
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the history service implements this to send stuff back to the main thread.
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The unit tests can provide a different implementation if they don't have
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // a history service object.
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  class Delegate {
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   public:
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    virtual ~Delegate() {}
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Called when the database cannot be read correctly for some reason.
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    virtual void NotifyProfileError(int backend_id,
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                    sql::InitStatus init_status) = 0;
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Sets the in-memory history backend. The in-memory backend is created by
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // the main backend. For non-unit tests, this happens on the background
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // thread. It is to be used on the main thread, so this would transfer
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // it to the history service. Unit tests can override this behavior.
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    //
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // This function is NOT guaranteed to be called. If there is an error,
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // there may be no in-memory database.
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    //
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Ownership of the backend pointer is transferred to this function.
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    virtual void SetInMemoryBackend(int backend_id,
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                    InMemoryHistoryBackend* backend) = 0;
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Broadcasts the specified notification to the notification service.
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // This is implemented here because notifications must only be sent from
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // the main thread. This is the only method that doesn't identify the
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // caller because notifications must always be sent.
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    //
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Ownership of the HistoryDetails is transferred to this function.
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    virtual void BroadcastNotifications(int type,
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                        HistoryDetails* details) = 0;
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Invoked when the backend has finished loading the db.
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    virtual void DBLoaded(int backend_id) = 0;
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Tell TopSites to start reading thumbnails from the ThumbnailsDB.
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    virtual void StartTopSitesMigration(int backend_id) = 0;
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    virtual void NotifyVisitDBObserversOnAddVisit(
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        const history::BriefVisitInfo& info) = 0;
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Init must be called to complete object creation. This object can be
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // constructed on any thread, but all other functions including Init() must
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // be called on the history thread.
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |history_dir| is the directory where the history files will be placed.
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // See the definition of BroadcastNotificationsCallback above. This function
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // takes ownership of the callback pointer.
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |id| is used to communicate with the delegate, to identify which
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // backend is calling the method.
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |bookmark_service| is used to determine bookmarked URLs when deleting and
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // may be NULL.
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This constructor is fast and does no I/O, so can be called at any time.
1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  HistoryBackend(const base::FilePath& history_dir,
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                 int id,
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                 Delegate* delegate,
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                 BookmarkService* bookmark_service);
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Must be called after creation but before any objects are created. If this
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // fails, all other functions will fail as well. (Since this runs on another
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // thread, we don't bother returning failure.)
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |languages| gives a list of language encodings with which the history
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // URLs and omnibox searches are interpreted.
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |force_fail| can be set during unittests to unconditionally fail to init.
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void Init(const std::string& languages, bool force_fail);
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notification that the history system is shutting down. This will break
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the refs owned by the delegate and any pending transaction so it will
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // actually be deleted.
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void Closing();
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // See NotifyRenderProcessHostDestruction.
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void NotifyRenderProcessHostDestruction(const void* host);
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Navigation ----------------------------------------------------------------
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |request.time| must be unique with high probability.
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void AddPage(const HistoryAddPageArgs& request);
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SetPageTitle(const GURL& url, const string16& title);
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void AddPageNoVisitForBookmark(const GURL& url, const string16& title);
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Updates the database backend with a page's ending time stamp information.
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The page can be identified by the combination of the pointer to
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // a RenderProcessHost, the page id and the url.
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The given pointer will not be dereferenced, it is only used for
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // identification purposes, hence it is a void*.
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UpdateWithPageEndTime(const void* host,
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                             int32 page_id,
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                             const GURL& url,
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                             base::Time end_ts);
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
165c6a03b665d27bf9b307170479657cbbf1b5bfe17Torne (Richard Coles)
166c6a03b665d27bf9b307170479657cbbf1b5bfe17Torne (Richard Coles)  // Indexing ------------------------------------------------------------------
167c6a03b665d27bf9b307170479657cbbf1b5bfe17Torne (Richard Coles)
168c6a03b665d27bf9b307170479657cbbf1b5bfe17Torne (Richard Coles)  void SetPageContents(const GURL& url, const string16& contents);
169c6a03b665d27bf9b307170479657cbbf1b5bfe17Torne (Richard Coles)
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Querying ------------------------------------------------------------------
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // ScheduleAutocomplete() never frees |provider| (which is globally live).
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // It passes |params| on to the autocomplete system which will eventually
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // free it.
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ScheduleAutocomplete(HistoryURLProvider* provider,
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            HistoryURLProviderParams* params);
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void IterateURLs(
17990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      const scoped_refptr<visitedlink::VisitedLinkDelegate::URLEnumerator>&
1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)          enumerator);
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void QueryURL(scoped_refptr<QueryURLRequest> request,
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                const GURL& url,
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                bool want_visits);
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void QueryHistory(scoped_refptr<QueryHistoryRequest> request,
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    const string16& text_query,
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    const QueryOptions& options);
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void QueryRedirectsFrom(scoped_refptr<QueryRedirectsRequest> request,
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          const GURL& url);
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void QueryRedirectsTo(scoped_refptr<QueryRedirectsRequest> request,
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const GURL& url);
1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void GetVisibleVisitCountToHost(
1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      scoped_refptr<GetVisibleVisitCountToHostRequest> request,
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const GURL& url);
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(Nik): remove. Use QueryMostVisitedURLs instead.
1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void QueryTopURLsAndRedirects(
1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      scoped_refptr<QueryTopURLsAndRedirectsRequest> request,
1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int result_count);
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Request the |result_count| most visited URLs and the chain of
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // redirects leading to each of these URLs. |days_back| is the
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // number of days of history to use. Used by TopSites.
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void QueryMostVisitedURLs(
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      scoped_refptr<QueryMostVisitedURLsRequest> request,
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int result_count,
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int days_back);
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Request the |result_count| URLs and the chain of redirects
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // leading to each of these URLs, filterd and sorted based on the |filter|.
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If |debug| is enabled, additional data will be computed and provided.
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void QueryFilteredURLs(
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      scoped_refptr<QueryFilteredURLsRequest> request,
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int result_count,
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const history::VisitFilter& filter,
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      bool debug);
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // QueryMostVisitedURLs without the request.
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void QueryMostVisitedURLsImpl(int result_count,
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                int days_back,
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                MostVisitedURLList* result);
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Computes the most recent URL(s) that the given canonical URL has
2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // redirected to and returns true on success. There may be more than one
2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // redirect in a row, so this function will fill the given array with the
2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // entire chain. If there are no redirects for the most recent visit of the
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // URL, or the URL is not in history, returns false.
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Backend for QueryRedirectsFrom.
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool GetMostRecentRedirectsFrom(const GURL& url,
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  history::RedirectList* redirects);
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Similar to above function except computes a chain of redirects to the
2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // given URL. Stores the most recent list of redirects ending at |url| in the
2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // given RedirectList. For example, if we have the redirect list A -> B -> C,
2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // then calling this function with url=C would fill redirects with {B, A}.
2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool GetMostRecentRedirectsTo(const GURL& url,
2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                history::RedirectList* redirects);
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Thumbnails ----------------------------------------------------------------
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetPageThumbnail(const GURL& url,
2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const gfx::Image* thumbnail,
2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const ThumbnailScore& score);
2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Retrieves a thumbnail, passing it across thread boundaries
2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // via. the included callback.
2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void GetPageThumbnail(scoped_refptr<GetPageThumbnailRequest> request,
2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const GURL& page_url);
2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Backend implementation of GetPageThumbnail. Unlike
2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // GetPageThumbnail(), this method has way to transport data across
2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // thread boundaries.
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Exposed for testing reasons.
2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void GetPageThumbnailDirectly(
2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const GURL& page_url,
2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      scoped_refptr<base::RefCountedBytes>* data);
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void MigrateThumbnailsDatabase();
2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Favicon -------------------------------------------------------------------
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void GetFavicons(const std::vector<GURL>& icon_urls,
2652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                    int icon_types,
2662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                    int desired_size_in_dip,
2672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                    const std::vector<ui::ScaleFactor>& desired_scale_factors,
26890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                    std::vector<chrome::FaviconBitmapResult>* bitmap_results);
2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void GetFaviconsForURL(
2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const GURL& page_url,
2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int icon_types,
2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int desired_size_in_dip,
2742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const std::vector<ui::ScaleFactor>& desired_scale_factors,
27590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      std::vector<chrome::FaviconBitmapResult>* bitmap_results);
2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void GetFaviconForID(
27890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      chrome::FaviconID favicon_id,
2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int desired_size_in_dip,
2802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      ui::ScaleFactor desired_scale_factor,
28190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      std::vector<chrome::FaviconBitmapResult>* bitmap_results);
2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UpdateFaviconMappingsAndFetch(
2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const GURL& page_url,
2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const std::vector<GURL>& icon_urls,
2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int icon_types,
2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int desired_size_in_dip,
2882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const std::vector<ui::ScaleFactor>& desired_scale_factors,
28990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      std::vector<chrome::FaviconBitmapResult>* bitmap_results);
2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void MergeFavicon(const GURL& page_url,
2922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                    const GURL& icon_url,
29390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                    chrome::IconType icon_type,
2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    scoped_refptr<base::RefCountedMemory> bitmap_data,
2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    const gfx::Size& pixel_size);
2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetFavicons(
2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const GURL& page_url,
29990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      chrome::IconType icon_type,
30090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data);
3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetFaviconsOutOfDateForPage(const GURL& page_url);
3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void CloneFavicons(const GURL& old_page_url, const GURL& new_page_url);
3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetImportedFavicons(
3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const std::vector<ImportedFaviconUsage>& favicon_usage);
3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Downloads -----------------------------------------------------------------
3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3117dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  void GetNextDownloadId(uint32* next_id);
3122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void QueryDownloads(std::vector<DownloadRow>* rows);
3132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void UpdateDownload(const DownloadRow& data);
3142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void CreateDownload(const history::DownloadRow& history_info,
3157dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch                      bool* success);
3167dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  void RemoveDownloads(const std::set<uint32>& ids);
3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Segment usage -------------------------------------------------------------
3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void QuerySegmentUsage(scoped_refptr<QuerySegmentUsageRequest> request,
3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         const base::Time from_time,
3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         int max_result_count);
3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DeleteOldSegmentData();
3242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void IncreaseSegmentDuration(const GURL& url,
3262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                               base::Time time,
3272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                               base::TimeDelta delta);
3282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void QuerySegmentDuration(scoped_refptr<QuerySegmentUsageRequest> request,
3302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                            const base::Time from_time,
3312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                            int max_result_count);
3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Keyword search terms ------------------------------------------------------
3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetKeywordSearchTermsForURL(const GURL& url,
3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                   TemplateURLID keyword_id,
3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                   const string16& term);
3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DeleteAllSearchTermsForKeyword(TemplateURLID keyword_id);
3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void GetMostRecentKeywordSearchTerms(
3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      scoped_refptr<GetMostRecentKeywordSearchTermsRequest> request,
3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      TemplateURLID keyword_id,
3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const string16& prefix,
3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int max_count);
3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID)
3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Android Provider ---------------------------------------------------------
3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // History and bookmarks ----------------------------------------------------
3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void InsertHistoryAndBookmark(scoped_refptr<InsertRequest> request,
3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                const HistoryAndBookmarkRow& row);
3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void QueryHistoryAndBookmarks(
3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      scoped_refptr<QueryRequest> request,
3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const std::vector<HistoryAndBookmarkRow::ColumnID>& projections,
3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const std::string& selection,
3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const std::vector<string16>& selection_args,
3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const std::string& sort_order);
3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UpdateHistoryAndBookmarks(scoped_refptr<UpdateRequest> request,
3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 const HistoryAndBookmarkRow& row,
3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 const std::string& selection,
3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 const std::vector<string16>& selection_args);
3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DeleteHistoryAndBookmarks(scoped_refptr<DeleteRequest> request,
3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 const std::string& selection,
3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                 const std::vector<string16>& selection_args);
3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DeleteHistory(scoped_refptr<DeleteRequest> request,
3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     const std::string& selection,
3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     const std::vector<string16>& selection_args);
3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Statement ----------------------------------------------------------------
3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Move the statement's current position.
3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void MoveStatement(scoped_refptr<MoveStatementRequest> request,
3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     history::AndroidStatement* statement,
3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     int current_pos,
3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     int destination);
3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Close the given statement. The ownership is transfered.
3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void CloseStatement(AndroidStatement* statement);
3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Search terms -------------------------------------------------------------
3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void InsertSearchTerm(scoped_refptr<InsertRequest> request,
3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const SearchRow& row);
3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UpdateSearchTerms(scoped_refptr<UpdateRequest> request,
3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         const SearchRow& row,
3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         const std::string& selection,
3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         const std::vector<string16> selection_args);
3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DeleteSearchTerms(scoped_refptr<DeleteRequest> request,
3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         const std::string& selection,
3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         const std::vector<string16> selection_args);
3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void QuerySearchTerms(scoped_refptr<QueryRequest> request,
3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const std::vector<SearchRow::ColumnID>& projections,
3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const std::string& selection,
4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const std::vector<string16>& selection_args,
4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const std::string& sort_order);
4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // defined(OS_ANDROID)
4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Generic operations --------------------------------------------------------
4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ProcessDBTask(scoped_refptr<HistoryDBTaskRequest> request);
4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool GetAllTypedURLs(URLRows* urls);
4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool GetVisitsForURL(URLID id, VisitVector* visits);
4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Fetches up to |max_visits| most recent visits for the passed URL.
4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool GetMostRecentVisitsForURL(URLID id,
4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                         int max_visits,
4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                         VisitVector* visits);
4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool UpdateURL(URLID id, const history::URLRow& url);
4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // While adding visits in batch, the source needs to be provided.
4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool AddVisits(const GURL& url,
4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         const std::vector<history::VisitInfo>& visits,
4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         VisitSource visit_source);
4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool RemoveVisits(const VisitVector& visits);
4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the VisitSource associated with each one of the passed visits.
4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If there is no entry in the map for a given visit, that means the visit
4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // was SOURCE_BROWSED. Returns false if there is no HistoryDatabase..
4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool GetVisitsSource(const VisitVector& visits, VisitSourceMap* sources);
4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool GetURL(const GURL& url, history::URLRow* url_row);
4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
434b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // Returns the syncable service for syncing typed urls. The returned service
435b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // is owned by |this| object.
436b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  virtual TypedUrlSyncableService* GetTypedUrlSyncableService() const;
437b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Deleting ------------------------------------------------------------------
4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DeleteURLs(const std::vector<GURL>& urls);
4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DeleteURL(const GURL& url);
4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Calls ExpireHistoryBackend::ExpireHistoryBetween and commits the change.
4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ExpireHistoryBetween(
4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const std::set<GURL>& restrict_urls,
4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      base::Time begin_time,
4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      base::Time end_time);
4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Finds the URLs visited at |times| and expires all their visits within
4512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // [|begin_time|, |end_time|). All times in |times| should be in
4522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // [|begin_time|, |end_time|). This is used when expiration request is from
4532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // server side, i.e. web history deletes, where only visit times (possibly
4542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // incomplete) are transmitted to protect user's privacy.
4552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void ExpireHistoryForTimes(const std::set<base::Time>& times,
4562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                             base::Time begin_time, base::Time end_time);
4572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Calls ExpireHistoryBetween() once for each element in the vector.
4592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The fields of |ExpireHistoryArgs| map directly to the arguments of
4602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // of ExpireHistoryBetween().
4612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void ExpireHistory(const std::vector<ExpireHistoryArgs>& expire_list);
4622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Bookmarks -----------------------------------------------------------------
4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notification that a URL is no longer bookmarked. If there are no visits
4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // for the specified url, it is deleted.
4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void URLsNoLongerBookmarked(const std::set<GURL>& urls);
4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Callbacks To Kill Database When It Gets Corrupted -------------------------
4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4717d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // Called by the database to report errors.  Schedules one call to
4727d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // KillHistoryDatabase() in case of corruption.
4737d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  void DatabaseErrorCallback(int error, sql::Statement* stmt);
4747d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Raze the history database. It will be recreated in a future run. Hopefully
4765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // things go better then. Continue running but without reading or storing any
4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // state into the HistoryBackend databases. Close all of the databases managed
4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // HistoryBackend as there are no provisions for accessing the other databases
4795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // managed by HistoryBackend when the history database cannot be accessed.
4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void KillHistoryDatabase();
4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Testing -------------------------------------------------------------------
4835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets the task to run and the message loop to run it on when this object
4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is destroyed. See HistoryService::SetOnBackendDestroyTask for a more
4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // complete description.
48790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  void SetOnBackendDestroyTask(base::MessageLoop* message_loop,
4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                               const base::Closure& task);
4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Adds the given rows to the database if it doesn't exist. A visit will be
4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // added for each given URL at the last visit time in the URLRow if the
4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // passed visit type != SOURCE_SYNCED (the sync code manages visits itself).
4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Each visit will have the visit_source type set.
4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void AddPagesWithDetails(const URLRows& info, VisitSource visit_source);
4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(UNIT_TEST)
4975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  HistoryDatabase* db() const { return db_.get(); }
4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ExpireHistoryBackend* expire_backend() { return &expirer_; }
5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the passed visit time is already expired (used by the sync
5035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // code to avoid syncing visits that would immediately be expired).
5045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IsExpiredVisitTime(const base::Time& time);
5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::Time GetFirstRecordedTimeForTest() {
5072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return first_recorded_time_;
5082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
5092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected:
5115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~HistoryBackend();
5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class base::RefCountedThreadSafe<HistoryBackend>;
5155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class CommitLaterTask;  // The commit task needs to call Commit().
5165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class HistoryBackendTest;
5175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class HistoryBackendDBTest;  // So the unit tests can poke our innards.
5185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll);
5195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAllThenAddData);
5205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ImportedFaviconsTest);
5215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, URLsNoLongerBookmarked);
5225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, StripUsernamePasswordTest);
5235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteThumbnailsDatabaseTest);
5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPageVisitSource);
525c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPageVisitNotLastVisit);
5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPageArgsSource);
5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddVisitsSource);
5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetMostRecentVisits);
5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsSource);
5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsTransitions);
5315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationVisitSource);
5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationIconMapping);
5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           SetFaviconMappingsForPageAndRedirects);
5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           SetFaviconMappingsForPageDuplicates);
5375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFaviconsDeleteBitmaps);
5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFaviconsReplaceBitmapData);
5395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           SetFaviconsSameFaviconURLForTwoPages);
5415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
5425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           UpdateFaviconMappingsAndFetchNoChange);
5435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconPageURLNotInDB);
5445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconPageURLInDB);
5455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconMaxFaviconsPerPage);
5465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
5472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           MergeFaviconIconURLMappedToDifferentPageURL);
5482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
5495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           MergeFaviconMaxFaviconBitmapsPerIconURL);
5505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
5515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           UpdateFaviconMappingsAndFetchMultipleIconTypes);
5525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBEmpty);
5535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
5545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           GetFaviconsFromDBNoFaviconBitmaps);
5555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
5565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           GetFaviconsFromDBSelectClosestMatch);
5575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBSingleIconURL);
5585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBIconType);
5595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired);
5602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
5612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           UpdateFaviconMappingsAndFetchNoDB);
5625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
5635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           CloneFaviconIsRestrictedToSameDomain);
5645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs);
5655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration);
5662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ExpireHistoryForTimes);
567bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch  FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteFTSIndexDatabases);
5685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class ::TestingProfile;
5705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Computes the name of the specified database on disk.
5722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::FilePath GetThumbnailFileName() const;
5735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the name of the Favicons database. This is the new name
5755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // of the Thumbnails database.
5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // See ThumbnailDatabase::RenameAndDropThumbnails.
5772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::FilePath GetFaviconsFileName() const;
5782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::FilePath GetArchivedFileName() const;
5795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID)
5815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the name of android cache database.
5822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::FilePath GetAndroidCacheFileName() const;
583eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
584eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // Populate a map from a |MostVisitedURLList|. The map assigns a rank to each
585eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // top URL and its redirects. This should only be done once at backend
586eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // initialization.
587eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // This can be removed for M31. (See issue 248761.)
588eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
589eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  void PopulateMostVisitedURLMap();
590eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // Record counts of page visits by rank. If a url is not ranked, record the
591eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // page visit in a slot corresponding to |max_top_url_count|, which should
592eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // be one greater than the largest rank of any url in |top_urls|.
593eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // This can be removed for M31. (See issue 248761.)
594eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  void RecordTopPageVisitStats(const GURL& url);
5955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
5965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  class URLQuerier;
5985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class URLQuerier;
5995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Does the work of Init.
6015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void InitImpl(const std::string& languages);
6025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
603ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  // Called when the system is under memory pressure.
604ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  void OnMemoryPressure(
605ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch      base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
606ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch
6075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Closes all databases managed by HistoryBackend. Commits any pending
6085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // transactions.
6095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void CloseAllDatabases();
6105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Adds a single visit to the database, updating the URL information such
6125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // as visit and typed count. The visit ID of the added visit and the URL ID
6135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // of the associated URL (whether added or not) is returned. Both values will
6145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // be 0 on failure.
6155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
6165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This does not schedule database commits, it is intended to be used as a
6175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // subroutine for AddPage only. It also assumes the database is valid.
6185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::pair<URLID, VisitID> AddPageVisit(const GURL& url,
6195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                         base::Time time,
6205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                         VisitID referring_visit,
6215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                         content::PageTransition transition,
6225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                         VisitSource visit_source);
6235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns a redirect chain in |redirects| for the VisitID
6255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |cur_visit|. |cur_visit| is assumed to be valid. Assumes that
6265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // this HistoryBackend object has been Init()ed successfully.
6275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void GetRedirectsFromSpecificVisit(
6285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      VisitID cur_visit, history::RedirectList* redirects);
6295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Similar to the above function except returns a redirect list ending
6315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // at |cur_visit|.
6325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void GetRedirectsToSpecificVisit(
6335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      VisitID cur_visit, history::RedirectList* redirects);
6345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Update the visit_duration information in visits table.
6365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UpdateVisitDuration(VisitID visit_id, const base::Time end_ts);
6375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Thumbnail Helpers ---------------------------------------------------------
6395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // When a simple GetMostRecentRedirectsFrom() fails, this method is
6415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // called which searches the last N visit sessions instead of just
6425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the current one. Returns true and puts thumbnail data in |data|
6435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // if a proper thumbnail was found. Returns false otherwise. Assumes
6445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // that this HistoryBackend object has been Init()ed successfully.
6455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool GetThumbnailFromOlderRedirect(
6465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const GURL& page_url, std::vector<unsigned char>* data);
6475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Querying ------------------------------------------------------------------
6495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
650eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // Backends for QueryHistory. *Basic() handles queries that are not
651eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // text search queries and can just be given directly to the history DB.
652eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // The *Text() version performs a brute force query of the history DB to
653eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // search for results which match the given text query.
6545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Both functions assume QueryHistory already checked the DB for validity.
6555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void QueryHistoryBasic(URLDatabase* url_db, VisitDatabase* visit_db,
6565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         const QueryOptions& options, QueryResults* result);
657eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  void QueryHistoryText(URLDatabase* url_db,
658eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch                        VisitDatabase* visit_db,
659eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch                        const string16& text_query,
660eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch                        const QueryOptions& options,
661eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch                        QueryResults* result);
6625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Committing ----------------------------------------------------------------
6645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // We always keep a transaction open on the history database so that multiple
6665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // transactions can be batched. Periodically, these are flushed (use
6675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // ScheduleCommit). This function does the commit to write any new changes to
6685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // disk and opens a new transaction. This will be called automatically by
6695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // ScheduleCommit, or it can be called explicitly if a caller really wants
6705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to write something to disk.
6715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void Commit();
6725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Schedules a commit to happen in the future. We do this so that many
6745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // operations over a period of time will be batched together. If there is
6755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // already a commit scheduled for the future, this will do nothing.
6765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ScheduleCommit();
6775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Cancels the scheduled commit, if any. If there is no scheduled commit,
6795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // does nothing.
6805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void CancelScheduledCommit();
6815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Segments ------------------------------------------------------------------
6835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Walks back a segment chain to find the last visit with a non null segment
6855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // id and returns it. If there is none found, returns 0.
6865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  SegmentID GetLastSegmentID(VisitID from_visit);
6875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Update the segment information. This is called internally when a page is
6895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // added. Return the segment id of the segment that has been updated.
6905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  SegmentID UpdateSegments(const GURL& url,
6915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           VisitID from_visit,
6925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           VisitID visit_id,
6935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           content::PageTransition transition_type,
6945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           const base::Time ts);
6955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Favicons ------------------------------------------------------------------
6975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Used by both UpdateFaviconMappingsAndFetch and GetFavicons.
6995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If |page_url| is non-null, the icon urls for |page_url| (and all
7005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // redirects) are set to the subset of |icon_urls| for which icons are
7015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // already stored in the database.
7025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If |page_url| is non-null, |icon_types| can be multiple icon types
7035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // only if |icon_types| == TOUCH_ICON | TOUCH_PRECOMPOSED_ICON.
7045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If multiple icon types are specified, |page_url| will be mapped to the
7055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // icon URLs of the largest type available in the database.
7065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UpdateFaviconMappingsAndFetchImpl(
7075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const GURL* page_url,
7085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const std::vector<GURL>& icon_urls,
7095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int icon_types,
7105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int desired_size_in_dip,
7112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const std::vector<ui::ScaleFactor>& desired_scale_factors,
71290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      std::vector<chrome::FaviconBitmapResult>* results);
7135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Set the favicon bitmaps for |icon_id|.
7155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // For each entry in |favicon_bitmap_data|, if a favicon bitmap already
7165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // exists at the entry's pixel size, replace the favicon bitmap's data with
7175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the entry's bitmap data. Otherwise add a new favicon bitmap.
7182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Any favicon bitmaps already mapped to |icon_id| whose pixel sizes are not
7192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // in |favicon_bitmap_data| are deleted.
7202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // If not NULL, |favicon_bitmaps_changed| is set to whether any of the bitmap
7212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // data at |icon_id| is changed as a result of calling this method.
7222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Computing |favicon_bitmaps_changed| requires additional database queries
7232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // so should be avoided if unnecessary.
7245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetFaviconBitmaps(
72590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      chrome::FaviconID icon_id,
72690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data,
7272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      bool* favicon_bitmaps_changed);
7285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns true if |favicon_bitmap_data| passed to SetFavicons() is valid.
7305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Criteria:
7312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // 1) |favicon_bitmap_data| contains no more than
7322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  //      kMaxFaviconsPerPage unique icon URLs.
7332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  //      kMaxFaviconBitmapsPerIconURL favicon bitmaps for each icon URL.
7342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // 2) FaviconBitmapData::bitmap_data contains non NULL bitmap data.
7355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool ValidateSetFaviconsParams(
73690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data) const;
7375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns true if the bitmap data at |bitmap_id| equals |new_bitmap_data|.
7392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool IsFaviconBitmapDataEqual(
7402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      FaviconBitmapID bitmap_id,
7412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const scoped_refptr<base::RefCountedMemory>& new_bitmap_data);
7425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if there are favicons for |page_url| and one of the types in
7445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |icon_types|.
7455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |favicon_bitmap_results| is set to the favicon bitmaps which most closely
7465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // match |desired_size_in_dip| and |desired_scale_factors|. If
7475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |desired_size_in_dip| is 0, the largest favicon bitmap with one of the icon
7485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // types in |icon_types| is returned. If |icon_types| contains multiple icon
7495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // types and there are several matched icon types in the database, results
7505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // will only be returned for a single icon type in the priority of
7515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, and FAVICON. See the comment for
7525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // GetFaviconResultsForBestMatch() for more details on how
7535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |favicon_bitmap_results| is constructed.
7545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool GetFaviconsFromDB(
7555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const GURL& page_url,
7565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int icon_types,
7575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const int desired_size_in_dip,
7585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const std::vector<ui::ScaleFactor>& desired_scale_factors,
75990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results);
7605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the favicon bitmaps which most closely match |desired_size_in_dip|
7625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and |desired_scale_factors| in |favicon_bitmap_results|. If
7635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |desired_size_in_dip| is 0, only the largest favicon bitmap is returned.
7645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Goodness is computed via SelectFaviconBitmapIDs(). It is computed on a
7655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // per favicon id basis, thus all |favicon_bitmap_results| are guaranteed to
7665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // be for the same FaviconID. |favicon_bitmap_results| will have at most one
7675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // entry for each desired scale factor. There will be less entries if the same
7685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // favicon bitmap is the best result for multiple scale factors.
7695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if there were no errors.
7705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool GetFaviconBitmapResultsForBestMatch(
77190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      const std::vector<chrome::FaviconID>& candidate_favicon_ids,
7725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int desired_size_in_dip,
7735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const std::vector<ui::ScaleFactor>& desired_scale_factors,
77490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results);
7755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Maps the favicon ids in |icon_ids| to |page_url| (and all redirects)
7775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // for |icon_type|.
7785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the mappings for the page or any of its redirects were
7795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // changed.
7805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool SetFaviconMappingsForPageAndRedirects(
7815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const GURL& page_url,
78290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      chrome::IconType icon_type,
78390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      const std::vector<chrome::FaviconID>& icon_ids);
7845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Maps the favicon ids in |icon_ids| to |page_url| for |icon_type|.
7865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the function changed some of |page_url|'s mappings.
78790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  bool SetFaviconMappingsForPage(
78890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      const GURL& page_url,
78990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      chrome::IconType icon_type,
79090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      const std::vector<chrome::FaviconID>& icon_ids);
7915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns all the page URLs in the redirect chain for |page_url|. If there
7935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // are no known redirects for |page_url|, returns a vector with |page_url|.
7945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void GetCachedRecentRedirects(const GURL& page_url,
7955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                history::RedirectList* redirect_list);
7965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Send notification that the favicon has changed for |page_url| and all its
7985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // redirects.
7995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SendFaviconChangedNotificationForPageAndRedirects(
8005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const GURL& page_url);
8015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Generic stuff -------------------------------------------------------------
8035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Processes the next scheduled HistoryDBTask, scheduling this method
8055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to be invoked again if there are more tasks that need to run.
8065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ProcessDBTaskImpl();
8075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Release all tasks in history_db_tasks_ and clears it.
8095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ReleaseDBTasks();
8105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Schedules a broadcast of the given notification on the main thread. The
8125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // details argument will have ownership taken by this function (it will be
8135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // sent to the main thread and deleted there).
8145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void BroadcastNotifications(int type,
8155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                      HistoryDetails* details_deleted) OVERRIDE;
8165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
817b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  virtual void NotifySyncURLsDeleted(bool all_history,
818b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)                                     bool archived,
819b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)                                     URLRows* rows) OVERRIDE;
820b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
8215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Deleting all history ------------------------------------------------------
8225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Deletes all history. This is a special case of deleting that is separated
8245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // from our normal dependency-following method for performance reasons. The
8255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // logic lives here instead of ExpireHistoryBackend since it will cause
8265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // re-initialization of some databases such as Thumbnails or Archived that
8275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // could fail. When these databases are not valid, our pointers must be NULL,
8285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // so we need to handle this type of operation to keep the pointers in sync.
8295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DeleteAllHistory();
8305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Given a vector of all URLs that we will keep, removes all thumbnails
8325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // referenced by any URL, and also all favicons that aren't used by those
8335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // URLs. The favicon IDs will change, so this will update the url rows in the
8345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // vector to reference the new IDs.
8355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool ClearAllThumbnailHistory(URLRows* kept_urls);
8365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Deletes all information in the history database, except for the supplied
8385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // set of URLs in the URL table (these should correspond to the bookmarked
8395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // URLs).
8405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
8415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The IDs of the URLs may change.
8425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool ClearAllMainHistory(const URLRows& kept_urls);
8435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
844bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch  // Deletes the FTS index database files, which are no longer used.
845bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch  void DeleteFTSIndexDatabases();
846bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch
8475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the BookmarkService, blocking until it is loaded. This may return
8485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NULL during testing.
8495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  BookmarkService* GetBookmarkService();
8505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notify any observers of an addition to the visit database.
8525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void NotifyVisitObservers(const VisitRow& visit);
8535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Data ----------------------------------------------------------------------
8555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Delegate. See the class definition above for more information. This will
8575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // be NULL before Init is called and after Cleanup, but is guaranteed
8585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // non-NULL in between.
8595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<Delegate> delegate_;
8605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The id of this class, given in creation and used for identifying the
8625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // backend when calling the delegate.
8635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int id_;
8645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Directory where database files will be stored.
8662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::FilePath history_dir_;
8675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The history/thumbnail databases. Either MAY BE NULL if the database could
8695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // not be opened, all users must first check for NULL and return immediately
8705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // if it is. The thumbnail DB may be NULL when the history one isn't, but not
8715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // vice-versa.
8725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<HistoryDatabase> db_;
8737d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  bool scheduled_kill_db_;  // Database is being killed due to error.
8745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<ThumbnailDatabase> thumbnail_db_;
8755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Stores old history in a larger, slower database.
8775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<ArchivedDatabase> archived_db_;
8785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
879c6a03b665d27bf9b307170479657cbbf1b5bfe17Torne (Richard Coles)  // Helper to collect page data for vending to history_publisher_.
880c6a03b665d27bf9b307170479657cbbf1b5bfe17Torne (Richard Coles)  scoped_ptr<PageCollector> page_collector_;
881c6a03b665d27bf9b307170479657cbbf1b5bfe17Torne (Richard Coles)
8825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Manages expiration between the various databases.
8835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ExpireHistoryBackend expirer_;
8845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // A commit has been scheduled to occur sometime in the future. We can check
8865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // non-null-ness to see if there is a commit scheduled in the future, and we
8875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // can use the pointer to cancel the scheduled commit. There can be only one
8885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // scheduled commit at a time (see ScheduleCommit).
8895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_refptr<CommitLaterTask> scheduled_commit_;
8905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Maps recent redirect destination pages to the chain of redirects that
8925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // brought us to there. Pages that did not have redirects or were not the
8935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // final redirect in a chain will not be in this list, as well as pages that
8945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // redirected "too long" ago (as determined by ExpireOldRedirects above).
8955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // It is used to set titles & favicons for redirects to that of the
8965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // destination.
8975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
8985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // As with AddPage, the last item in the redirect chain will be the
8995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // destination of the redirect (i.e., the key into recent_redirects_);
9005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef base::MRUCache<GURL, history::RedirectList> RedirectCache;
9015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  RedirectCache recent_redirects_;
9025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Timestamp of the first entry in our database.
9045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  base::Time first_recorded_time_;
9055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // When set, this is the task that should be invoked on destruction.
90790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  base::MessageLoop* backend_destroy_message_loop_;
9085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  base::Closure backend_destroy_task_;
9095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tracks page transition types.
9115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  VisitTracker tracker_;
9125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // A boolean variable to track whether we have already purged obsolete segment
9145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // data.
9155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool segment_queried_;
9165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // HistoryDBTasks to run. Be sure to AddRef when adding, and Release when
9185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // done.
9195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::list<HistoryDBTaskRequest*> db_task_requests_;
9205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Used to determine if a URL is bookmarked. This is owned by the Profile and
9225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // may be NULL (during testing).
9235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
9245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Use GetBookmarkService to access this, which makes sure the service is
9255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // loaded.
9265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  BookmarkService* bookmark_service_;
9275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Publishes the history to all indexers which are registered to receive
9295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // history data from us. Can be NULL if there are no listeners.
9305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<HistoryPublisher> history_publisher_;
9315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID)
9335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Used to provide the Android ContentProvider APIs.
9345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<AndroidProviderBackend> android_provider_backend_;
935eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
936eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // Used to provide UMA on the number of page visits that are to the most
937eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // visited URLs. This is here because the backend both has access to this
938eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // information and is notified of page visits. The top sites service should
939eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // be used instead whenever possible.
940eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  std::map<GURL, int> most_visited_urls_map_;
9415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
9425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
943b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // Used to manage syncing of the typed urls datatype. This will be NULL
944b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // before Init is called.
945b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  scoped_ptr<TypedUrlSyncableService> typed_url_syncable_service_;
946b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
947ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  // Listens for the system being under memory pressure.
948ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_;
949ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch
9505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(HistoryBackend);
9515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
9525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace history
9545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
956