| Index: chrome/browser/visitedlink/visitedlink_master.h
|
| diff --git a/chrome/browser/visitedlink/visitedlink_master.h b/chrome/browser/visitedlink/visitedlink_master.h
|
| index ff07d5d7f7433e5c77dc9e4805910ef40cdfc305..039ca317f643bb5c46f94f2c030197eb5d64e292 100644
|
| --- a/chrome/browser/visitedlink/visitedlink_master.h
|
| +++ b/chrome/browser/visitedlink/visitedlink_master.h
|
| @@ -11,26 +11,19 @@
|
| #include <set>
|
| #include <vector>
|
|
|
| -#include "base/callback.h"
|
| #include "base/callback_forward.h"
|
| #include "base/file_path.h"
|
| #include "base/gtest_prod_util.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/shared_memory.h"
|
| #include "base/threading/sequenced_worker_pool.h"
|
| +#include "chrome/browser/history/history.h"
|
| +#include "chrome/browser/history/history_types.h"
|
| +#include "chrome/browser/profiles/profile_keyed_service.h"
|
| #include "chrome/common/visitedlink_common.h"
|
|
|
| -#if defined(UNIT_TEST) || defined(PERF_TEST) || !defined(NDEBUG)
|
| -#include "base/logging.h"
|
| -#endif
|
| -
|
| class GURL;
|
| -class VisitedLinkDelegate;
|
| -
|
| -namespace content {
|
| -class BrowserContext;
|
| -} // namespace content
|
| -
|
| +class Profile;
|
|
|
| // Controls the link coloring database. The master controls all writing to the
|
| // database as well as disk I/O. There should be only one master.
|
| @@ -38,7 +31,8 @@ class BrowserContext;
|
| // This class will defer writing operations to the file thread. This means that
|
| // class destruction, the file may still be open since operations are pending on
|
| // another thread.
|
| -class VisitedLinkMaster : public VisitedLinkCommon {
|
| +class VisitedLinkMaster : public VisitedLinkCommon,
|
| + public ProfileKeyedService {
|
| public:
|
| // Listens to the link coloring database events. The master is given this
|
| // event as a constructor argument and dispatches events using it.
|
| @@ -59,8 +53,7 @@ class VisitedLinkMaster : public VisitedLinkCommon {
|
| virtual void Reset() = 0;
|
| };
|
|
|
| - VisitedLinkMaster(content::BrowserContext* browser_context,
|
| - VisitedLinkDelegate* delegate);
|
| + explicit VisitedLinkMaster(Profile* profile);
|
|
|
| // In unit test mode, we allow the caller to optionally specify the database
|
| // filename so that it can be run from a unit test. The directory where this
|
| @@ -78,12 +71,15 @@ class VisitedLinkMaster : public VisitedLinkCommon {
|
| // history if the file can't be loaded. This should generally be set for
|
| // testing except when you want to test the rebuild process explicitly.
|
| VisitedLinkMaster(Listener* listener,
|
| - VisitedLinkDelegate* delegate,
|
| + HistoryService* history_service,
|
| bool suppress_rebuild,
|
| const FilePath& filename,
|
| int32 default_table_size);
|
| virtual ~VisitedLinkMaster();
|
|
|
| + // Return the VisitedLinkMaster instance for a profile.
|
| + static VisitedLinkMaster* FromProfile(Profile* profile);
|
| +
|
| // Must be called immediately after object creation. Nothing else will work
|
| // until this is called. Returns true on success, false means that this
|
| // object won't work.
|
| @@ -97,31 +93,13 @@ class VisitedLinkMaster : public VisitedLinkCommon {
|
| // Adds a set of URLs to the table.
|
| void AddURLs(const std::vector<GURL>& url);
|
|
|
| - // See DeleteURLs.
|
| - class URLIterator {
|
| - public:
|
| - // HasNextURL must return true when this is called. Returns the next URL
|
| - // then advances the iterator. Note that the returned reference is only
|
| - // valid until the next call of NextURL.
|
| - virtual const GURL& NextURL() = 0;
|
| -
|
| - // Returns true if still has URLs to be iterated.
|
| - virtual bool HasNextURL() const = 0;
|
| -
|
| - protected:
|
| - virtual ~URLIterator() {}
|
| - };
|
| -
|
| // Deletes the specified URLs from |rows| from the table.
|
| - void DeleteURLs(URLIterator* iterator);
|
| + void DeleteURLs(const history::URLRows& rows);
|
|
|
| // Clears the visited links table by deleting the file from disk. Used as
|
| // part of history clearing.
|
| void DeleteAllURLs();
|
|
|
| - // Returns the Delegate of this Master.
|
| - VisitedLinkDelegate* GetDelegate();
|
| -
|
| #if defined(UNIT_TEST) || !defined(NDEBUG) || defined(PERF_TEST)
|
| // This is a debugging function that can be called to double-check internal
|
| // data structures. It will assert if the check fails.
|
| @@ -311,7 +289,7 @@ class VisitedLinkMaster : public VisitedLinkCommon {
|
| //
|
| // Returns true on success. Failure means we're not attempting to rebuild
|
| // the database because something failed.
|
| - bool RebuildTableFromDelegate();
|
| + bool RebuildTableFromHistory();
|
|
|
| // Callback that the table rebuilder uses when the rebuild is complete.
|
| // |success| is true if the fingerprint generation succeeded, in which case
|
| @@ -342,13 +320,9 @@ class VisitedLinkMaster : public VisitedLinkCommon {
|
| bool posted_asynchronous_operation_;
|
| #endif
|
|
|
| - // Reference to the browser context that this object belongs to
|
| + // Reference to the user profile that this object belongs to
|
| // (it knows the path to where the data is stored)
|
| - content::BrowserContext* browser_context_;
|
| -
|
| - // Client owns the delegate and is responsible for it being valid through
|
| - // the life time this VisitedLinkMaster.
|
| - VisitedLinkDelegate* delegate_;
|
| + Profile* profile_;
|
|
|
| // VisitedLinkEventListener to handle incoming events.
|
| scoped_ptr<Listener> listener_;
|
| @@ -406,6 +380,10 @@ class VisitedLinkMaster : public VisitedLinkCommon {
|
| // When nonzero, overrides the table size for new databases for testing
|
| int32 table_size_override_;
|
|
|
| + // When non-NULL, overrides the history service to use rather than as the
|
| + // BrowserProcess. This is provided for unit tests.
|
| + HistoryService* history_service_override_;
|
| +
|
| // When set, indicates the task that should be run after the next rebuild from
|
| // history is complete.
|
| base::Closure rebuild_complete_task_;
|
|
|