OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_HISTOGRAM_CONTROLLER_H_ |
| 6 #define CONTENT_BROWSER_HISTOGRAM_CONTROLLER_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/memory/singleton.h" |
| 12 #include "base/process.h" |
| 13 #include "content/common/content_export.h" |
| 14 #include "content/public/common/process_type.h" |
| 15 |
| 16 namespace content { |
| 17 |
| 18 class HistogramSubscriber; |
| 19 |
| 20 // HistogramController is used on the browser process to collect histogram data. |
| 21 // Only the browser UI thread is allowed to interact with the |
| 22 // HistogramController object. |
| 23 class HistogramController { |
| 24 public: |
| 25 // Returns the HistogramController object for the current process, or NULL if |
| 26 // none. |
| 27 static HistogramController* GetInstance(); |
| 28 |
| 29 // Normally instantiated when the child process is launched. Only one instance |
| 30 // should be created per process. |
| 31 HistogramController(); |
| 32 virtual ~HistogramController(); |
| 33 |
| 34 // Register the subscriber so that it will be called when for example |
| 35 // OnHistogramDataCollected is returning histogram data from a child process. |
| 36 // This is called on UI thread. |
| 37 void Register(HistogramSubscriber* subscriber); |
| 38 |
| 39 // Unregister the subscriber so that it will not be called when for example |
| 40 // OnHistogramDataCollected is returning histogram data from a child process. |
| 41 // Safe to call even if caller is not the current subscriber. |
| 42 void Unregister(const HistogramSubscriber* subscriber); |
| 43 |
| 44 // Contact all processes and get their histogram data. |
| 45 void GetHistogramData(int sequence_number); |
| 46 |
| 47 // Notify the |subscriber_| that it should expect at least |pending_processes| |
| 48 // additional calls to OnHistogramDataCollected(). OnPendingProcess() may be |
| 49 // called repeatedly; the last call will have |end| set to true, indicating |
| 50 // that there is no longer a possibility for the count of pending processes to |
| 51 // increase. This is called on the UI thread. |
| 52 void OnPendingProcesses(int sequence_number, int pending_processes, bool end); |
| 53 |
| 54 // Send the |histogram| back to the |subscriber_|. |
| 55 // This can be called from any thread. |
| 56 void OnHistogramDataCollected( |
| 57 int sequence_number, |
| 58 const std::vector<std::string>& pickled_histograms); |
| 59 |
| 60 private: |
| 61 friend struct DefaultSingletonTraits<HistogramController>; |
| 62 |
| 63 // Contact child processes and get their histogram data. |
| 64 void GetHistogramDataFromChildProcesses(int sequence_number); |
| 65 |
| 66 HistogramSubscriber* subscriber_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(HistogramController); |
| 69 }; |
| 70 |
| 71 } // namespace content |
| 72 |
| 73 #endif // CONTENT_BROWSER_HISTOGRAM_CONTROLLER_H_ |
OLD | NEW |