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

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

Issue 2285903002: Framework to ascribe all network data use to a source. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 4 years, 3 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/data_use_measurement/data_use_web_contents_observer.h
diff --git a/chrome/browser/data_use_measurement/data_use_web_contents_observer.h b/chrome/browser/data_use_measurement/data_use_web_contents_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..6acdbd723080c2c2f2738ca92245b4ca09b7ea2a
--- /dev/null
+++ b/chrome/browser/data_use_measurement/data_use_web_contents_observer.h
@@ -0,0 +1,67 @@
+// 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_DATA_USE_MEASUREMENT_DATA_USE_WEB_CONTENTS_OBSERVER_H_
+#define CHROME_BROWSER_DATA_USE_MEASUREMENT_DATA_USE_WEB_CONTENTS_OBSERVER_H_
+
+#include "base/macros.h"
+#include "content/public/browser/web_contents_observer.h"
+#include "content/public/browser/web_contents_user_data.h"
+
+namespace content {
+class NavigationHandle;
+class RenderFrameHost;
+}
+
+namespace data_use_measurement {
+
+class ChromeDataUseAscriberService;
+
+// Forwards navigation and frame events to |ChromeDataUseAscriberService|.
+class DataUseWebContentsObserver
+ : public content::WebContentsObserver,
+ public content::WebContentsUserData<DataUseWebContentsObserver> {
+ public:
+ // Creates a |DataUseWebContentsObserver| for the given |WebContents| and
+ // |ChromeDataUseAscriberService|.
+ static void CreateForWebContents(content::WebContents* web_contents,
+ ChromeDataUseAscriberService* service);
+
+ ~DataUseWebContentsObserver() override;
+
+ // Called when a render frame host is created. Propagates this event to
Lei Zhang 2016/09/08 22:04:43 Just write a class summary to explain this class f
Not at Google. Contact bengr 2016/09/09 18:37:16 Done.
+ // |ChromeDataUseAscriberService|.
+ void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
+
+ // Called when a render frame host is deleted. Propagates this event to
+ // |ChromeDataUseAscriberService|.
+ void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
+
+ // Called when a navigation is started. Propagates this event to
+ // |ChromeDataUseAscriberService|.
+ void DidStartNavigation(
+ content::NavigationHandle* navigation_handle) override;
+
+ // Called when a navigation is completed. Propagates this event to
+ // |ChromeDataUseAscriberService|.
+ void DidFinishNavigation(
+ content::NavigationHandle* navigation_handle) override;
+
+ // Called when a navigation is redirected. Propagates this event to
+ // |ChromeDataUseAscriberService|.
+ void DidRedirectNavigation(
+ content::NavigationHandle* navigation_handle) override;
+
+ private:
+ explicit DataUseWebContentsObserver(content::WebContents* web_contents,
Lei Zhang 2016/09/08 22:04:43 Multiple parameters - not explicit.
Not at Google. Contact bengr 2016/09/09 18:37:17 Done.
+ ChromeDataUseAscriberService* service);
+ friend class content::WebContentsUserData<DataUseWebContentsObserver>;
Lei Zhang 2016/09/08 22:04:43 Put the friend first and add a blank line before t
Not at Google. Contact bengr 2016/09/09 18:37:16 Done.
+ ChromeDataUseAscriberService* service_;
Lei Zhang 2016/09/08 22:04:43 ChromeDataUseAscriberService* const service_;
Not at Google. Contact bengr 2016/09/09 18:37:17 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(DataUseWebContentsObserver);
+};
+
+} // namespace data_use_measurement
+
+#endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_DATA_USE_WEB_CONTENTS_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698