Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Unified Diff: components/precache/content/precache_manager.h

Issue 27047003: Precache tracking database (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@precache
Patch Set: General fixes, added tests, and moved PrecacheManager into component Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..431688ca014d5fc4a3534e69de04661f231a4403
--- /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/interesting_urls_provider.h"
bengr 2013/10/23 19:03:36 actually, could this just be called a urls provide
sclittle 2013/10/24 22:11:38 Changed to URLListProvider
+#include "components/precache/core/precache_fetcher.h"
+#include "url/gurl.h"
+
+namespace content {
+class BrowserContext;
+}
+
+namespace precache {
+
+class PrecacheDatabase;
+
+// 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();
bengr 2013/10/23 19:03:36 Ah, here it is. Great!
sclittle 2013/10/24 22:11:38 You're welcome :)
+
+ // 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(InterestingURLsProvider* interesting_urls_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 is_precaching();
bengr 2013/10/23 19:03:36 I prefer IsPrecaching() because it is answering a
sclittle 2013/10/24 22:11:38 Done.
+
+ // 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 OnInterestingURLsReceived(const std::list<GURL>& interesting_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_

Powered by Google App Engine
This is Rietveld 408576698