| 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 COMPONENTS_METRICS_PROFILER_TRACKING_SYNCHRONIZER_H_ | 
| 6 #define CHROME_BROWSER_METRICS_TRACKING_SYNCHRONIZER_H_ | 6 #define COMPONENTS_METRICS_PROFILER_TRACKING_SYNCHRONIZER_H_ | 
| 7 | 7 | 
| 8 #include <map> | 8 #include <map> | 
| 9 #include <string> | 9 #include <string> | 
| 10 #include <vector> | 10 #include <vector> | 
| 11 | 11 | 
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" | 
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.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 "content/public/browser/profiler_subscriber.h" | 16 #include "content/public/browser/profiler_subscriber.h" | 
| 17 | 17 | 
| 18 // This class maintains state that is used to upload profiler data from the | 18 // This class maintains state that is used to upload profiler data from the | 
| 19 // various processes, into the browser process. Such transactions are usually | 19 // various processes, into the browser process. Such transactions are usually | 
| 20 // instigated by the browser. In general, a process will respond by gathering | 20 // instigated by the browser. In general, a process will respond by gathering | 
| 21 // profiler data, and transmitting the pickled profiler data. We collect the | 21 // profiler data, and transmitting the pickled profiler data. We collect the | 
| 22 // data in asynchronous mode that doesn't block the UI thread. | 22 // data in asynchronous mode that doesn't block the UI thread. | 
| 23 // | 23 // | 
| 24 // To assure that all the processes have responded, a counter is maintained | 24 // To assure that all the processes have responded, a counter is maintained | 
| 25 // to indicate the number of pending (not yet responsive) processes. We tag | 25 // to indicate the number of pending (not yet responsive) processes. We tag | 
| 26 // each group of requests with a sequence number. For each group of requests, we | 26 // each group of requests with a sequence number. For each group of requests, we | 
| 27 // create RequestContext object which stores the sequence number, pending | 27 // create RequestContext object which stores the sequence number, pending | 
| 28 // processes and the callback_object that needs to be notified when we receive | 28 // processes and the callback_object that needs to be notified when we receive | 
| 29 // an update from processes. When an update arrives we find the RequestContext | 29 // an update from processes. When an update arrives we find the RequestContext | 
| 30 // associated with sequence number and send the unpickled profiler data to the | 30 // associated with sequence number and send the unpickled profiler data to the | 
| 31 // |callback_object_|. | 31 // |callback_object_|. | 
| 32 | 32 | 
| 33 namespace chrome_browser_metrics { | 33 namespace metrics { | 
| 34 | 34 | 
| 35 class TrackingSynchronizerObserver; | 35 class TrackingSynchronizerObserver; | 
| 36 | 36 | 
| 37 class TrackingSynchronizer | 37 class TrackingSynchronizer | 
| 38     : public content::ProfilerSubscriber, | 38     : public content::ProfilerSubscriber, | 
| 39       public base::RefCountedThreadSafe<TrackingSynchronizer> { | 39       public base::RefCountedThreadSafe<TrackingSynchronizer> { | 
| 40  public: | 40  public: | 
| 41   // Construction also sets up the global singleton instance. This instance is | 41   // Construction also sets up the global singleton instance. This instance is | 
| 42   // used to communicate between the IO and UI thread, and is destroyed only as | 42   // used to communicate between the IO and UI thread, and is destroyed only as | 
| 43   // the main thread (browser_main) terminates, which means the IO thread has | 43   // the main thread (browser_main) terminates, which means the IO thread has | 
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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 metrics | 
| 116 | 116 | 
| 117 #endif  // CHROME_BROWSER_METRICS_TRACKING_SYNCHRONIZER_H_ | 117 #endif  // COMPONENTS_METRICS_PROFILER_TRACKING_SYNCHRONIZER_H_ | 
| OLD | NEW | 
|---|