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_ |