Chromium Code Reviews| Index: chrome/browser/visitedlink/visitedlink_master.h |
| diff --git a/chrome/browser/visitedlink/visitedlink_master.h b/chrome/browser/visitedlink/visitedlink_master.h |
| index 039ca317f643bb5c46f94f2c030197eb5d64e292..f9f284e3d4c2ffb20622ee10972d716a66028eaa 100644 |
| --- a/chrome/browser/visitedlink/visitedlink_master.h |
| +++ b/chrome/browser/visitedlink/visitedlink_master.h |
| @@ -11,28 +11,34 @@ |
| #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/logging.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" |
| class GURL; |
| +class VisitedLinkDelegate; |
| + |
| +// TODO(boliu): Remove. |
| class Profile; |
| +namespace content { |
| +class BrowserContext; |
| +} // namespace content |
| + |
| + |
| // 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. |
| // |
| // 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, |
| - public ProfileKeyedService { |
| +class VisitedLinkMaster : public VisitedLinkCommon { |
| public: |
| // Listens to the link coloring database events. The master is given this |
| // event as a constructor argument and dispatches events using it. |
| @@ -53,7 +59,8 @@ class VisitedLinkMaster : public VisitedLinkCommon, |
| virtual void Reset() = 0; |
| }; |
| - explicit VisitedLinkMaster(Profile* profile); |
| + VisitedLinkMaster(content::BrowserContext* browser_context, |
| + VisitedLinkDelegate* delegate); |
| // 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 |
| @@ -71,15 +78,12 @@ 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, |
| - HistoryService* history_service, |
| + VisitedLinkDelegate* delegate, |
| 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. |
| @@ -93,13 +97,21 @@ class VisitedLinkMaster : public VisitedLinkCommon, |
| // Adds a set of URLs to the table. |
| void AddURLs(const std::vector<GURL>& url); |
| + class URLIterator { |
| + public: |
| + virtual const GURL& next() = 0; |
| + virtual bool has_next() const = 0; |
| + }; |
| + |
| // Deletes the specified URLs from |rows| from the table. |
| - void DeleteURLs(const history::URLRows& rows); |
| + void DeleteURLs(URLIterator* iterator); |
| // Clears the visited links table by deleting the file from disk. Used as |
| // part of history clearing. |
| void DeleteAllURLs(); |
| + 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. |
| @@ -289,7 +301,7 @@ class VisitedLinkMaster : public VisitedLinkCommon, |
| // |
| // Returns true on success. Failure means we're not attempting to rebuild |
| // the database because something failed. |
| - bool RebuildTableFromHistory(); |
| + bool RebuildTableFromDelegate(); |
| // Callback that the table rebuilder uses when the rebuild is complete. |
| // |success| is true if the fingerprint generation succeeded, in which case |
| @@ -320,9 +332,11 @@ class VisitedLinkMaster : public VisitedLinkCommon, |
| bool posted_asynchronous_operation_; |
| #endif |
| - // Reference to the user profile that this object belongs to |
| + // Reference to the browser context that this object belongs to |
| // (it knows the path to where the data is stored) |
| - Profile* profile_; |
| + content::BrowserContext* browser_context_; |
| + |
| + VisitedLinkDelegate* delegate_; |
|
joth
2012/12/20 01:39:29
// weak.
boliu
2012/12/29 01:48:12
Added lengthier comment.
|
| // VisitedLinkEventListener to handle incoming events. |
| scoped_ptr<Listener> listener_; |
| @@ -380,10 +394,6 @@ 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_; |