OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_H_ | |
6 #define CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "components/keyed_service/core/keyed_service.h" | |
10 | |
11 namespace content { | |
12 class NavigationHandle; | |
13 class RenderFrameHost; | |
14 } | |
15 | |
16 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.
| |
17 | |
18 namespace data_use_measurement { | |
19 class ChromeDataUseAscriber; | |
20 | |
21 // UI thread functionality of |ChromeDataUseAscriber|. | |
22 // | |
23 // Listens to navigation and frame events on the UI thread and propagates them | |
24 // to |ChromeDataUseAscriber| on the IO thread. This class depends on external | |
25 // WebContentsObservers to propagate events to itself because each | |
26 // WebContents instance requires its own WebContentsObserver instance. | |
27 // | |
28 // Created and destroyed on the UI thread. Public methods should only be called | |
29 // on the UI thread. | |
30 class ChromeDataUseAscriberService : public KeyedService { | |
31 public: | |
32 ChromeDataUseAscriberService(); | |
33 ~ChromeDataUseAscriberService() override; | |
34 | |
35 // Called when a render frame host is created. Propagates this information to | |
36 // |ascriber_| on the IO thread. |RenderFrameHost| methods cannot be called | |
37 // on the IO thread, so only routing IDs of |render_frame_host| and its parent | |
38 // are propagated. | |
39 void RenderFrameCreated(content::RenderFrameHost* render_frame_host); | |
40 | |
41 // Called when a render frame host is deleted. Propagates this information to | |
42 // |ascriber_| on the IO thread. |RenderFrameHost| methods cannot be called | |
43 // on the IO thread, so only routing IDs of |render_frame_host| and its parent | |
44 // are propagated. | |
45 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host); | |
46 | |
47 // Called when a navigation is started. Propagates main frame navigation | |
48 // start to the |ascriber_| on the IO thread. |NavigationHandle| methods | |
49 // cannot be called on the IO thread, so the pointer is cast to void*. | |
50 void DidStartNavigation(content::NavigationHandle* navigation_handle); | |
51 | |
52 // Called when a navigation is finished. Propagates main frame navigation | |
53 // finish to the |ascriber_| on the IO thread. |NavigationHandle| methods | |
54 // cannot be called on the IO thread, so the pointer is cast to void*. | |
55 void DidFinishNavigation(content::NavigationHandle* navigation_handle); | |
56 | |
57 // Called when a navigation is redirected. Propagates main frame navigation | |
58 // redirect to the |ascriber_| on the IO thread. |NavigationHandle| methods | |
59 // cannot be called on the IO thread, so the pointer is cast to void*. | |
60 void DidRedirectNavigation(content::NavigationHandle* navigation_handle); | |
61 | |
62 private: | |
63 friend class ChromeDataUseAscriberServiceTest; | |
64 | |
65 void InitOnIOThread(IOThread* io_thread); | |
66 void SetDataUseAscriber(ChromeDataUseAscriber* ascriber); | |
67 | |
68 // |ascriber_| outlives this instance. | |
69 ChromeDataUseAscriber* ascriber_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriberService); | |
72 }; | |
73 | |
74 } // namespace data_use_measurement | |
75 | |
76 #endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_ H_ | |
OLD | NEW |