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

Unified Diff: chrome/browser/engagement/site_engagement_observer.h

Issue 1986033002: Implement an observer interface for the site engagement service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@site-engagement-refactor
Patch Set: Rebase to fix leak Created 4 years, 6 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: chrome/browser/engagement/site_engagement_observer.h
diff --git a/chrome/browser/engagement/site_engagement_observer.h b/chrome/browser/engagement/site_engagement_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..d76726f12bf57812aeea196332ea342b771040dd
--- /dev/null
+++ b/chrome/browser/engagement/site_engagement_observer.h
@@ -0,0 +1,51 @@
+// Copyright 2016 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 CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_OBSERVER_H_
+#define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_OBSERVER_H_
+
+#include "base/gtest_prod_util.h"
+#include "base/macros.h"
+
+namespace content {
+class WebContents;
+}
+
+class GURL;
+class SiteEngagementService;
+
+class SiteEngagementObserver {
+ public:
+ // Called when the engagement for |url| loaded in |web_contents| increases to
+ // |score|. |is_hidden| is true if the engagement occurred when |web_contents|
+ // was hidden (e.g. in the background).
benwells 2016/06/11 09:31:23 Why is the hidden field necessary?
dominickn 2016/06/11 15:05:50 Passing it through means that clients don't need t
benwells 2016/06/14 07:25:34 Let's chat about this. I think it would be better
+ // This method may be run on user input, so observers *must not* perform any
+ // expensive tasks here.
+ virtual void OnEngagementIncreased(content::WebContents* web_contents,
+ const GURL& url,
+ double score,
+ bool is_hidden) {}
+
+ protected:
+ explicit SiteEngagementObserver(SiteEngagementService* service);
+
+ SiteEngagementObserver();
+
+ ~SiteEngagementObserver();
+
+ // Returns the site engagement service which this object is observing.
+ SiteEngagementService* GetSiteEngagementService() const;
+
+ // Begin observing |service| for engagement increases.
+ // To stop observing, call Observe(nullptr).
+ void Observe(SiteEngagementService* service);
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, Observers);
+ SiteEngagementService* service_;
+
+ DISALLOW_COPY_AND_ASSIGN(SiteEngagementObserver);
+};
+
+#endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698