OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/ui/webui/profiler_ui.h" | 18 #include "chrome/browser/ui/webui/profiler_ui.h" |
19 #include "content/common/child_process_info.h" | |
20 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/common/process_type.h" |
21 | 21 |
22 // This class maintains state that is used to upload tracking data from the | 22 // This class maintains state that is used to upload tracking data from the |
23 // various processes, into the browser process. Such transactions are usually | 23 // various processes, into the browser process. Such transactions are usually |
24 // instigated by the browser. In general, a process will respond by gathering | 24 // instigated by the browser. In general, a process will respond by gathering |
25 // tracking data, and transmitting the pickled tracking data. We collect the | 25 // tracking data, and transmitting the pickled tracking data. We collect the |
26 // data in asynchronous mode that doesn't block the UI thread. | 26 // data in asynchronous mode that doesn't block the UI thread. |
27 // | 27 // |
28 // To assure that all the processes have responded, a counter is maintained | 28 // To assure that all the processes have responded, a counter is maintained |
29 // to indicate the number of pending (not yet responsive) processes. We tag | 29 // to indicate the number of pending (not yet responsive) processes. We tag |
30 // each group of requests with a sequence number. For each group of requests, we | 30 // each group of requests with a sequence number. For each group of requests, we |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // This method is accessible on UI thread. | 103 // This method is accessible on UI thread. |
104 static void SetTrackingStatusInProcess(int process_id); | 104 static void SetTrackingStatusInProcess(int process_id); |
105 | 105 |
106 // Deserialize the tracking data and record that we have received tracking | 106 // Deserialize the tracking data and record that we have received tracking |
107 // data from a process. This method posts a task to call | 107 // data from a process. This method posts a task to call |
108 // DeserializeTrackingListOnUI on UI thread to send the |tracking_data| to | 108 // DeserializeTrackingListOnUI on UI thread to send the |tracking_data| to |
109 // callback_object_. This method is accessible on IO thread. | 109 // callback_object_. This method is accessible on IO thread. |
110 static void DeserializeTrackingList( | 110 static void DeserializeTrackingList( |
111 int sequence_number, | 111 int sequence_number, |
112 const std::string& tracking_data, | 112 const std::string& tracking_data, |
113 ChildProcessInfo::ProcessType process_type); | 113 content::ProcessType process_type); |
114 | 114 |
115 // Deserialize the tracking data and record that we have received tracking | 115 // Deserialize the tracking data and record that we have received tracking |
116 // data from a process. This method is accessible on UI thread. | 116 // data from a process. This method is accessible on UI thread. |
117 static void DeserializeTrackingListOnUI( | 117 static void DeserializeTrackingListOnUI( |
118 int sequence_number, | 118 int sequence_number, |
119 const std::string& tracking_data, | 119 const std::string& tracking_data, |
120 ChildProcessInfo::ProcessType process_type); | 120 content::ProcessType process_type); |
121 | 121 |
122 private: | 122 private: |
123 friend class base::RefCountedThreadSafe<TrackingSynchronizer>; | 123 friend class base::RefCountedThreadSafe<TrackingSynchronizer>; |
124 | 124 |
125 virtual ~TrackingSynchronizer(); | 125 virtual ~TrackingSynchronizer(); |
126 | 126 |
127 // Establish a new sequence_number_, and use it to notify all the processes of | 127 // Establish a new sequence_number_, and use it to notify all the processes of |
128 // the need to supply, to the browser, their tracking data. It also registers | 128 // the need to supply, to the browser, their tracking data. It also registers |
129 // |callback_object| in |outstanding_requests_| map. Return the | 129 // |callback_object| in |outstanding_requests_| map. Return the |
130 // sequence_number_ that was used. This method is accessible on UI thread. | 130 // sequence_number_ that was used. This method is accessible on UI thread. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // all the other threads have gone away. As a result, it is ok to call it | 175 // all the other threads have gone away. As a result, it is ok to call it |
176 // from the UI thread, or for about:tracking. | 176 // from the UI thread, or for about:tracking. |
177 static TrackingSynchronizer* tracking_synchronizer_; | 177 static TrackingSynchronizer* tracking_synchronizer_; |
178 | 178 |
179 DISALLOW_COPY_AND_ASSIGN(TrackingSynchronizer); | 179 DISALLOW_COPY_AND_ASSIGN(TrackingSynchronizer); |
180 }; | 180 }; |
181 | 181 |
182 } // namespace chrome_browser_metrics | 182 } // namespace chrome_browser_metrics |
183 | 183 |
184 #endif // CHROME_BROWSER_METRICS_TRACKING_SYNCHRONIZER_H_ | 184 #endif // CHROME_BROWSER_METRICS_TRACKING_SYNCHRONIZER_H_ |
OLD | NEW |