1 // Copyright 2014 The Chromium Authors 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 COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_ 6 #define COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_ 7 8 #include <stddef.h> 9 10 #include <memory> 11 12 #include "components/metrics/metrics_log.h" 13 14 namespace metrics { 15 16 // Manages all the log objects used by a MetricsService implementation. 17 // TODO(crbug/1052796): Remove this class, and replace uses of this class with 18 // just a unique_ptr<MetricsLog>. 19 class MetricsLogManager { 20 public: 21 MetricsLogManager(); 22 23 MetricsLogManager(const MetricsLogManager&) = delete; 24 MetricsLogManager& operator=(const MetricsLogManager&) = delete; 25 26 ~MetricsLogManager(); 27 28 // Makes |log| the current_log. This should only be called if there is not a 29 // current log. 30 void BeginLoggingWithLog(std::unique_ptr<MetricsLog> log); 31 32 // Returns the in-progress log. current_log()33 MetricsLog* current_log() { return current_log_.get(); } 34 35 // Releases |current_log_| and transfers ownership to the caller. 36 std::unique_ptr<MetricsLog> ReleaseCurrentLog(); 37 38 private: 39 // The log that we are still appending to. 40 std::unique_ptr<MetricsLog> current_log_; 41 }; 42 43 } // namespace metrics 44 45 #endif // COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_ 46