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

Unified Diff: chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.h

Issue 2572823002: Propogate the tab foreground, background change events to data use (Closed)
Patch Set: Fix trybot failure Created 4 years 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/data_use_measurement/chrome_data_use_ascriber_service.h
diff --git a/chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.h b/chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.h
index ce7782ea0e5c3f665ee174f97bdfbf229e2313e1..522813d06c39e802311646ece59bf229a5ca0c76 100644
--- a/chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.h
+++ b/chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_H_
#include <list>
+#include <unordered_set>
#include "base/macros.h"
#include "components/keyed_service/core/keyed_service.h"
@@ -53,6 +54,15 @@ class ChromeDataUseAscriberService : public KeyedService {
// methods cannot be called on the IO thread, so the pointer is cast to void*.
void ReadyToCommitNavigation(content::NavigationHandle* navigation_handle);
+ // Called every time the WebContents changes visibility. Propagates the event
+ // to the |ascriber_| on the IO thread.
+ void WasShownOrHidden(content::RenderFrameHost* main_render_frame_host,
+ bool visible);
+
+ // Called when one of the render frames of a WebContents is swapped.
+ void RenderFrameHostChanged(content::RenderFrameHost* old_host,
+ content::RenderFrameHost* new_host);
+
private:
friend class ChromeDataUseAscriberServiceTest;
@@ -72,6 +82,11 @@ class ChromeDataUseAscriberService : public KeyedService {
// duration that they are in the queue.
std::list<content::RenderFrameHost*> pending_frames_queue_;
+ // WebContents visibility change events might arrive from the UI thread before
+ // |ascriber_| is set. Sucn pending main render frame visibile events are
+ // maintained in this set and propagated immediately after |ascriber_| is set.
+ std::unordered_set<content::RenderFrameHost*> pending_visible_main_frames_;
+
DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriberService);
};

Powered by Google App Engine
This is Rietveld 408576698