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

Unified Diff: chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.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/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
new file mode 100644
index 0000000000000000000000000000000000000000..6446bad92a92f1d4a780747ee3d7a1545f5d9747
--- /dev/null
+++ b/chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.h
@@ -0,0 +1,76 @@
+// 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_CHROME_DATA_USE_ASCRIBER_SERVICE_H_
+#define CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_H_
+
+#include "base/macros.h"
+#include "components/keyed_service/core/keyed_service.h"
+
+namespace content {
+class NavigationHandle;
+class RenderFrameHost;
+}
+
+class IOThread;
Lei Zhang 2016/09/08 22:04:43 I'd put this before all the fwrd decls with namesp
Not at Google. Contact bengr 2016/09/09 18:37:16 Done.
+
+namespace data_use_measurement {
+class ChromeDataUseAscriber;
+
+// UI thread functionality of |ChromeDataUseAscriber|.
+//
+// Listens to navigation and frame events on the UI thread and propagates them
+// to |ChromeDataUseAscriber| on the IO thread. This class depends on external
+// WebContentsObservers to propagate events to itself because each
+// WebContents instance requires its own WebContentsObserver instance.
+//
+// Created and destroyed on the UI thread. Public methods should only be called
+// on the UI thread.
+class ChromeDataUseAscriberService : public KeyedService {
+ public:
+ ChromeDataUseAscriberService();
+ ~ChromeDataUseAscriberService() override;
+
+ // Called when a render frame host is created. Propagates this information to
+ // |ascriber_| on the IO thread. |RenderFrameHost| methods cannot be called
+ // on the IO thread, so only routing IDs of |render_frame_host| and its parent
+ // are propagated.
+ void RenderFrameCreated(content::RenderFrameHost* render_frame_host);
+
+ // Called when a render frame host is deleted. Propagates this information to
+ // |ascriber_| on the IO thread. |RenderFrameHost| methods cannot be called
+ // on the IO thread, so only routing IDs of |render_frame_host| and its parent
+ // are propagated.
+ void RenderFrameDeleted(content::RenderFrameHost* render_frame_host);
+
+ // Called when a navigation is started. Propagates main frame navigation
+ // start to the |ascriber_| on the IO thread. |NavigationHandle| methods
+ // cannot be called on the IO thread, so the pointer is cast to void*.
+ void DidStartNavigation(content::NavigationHandle* navigation_handle);
+
+ // Called when a navigation is finished. Propagates main frame navigation
+ // finish to the |ascriber_| on the IO thread. |NavigationHandle| methods
+ // cannot be called on the IO thread, so the pointer is cast to void*.
+ void DidFinishNavigation(content::NavigationHandle* navigation_handle);
+
+ // Called when a navigation is redirected. Propagates main frame navigation
+ // redirect to the |ascriber_| on the IO thread. |NavigationHandle| methods
+ // cannot be called on the IO thread, so the pointer is cast to void*.
+ void DidRedirectNavigation(content::NavigationHandle* navigation_handle);
+
+ private:
+ friend class ChromeDataUseAscriberServiceTest;
+
+ void InitOnIOThread(IOThread* io_thread);
+ void SetDataUseAscriber(ChromeDataUseAscriber* ascriber);
+
+ // |ascriber_| outlives this instance.
+ ChromeDataUseAscriber* ascriber_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriberService);
+};
+
+} // namespace data_use_measurement
+
+#endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698