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

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

Issue 1373363005: Add a delay to Site Engagement tracking after navigation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comment Created 5 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
« no previous file with comments | « no previous file | chrome/browser/engagement/site_engagement_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/engagement/site_engagement_helper.h
diff --git a/chrome/browser/engagement/site_engagement_helper.h b/chrome/browser/engagement/site_engagement_helper.h
index bd4565009ed646d6cbf99d83d9a5eeef7fdc551e..3077afb5a579a9866458c5d1bf79c86dc951573a 100644
--- a/chrome/browser/engagement/site_engagement_helper.h
+++ b/chrome/browser/engagement/site_engagement_helper.h
@@ -26,7 +26,18 @@ class SiteEngagementHelper
public:
~SiteEngagementHelper() override;
- static void SetSecondsBetweenUserInputCheck(double seconds);
+ static void SetSecondsBetweenUserInputCheck(int seconds);
+ static void SetSecondsTrackingDelayAfterNavigation(int seconds);
+ static void SetSecondsTrackingDelayAfterShow(int seconds);
+
+ // content::WebContentsObserver overrides.
+ void DidNavigateMainFrame(
+ const content::LoadCommittedDetails& details,
+ const content::FrameNavigateParams& params) override;
+ void RenderViewHostChanged(content::RenderViewHost* old_host,
+ content::RenderViewHost* new_host) override;
+ void WasShown() override;
+ void WasHidden() override;
private:
// Class to encapsulate the user input listening.
@@ -51,30 +62,45 @@ class SiteEngagementHelper
// Callback to handle mouse events from the RenderViewHost.
bool HandleMouseEvent(const blink::WebMouseEvent& event);
- // Register callbacks to listen for user input.
- void StartTracking(content::RenderViewHost* host);
+ // Begin tracking input after |initial_delay|.
+ void Start(content::RenderViewHost* host, base::TimeDelta initial_delay);
- // Pause listening for user input, restarting listening after
- // g_seconds_between_user_input_check seconds.
- void PauseTracking(content::RenderViewHost* host);
+ // Pause listening for user input, restarting listening after a delay.
+ void Pause();
- // Restart listening for user input.
- void ResumeTracking();
+ // Switches the InputTracker to another RenderViewHost, respecting the pause
+ // timer state.
+ void SwitchRenderViewHost(content::RenderViewHost* old_host,
+ content::RenderViewHost* new_host);
// Stop listening for user input.
- void StopTracking(content::RenderViewHost* host);
+ void Stop();
- // Set the timer object for testing purposes.
- void SetTimerForTesting(scoped_ptr<base::Timer> timer);
+ // Returns whether the InputTracker has been started for a RenderViewHost.
+ bool is_active() const { return is_active_; }
- bool callbacks_added() { return callbacks_added_; }
+ // Returns whether input tracking callbacks have been added to
+ // RenderViewHost.
+ bool is_tracking() const { return is_tracking_; }
+
+ // Set the timer object for testing purposes.
+ void SetPauseTimerForTesting(scoped_ptr<base::Timer> timer);
private:
+ // Starts the timer for adding callbacks to the RenderViewHost.
+ void StartTimer(base::TimeDelta delay);
+
+ // Adds/removes tracking callbacks to the RenderViewHost.
+ void AddCallbacks();
+ void RemoveCallbacks();
+
SiteEngagementHelper* helper_;
scoped_ptr<base::Timer> pause_timer_;
+ content::RenderViewHost* host_;
content::RenderWidgetHost::KeyPressEventCallback key_press_event_callback_;
content::RenderWidgetHost::MouseEventCallback mouse_event_callback_;
- bool callbacks_added_;
+ bool is_active_;
+ bool is_tracking_;
};
explicit SiteEngagementHelper(content::WebContents* web_contents);
@@ -85,19 +111,6 @@ class SiteEngagementHelper
// current contents location.
void RecordUserInput(SiteEngagementMetrics::EngagementType type);
- bool ShouldRecordEngagement();
-
- // content::WebContentsObserver overrides.
- void DidNavigateMainFrame(
- const content::LoadCommittedDetails& details,
- const content::FrameNavigateParams& params) override;
-
- void RenderViewHostChanged(content::RenderViewHost* old_host,
- content::RenderViewHost* new_host) override;
-
- void WasShown() override;
- void WasHidden() override;
-
InputTracker input_tracker_;
bool record_engagement_;
« no previous file with comments | « no previous file | chrome/browser/engagement/site_engagement_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698