| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // |ascriber_| on the IO thread. RenderFrameHost methods cannot be called | 43 // |ascriber_| on the IO thread. RenderFrameHost methods cannot be called |
| 44 // on the IO thread, so only routing IDs of |render_frame_host| and its parent | 44 // on the IO thread, so only routing IDs of |render_frame_host| and its parent |
| 45 // are propagated. | 45 // are propagated. |
| 46 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host); | 46 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host); |
| 47 | 47 |
| 48 // Called when a navigation is started. Propagates main frame navigation | 48 // Called when a navigation is started. Propagates main frame navigation |
| 49 // start to the |ascriber_| on the IO thread. NavigationHandle methods | 49 // start to the |ascriber_| on the IO thread. NavigationHandle methods |
| 50 // cannot be called on the IO thread, so the pointer is cast to void*. | 50 // cannot be called on the IO thread, so the pointer is cast to void*. |
| 51 void DidStartNavigation(content::NavigationHandle* navigation_handle); | 51 void DidStartNavigation(content::NavigationHandle* navigation_handle); |
| 52 | 52 |
| 53 // Called when the navigation is ready to be committed in a renderer. | 53 // Called when a navigation is finished. Propagates main frame navigation |
| 54 // Propagates the event to the |ascriber_| on the IO thread. NavigationHandle | 54 // finish to the |ascriber_| on the IO thread. NavigationHandle methods |
| 55 // methods cannot be called on the IO thread, so the pointer is cast to void*. | 55 // cannot be called on the IO thread, so the pointer is cast to void*. |
| 56 void ReadyToCommitNavigation(content::NavigationHandle* navigation_handle); | 56 void DidFinishNavigation(content::NavigationHandle* navigation_handle); |
| 57 | 57 |
| 58 // Called when a navigation is redirected. Propagates main frame navigation | 58 // Called when a navigation is redirected. Propagates main frame navigation |
| 59 // redirect to the |ascriber_| on the IO thread. NavigationHandle methods | 59 // redirect to the |ascriber_| on the IO thread. NavigationHandle methods |
| 60 // cannot be called on the IO thread, so the pointer is cast to void*. | 60 // cannot be called on the IO thread, so the pointer is cast to void*. |
| 61 void DidRedirectNavigation(content::NavigationHandle* navigation_handle); | 61 void DidRedirectNavigation(content::NavigationHandle* navigation_handle); |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 friend class ChromeDataUseAscriberServiceTest; | 64 friend class ChromeDataUseAscriberServiceTest; |
| 65 | 65 |
| 66 void SetDataUseAscriber(ChromeDataUseAscriber* ascriber); | 66 void SetDataUseAscriber(ChromeDataUseAscriber* ascriber); |
| 67 | 67 |
| 68 // |ascriber_| outlives this instance. | 68 // |ascriber_| outlives this instance. |
| 69 ChromeDataUseAscriber* ascriber_; | 69 ChromeDataUseAscriber* ascriber_; |
| 70 | 70 |
| 71 // Tracks whether |ascriber_| was set. This field is required because tests | 71 // Tracks whether |ascriber_| was set. This field is required because tests |
| 72 // might set |ascriber_| to nullptr. | 72 // might set |ascriber_| to nullptr. |
| 73 bool is_initialized_; | 73 bool is_initialized_; |
| 74 | 74 |
| 75 // Frame events might arrive from the UI thread before |ascriber_| is set. A | 75 // Frame and navigation events might arrive from the UI thread before |
| 76 // queue of frame events that arrive before |ascriber_| is set is maintained | 76 // |ascriber_| is set. A queue of frame and navigation events that arrive |
| 77 // in this field so that they can be propagated immediately after |ascriber_| | 77 // before |ascriber_| is set are maintained in these fields so that they can |
| 78 // is set. The RenderFrameHost pointers in the queues are valid for the | 78 // be propagated immediately after |ascriber_| is set. The RenderFrameHost |
| 79 // duration that they are in the queue. | 79 // and NavigationHandle pointers in the queues are valid for the duration that |
| 80 // they are in the queue. |
| 80 std::list<content::RenderFrameHost*> pending_frames_queue_; | 81 std::list<content::RenderFrameHost*> pending_frames_queue_; |
| 82 std::list<content::NavigationHandle*> pending_navigations_queue_; |
| 81 | 83 |
| 82 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriberService); | 84 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriberService); |
| 83 }; | 85 }; |
| 84 | 86 |
| 85 } // namespace data_use_measurement | 87 } // namespace data_use_measurement |
| 86 | 88 |
| 87 #endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_
H_ | 89 #endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_
H_ |
| OLD | NEW |