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

Unified Diff: components/password_manager/core/browser/affiliation_backend.h

Issue 947563002: Add prefetch support to AffiliationBackend. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove 'stale' accessor, cleaned up timelines for tests, extended/fixed some tests. Created 5 years, 9 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
« no previous file with comments | « components/components_tests.gyp ('k') | components/password_manager/core/browser/affiliation_backend.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/password_manager/core/browser/affiliation_backend.h
diff --git a/components/password_manager/core/browser/affiliation_backend.h b/components/password_manager/core/browser/affiliation_backend.h
index eea5e3d7a55ecb5850863ce8f1c2b52bc5f50a31..0e1558a08a65857bd106cd1b9eb114b6c2cd503c 100644
--- a/components/password_manager/core/browser/affiliation_backend.h
+++ b/components/password_manager/core/browser/affiliation_backend.h
@@ -41,20 +41,20 @@ class FacetManager;
//
// This class is not thread-safe, but it is fine to construct it on one thread
// and then transfer it to the background thread for the rest of its life.
-// Initialize() must be called already on the background thread.
+// Initialize() must be called already on the final (background) thread.
class AffiliationBackend : public FacetManagerHost,
public AffiliationFetcherDelegate {
public:
// Constructs an instance that will use |request_context_getter| for all
// network requests, and will rely on |time_source| to tell the current time,
- // which is expected to always be strictly greater than the NULL time.
+ // which is expected to always be no less than the Unix epoch.
// Construction is very cheap, expensive steps are deferred to Initialize().
AffiliationBackend(
const scoped_refptr<net::URLRequestContextGetter>& request_context_getter,
scoped_ptr<base::Clock> time_source);
~AffiliationBackend() override;
- // Performs the I/O-heavy part of initialization. The database to cache
+ // Performs the I/O-heavy part of initialization. The database used to cache
// affiliation information locally will be opened/created at |db_path|.
void Initialize(const base::FilePath& db_path);
@@ -71,17 +71,27 @@ class AffiliationBackend : public FacetManagerHost,
void TrimCache();
private:
+ friend class AffiliationBackendTest;
+
+ // Retrieves the FacetManager corresponding to |facet_uri|, creating it and
+ // storing it into |facet_managers_| if it did not exist.
+ FacetManager* GetOrCreateFacetManager(const FacetURI& facet_uri);
+
// Collects facet URIs that require fetching and issues a network request
// against the Affiliation API to fetch corresponding affiliation information.
void SendNetworkRequest();
+ // Scheduled by RequestNotificationAtTime() to be called back at times when a
+ // FacetManager needs to be notified.
+ void OnSendNotification(const FacetURI& facet_uri);
+
// FacetManagerHost:
- base::Time GetCurrentTime() override;
- base::Time ReadLastUpdateTimeFromDatabase(const FacetURI& facet_uri) override;
bool ReadAffiliationsFromDatabase(
const FacetURI& facet_uri,
AffiliatedFacetsWithUpdateTime* affiliations) override;
void SignalNeedNetworkRequest() override;
+ void RequestNotificationAtTime(const FacetURI& facet_uri,
+ base::Time time) override;
// AffiliationFetcherDelegate:
void OnFetchSucceeded(
@@ -89,6 +99,9 @@ class AffiliationBackend : public FacetManagerHost,
void OnFetchFailed() override;
void OnMalformedResponse() override;
+ // Used only for testing.
+ size_t facet_manager_count_for_testing() { return facet_managers_.size(); }
+
// Created in Initialize(), and ensures that all subsequent methods are called
// on the same thread.
scoped_ptr<base::ThreadChecker> thread_checker_;
« no previous file with comments | « components/components_tests.gyp ('k') | components/password_manager/core/browser/affiliation_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698