OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_H_ | 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_ | 6 #define CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // Called when a navigation is started. Propagates main frame navigation | 46 // Called when a navigation is started. Propagates main frame navigation |
47 // start to the |ascriber_| on the IO thread. NavigationHandle methods | 47 // start to the |ascriber_| on the IO thread. NavigationHandle methods |
48 // cannot be called on the IO thread, so the pointer is cast to void*. | 48 // cannot be called on the IO thread, so the pointer is cast to void*. |
49 void DidStartNavigation(content::NavigationHandle* navigation_handle); | 49 void DidStartNavigation(content::NavigationHandle* navigation_handle); |
50 | 50 |
51 // Called when the navigation is ready to be committed in a renderer. | 51 // Called when the navigation is ready to be committed in a renderer. |
52 // Propagates the event to the |ascriber_| on the IO thread. NavigationHandle | 52 // Propagates the event to the |ascriber_| on the IO thread. NavigationHandle |
53 // methods cannot be called on the IO thread, so the pointer is cast to void*. | 53 // methods cannot be called on the IO thread, so the pointer is cast to void*. |
54 void ReadyToCommitNavigation(content::NavigationHandle* navigation_handle); | 54 void ReadyToCommitNavigation(content::NavigationHandle* navigation_handle); |
55 | 55 |
56 // Called when a navigation is redirected. Propagates main frame navigation | |
57 // redirect to the |ascriber_| on the IO thread. NavigationHandle methods | |
58 // cannot be called on the IO thread, so the pointer is cast to void*. | |
59 void DidRedirectNavigation(content::NavigationHandle* navigation_handle); | |
60 | |
61 private: | 56 private: |
62 friend class ChromeDataUseAscriberServiceTest; | 57 friend class ChromeDataUseAscriberServiceTest; |
63 | 58 |
64 void SetDataUseAscriber(ChromeDataUseAscriber* ascriber); | 59 void SetDataUseAscriber(ChromeDataUseAscriber* ascriber); |
65 | 60 |
66 // |ascriber_| outlives this instance. | 61 // |ascriber_| outlives this instance. |
67 ChromeDataUseAscriber* ascriber_; | 62 ChromeDataUseAscriber* ascriber_; |
68 | 63 |
69 // Tracks whether |ascriber_| was set. This field is required because tests | 64 // Tracks whether |ascriber_| was set. This field is required because tests |
70 // might set |ascriber_| to nullptr. | 65 // might set |ascriber_| to nullptr. |
71 bool is_initialized_; | 66 bool is_initialized_; |
72 | 67 |
73 // Frame events might arrive from the UI thread before |ascriber_| is set. A | 68 // Frame events might arrive from the UI thread before |ascriber_| is set. A |
74 // queue of frame events that arrive before |ascriber_| is set is maintained | 69 // queue of frame events that arrive before |ascriber_| is set is maintained |
75 // in this field so that they can be propagated immediately after |ascriber_| | 70 // in this field so that they can be propagated immediately after |ascriber_| |
76 // is set. The RenderFrameHost pointers in the queues are valid for the | 71 // is set. The RenderFrameHost pointers in the queues are valid for the |
77 // duration that they are in the queue. | 72 // duration that they are in the queue. |
78 std::list<content::RenderFrameHost*> pending_frames_queue_; | 73 std::list<content::RenderFrameHost*> pending_frames_queue_; |
79 | 74 |
80 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriberService); | 75 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriberService); |
81 }; | 76 }; |
82 | 77 |
83 } // namespace data_use_measurement | 78 } // namespace data_use_measurement |
84 | 79 |
85 #endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_
H_ | 80 #endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_
H_ |
OLD | NEW |