visitedlink_delegate.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_VISITEDLINK_BROWSER_VISITEDLINK_DELEGATE_H_
  5. #define COMPONENTS_VISITEDLINK_BROWSER_VISITEDLINK_DELEGATE_H_
  6. #include "base/memory/ref_counted.h"
  7. class GURL;
  8. namespace visitedlink {
  9. // Delegate class that clients of VisitedLinkWriter must implement.
  10. class VisitedLinkDelegate {
  11. public:
  12. // See RebuildTable.
  13. class URLEnumerator : public base::RefCountedThreadSafe<URLEnumerator> {
  14. public:
  15. // Call this with each URL to rebuild the table.
  16. virtual void OnURL(const GURL& url) = 0;
  17. // This must be called by Delegate after RebuildTable is called. |success|
  18. // indicates all URLs have been returned successfully. The URLEnumerator
  19. // object cannot be used by the delegate after this call.
  20. virtual void OnComplete(bool success) = 0;
  21. protected:
  22. virtual ~URLEnumerator() {}
  23. private:
  24. friend class base::RefCountedThreadSafe<URLEnumerator>;
  25. };
  26. // Delegate class is responsible for persisting the list of visited URLs
  27. // across browser runs. This is called by VisitedLinkWriter to repopulate
  28. // its internal table. Note that methods on enumerator can be called on any
  29. // thread but the delegate is responsible for synchronizating the calls.
  30. virtual void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) = 0;
  31. protected:
  32. virtual ~VisitedLinkDelegate() {}
  33. };
  34. } // namespace visitedlink
  35. #endif // COMPONENTS_VISITEDLINK_BROWSER_VISITEDLINK_DELEGATE_H_