OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_METRICS_TRACKING_SYNCHRONIZER_H_ | 5 #ifndef CHROME_BROWSER_METRICS_TRACKING_SYNCHRONIZER_H_ |
6 #define CHROME_BROWSER_METRICS_TRACKING_SYNCHRONIZER_H_ | 6 #define CHROME_BROWSER_METRICS_TRACKING_SYNCHRONIZER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 virtual ~TrackingSynchronizer(); | 69 virtual ~TrackingSynchronizer(); |
70 | 70 |
71 // Send profiler_data back to callback_object_ by calling | 71 // Send profiler_data back to callback_object_ by calling |
72 // DecrementPendingProcessesAndSendData which records that we are waiting | 72 // DecrementPendingProcessesAndSendData which records that we are waiting |
73 // for one less profiler data from renderer or browser child process for the | 73 // for one less profiler data from renderer or browser child process for the |
74 // given sequence number. This method is accessible on UI thread. | 74 // given sequence number. This method is accessible on UI thread. |
75 virtual void OnProfilerDataCollected( | 75 virtual void OnProfilerDataCollected( |
76 int sequence_number, | 76 int sequence_number, |
77 const tracked_objects::ProcessDataSnapshot& profiler_data, | 77 const tracked_objects::ProcessDataSnapshot& profiler_data, |
78 content::ProcessType process_type) OVERRIDE; | 78 int process_type) OVERRIDE; |
79 | 79 |
80 // Establish a new sequence_number_, and use it to notify all the processes of | 80 // Establish a new sequence_number_, and use it to notify all the processes of |
81 // the need to supply, to the browser, their tracking data. It also registers | 81 // the need to supply, to the browser, their tracking data. It also registers |
82 // |callback_object| in |outstanding_requests_| map. Return the | 82 // |callback_object| in |outstanding_requests_| map. Return the |
83 // sequence_number_ that was used. This method is accessible on UI thread. | 83 // sequence_number_ that was used. This method is accessible on UI thread. |
84 int RegisterAndNotifyAllProcesses( | 84 int RegisterAndNotifyAllProcesses( |
85 const base::WeakPtr<TrackingSynchronizerObserver>& callback_object); | 85 const base::WeakPtr<TrackingSynchronizerObserver>& callback_object); |
86 | 86 |
87 // It finds the RequestContext for the given |sequence_number| and notifies | 87 // It finds the RequestContext for the given |sequence_number| and notifies |
88 // the RequestContext's |callback_object_| about the |value|. This is called | 88 // the RequestContext's |callback_object_| about the |value|. This is called |
89 // whenever we receive profiler data from processes. It also records that we | 89 // whenever we receive profiler data from processes. It also records that we |
90 // are waiting for one less profiler data from a process for the given | 90 // are waiting for one less profiler data from a process for the given |
91 // sequence number. If we have received a response from all renderers and | 91 // sequence number. If we have received a response from all renderers and |
92 // browser processes, then it calls RequestContext's DeleteIfAllDone to delete | 92 // browser processes, then it calls RequestContext's DeleteIfAllDone to delete |
93 // the entry for sequence_number. This method is accessible on UI thread. | 93 // the entry for sequence_number. This method is accessible on UI thread. |
94 void DecrementPendingProcessesAndSendData( | 94 void DecrementPendingProcessesAndSendData( |
95 int sequence_number, | 95 int sequence_number, |
96 const tracked_objects::ProcessDataSnapshot& profiler_data, | 96 const tracked_objects::ProcessDataSnapshot& profiler_data, |
97 content::ProcessType process_type); | 97 int process_type); |
98 | 98 |
99 // Get a new sequence number to be sent to processes from browser process. | 99 // Get a new sequence number to be sent to processes from browser process. |
100 // This method is accessible on UI thread. | 100 // This method is accessible on UI thread. |
101 int GetNextAvailableSequenceNumber(); | 101 int GetNextAvailableSequenceNumber(); |
102 | 102 |
103 // We don't track the actual processes that are contacted for an update, only | 103 // We don't track the actual processes that are contacted for an update, only |
104 // the count of the number of processes, and we can sometimes time-out and | 104 // the count of the number of processes, and we can sometimes time-out and |
105 // give up on a "slow to respond" process. We use a sequence_number to be | 105 // give up on a "slow to respond" process. We use a sequence_number to be |
106 // sure a response from a process is associated with the current round of | 106 // sure a response from a process is associated with the current round of |
107 // requests. All sequence numbers used are non-negative. | 107 // requests. All sequence numbers used are non-negative. |
108 // last_used_sequence_number_ is the most recently used number (used to avoid | 108 // last_used_sequence_number_ is the most recently used number (used to avoid |
109 // reuse for a long time). | 109 // reuse for a long time). |
110 int last_used_sequence_number_; | 110 int last_used_sequence_number_; |
111 | 111 |
112 DISALLOW_COPY_AND_ASSIGN(TrackingSynchronizer); | 112 DISALLOW_COPY_AND_ASSIGN(TrackingSynchronizer); |
113 }; | 113 }; |
114 | 114 |
115 } // namespace chrome_browser_metrics | 115 } // namespace chrome_browser_metrics |
116 | 116 |
117 #endif // CHROME_BROWSER_METRICS_TRACKING_SYNCHRONIZER_H_ | 117 #endif // CHROME_BROWSER_METRICS_TRACKING_SYNCHRONIZER_H_ |
OLD | NEW |