Home | History | Annotate | Download | only in browser
      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 
      5 #ifndef COMPONENTS_VISITEDLINK_BROWSER_VISITEDLINK_DELEGATE_H_
      6 #define COMPONENTS_VISITEDLINK_BROWSER_VISITEDLINK_DELEGATE_H_
      7 
      8 #include "base/memory/ref_counted.h"
      9 
     10 class GURL;
     11 
     12 namespace content {
     13 class BrowserContext;
     14 }
     15 
     16 namespace visitedlink {
     17 
     18 // Delegate class that clients of VisitedLinkMaster must implement.
     19 class VisitedLinkDelegate {
     20  public:
     21   // See RebuildTable.
     22   class URLEnumerator : public base::RefCountedThreadSafe<URLEnumerator> {
     23    public:
     24     // Call this with each URL to rebuild the table.
     25     virtual void OnURL(const GURL& url) = 0;
     26 
     27     // This must be called by Delegate after RebuildTable is called. |success|
     28     // indicates all URLs have been returned successfully. The URLEnumerator
     29     // object cannot be used by the delegate after this call.
     30     virtual void OnComplete(bool success) = 0;
     31 
     32    protected:
     33     virtual ~URLEnumerator() {}
     34 
     35    private:
     36     friend class base::RefCountedThreadSafe<URLEnumerator>;
     37   };
     38 
     39   // Delegate class is responsible for persisting the list of visited URLs
     40   // across browser runs. This is called by VisitedLinkMaster to repopulate
     41   // its internal table. Note that methods on enumerator can be called on any
     42   // thread but the delegate is responsible for synchronizating the calls.
     43   virtual void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) = 0;
     44 
     45  protected:
     46   virtual ~VisitedLinkDelegate() {}
     47 };
     48 
     49 }  // namespace visitedlink
     50 
     51 #endif  // COMPONENTS_VISITEDLINK_BROWSER_VISITEDLINK_DELEGATE_H_
     52