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

Side by Side 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: Addressed nits 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 unified diff | Download patch
OLDNEW
(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 class IOThread;
12
13 namespace content {
14 class NavigationHandle;
15 class RenderFrameHost;
16 }
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 SetDataUseAscriber(ChromeDataUseAscriber* ascriber);
66
67 // |ascriber_| outlives this instance.
68 ChromeDataUseAscriber* ascriber_;
69
70 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriberService);
71 };
72
73 } // namespace data_use_measurement
74
75 #endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698