| Index: components/precache/content/precache_manager.h
 | 
| diff --git a/components/precache/content/precache_manager.h b/components/precache/content/precache_manager.h
 | 
| new file mode 100644
 | 
| index 0000000000000000000000000000000000000000..c11e61d9f9ab446a9a0fd8cc8287fb65ee9adaab
 | 
| --- /dev/null
 | 
| +++ b/components/precache/content/precache_manager.h
 | 
| @@ -0,0 +1,89 @@
 | 
| +// Copyright 2013 The Chromium Authors. All rights reserved.
 | 
| +// Use of this source code is governed by a BSD-style license that can be
 | 
| +// found in the LICENSE file.
 | 
| +
 | 
| +#ifndef COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_
 | 
| +#define COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_
 | 
| +
 | 
| +#include <list>
 | 
| +
 | 
| +#include "base/memory/ref_counted.h"
 | 
| +#include "base/memory/scoped_ptr.h"
 | 
| +#include "base/synchronization/lock.h"
 | 
| +#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
 | 
| +#include "components/precache/core/precache_fetcher.h"
 | 
| +#include "url/gurl.h"
 | 
| +
 | 
| +namespace content {
 | 
| +class BrowserContext;
 | 
| +}
 | 
| +
 | 
| +namespace precache {
 | 
| +
 | 
| +class PrecacheDatabase;
 | 
| +class URLListProvider;
 | 
| +
 | 
| +// Class that manages all precaching-related activities. Owned by the
 | 
| +// BrowserContext that it is constructed for. Use
 | 
| +// PrecacheManagerFactory::GetForBrowserContext to get an instance of this
 | 
| +// class.
 | 
| +// TODO(sclittle): Delete precache history when browsing history is deleted.
 | 
| +class PrecacheManager : public BrowserContextKeyedService,
 | 
| +                        PrecacheFetcher::PrecacheDelegate {
 | 
| + public:
 | 
| +  explicit PrecacheManager(content::BrowserContext* browser_context);
 | 
| +  virtual ~PrecacheManager();
 | 
| +
 | 
| +  // Returns true if precaching is enabled by either Finch or the command line
 | 
| +  // flag.
 | 
| +  static bool IsPrecachingEnabled();
 | 
| +
 | 
| +  // From BrowserContextKeyedService.
 | 
| +  virtual void Shutdown() OVERRIDE;
 | 
| +
 | 
| +  // From PrecacheFetcher::PrecacheDelegate.
 | 
| +  virtual void OnDone() OVERRIDE;
 | 
| +
 | 
| +  // Starts precaching resources that the user is predicted to fetch in the
 | 
| +  // future. If precaching is already currently in progress, then this method
 | 
| +  // does nothing. Must be called on the UI thread.
 | 
| +  void StartPrecaching(URLListProvider* url_list_provider);
 | 
| +
 | 
| +  // Cancels precaching if it is in progress. Must be called on the UI thread.
 | 
| +  void CancelPrecaching();
 | 
| +
 | 
| +  // Returns true if precaching is currently in progress, or false otherwise.
 | 
| +  // May be called from any thread.
 | 
| +  bool IsPrecaching();
 | 
| +
 | 
| +  // Returns the PrecacheDatabase used for tracking precache metrics. This
 | 
| +  // method can be called on any thread, but methods on the PrecacheDatabase
 | 
| +  // should only be used on the DB thread.
 | 
| +  scoped_refptr<PrecacheDatabase> precache_database();
 | 
| +
 | 
| + private:
 | 
| +  void OnURLsReceived(const std::list<GURL>& urls);
 | 
| +
 | 
| +  // The browser context that owns this PrecacheManager.
 | 
| +  content::BrowserContext* browser_context_;
 | 
| +
 | 
| +  // The PrecacheFetcher used to precache resources. Should only be used on the
 | 
| +  // UI thread.
 | 
| +  scoped_ptr<PrecacheFetcher> precache_fetcher_;
 | 
| +
 | 
| +  // The PrecacheDatabase for tracking precache metrics. Should only be used on
 | 
| +  // the DB thread.
 | 
| +  scoped_refptr<PrecacheDatabase> precache_database_;
 | 
| +
 | 
| +  // Flag indicating whether or not precaching is currently in progress.
 | 
| +  bool is_precaching_;
 | 
| +
 | 
| +  // Lock for |is_precaching_|.
 | 
| +  base::Lock lock_;
 | 
| +
 | 
| +  DISALLOW_COPY_AND_ASSIGN(PrecacheManager);
 | 
| +};
 | 
| +
 | 
| +}  // namespace precache
 | 
| +
 | 
| +#endif  // COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_
 | 
| 
 |