1 // Copyright 2012 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_CHILD_HISTOGRAM_FETCHER_IMPL_H_ 6 #define COMPONENTS_METRICS_CHILD_HISTOGRAM_FETCHER_IMPL_H_ 7 8 #include <memory> 9 #include <string> 10 #include <vector> 11 12 #include "base/memory/unsafe_shared_memory_region.h" 13 #include "components/metrics/public/mojom/histogram_fetcher.mojom.h" 14 #include "mojo/public/cpp/bindings/pending_receiver.h" 15 16 namespace base { 17 class HistogramDeltaSerialization; 18 } // namespace base 19 20 namespace metrics { 21 22 class ChildHistogramFetcherFactoryImpl 23 : public mojom::ChildHistogramFetcherFactory { 24 public: 25 ChildHistogramFetcherFactoryImpl(); 26 ~ChildHistogramFetcherFactoryImpl() override; 27 28 static void Create( 29 mojo::PendingReceiver<mojom::ChildHistogramFetcherFactory>); 30 31 private: 32 // mojom::ChildHistogramFetcherFactory: 33 void CreateFetcher( 34 base::UnsafeSharedMemoryRegion, 35 mojo::PendingReceiver<mojom::ChildHistogramFetcher>) override; 36 }; 37 38 class ChildHistogramFetcherImpl : public mojom::ChildHistogramFetcher { 39 public: 40 ChildHistogramFetcherImpl(); 41 42 ChildHistogramFetcherImpl(const ChildHistogramFetcherImpl&) = delete; 43 ChildHistogramFetcherImpl& operator=(const ChildHistogramFetcherImpl&) = 44 delete; 45 46 ~ChildHistogramFetcherImpl() override; 47 48 private: 49 // mojom::ChildHistogramFetcher: 50 void GetChildNonPersistentHistogramData( 51 GetChildNonPersistentHistogramDataCallback callback) override; 52 void Ping(mojom::UmaPingCallSource call_source, 53 PingCallback callback) override; 54 55 // Extract snapshot data and then send it off to the Browser process. 56 // Send only a delta to what we have already sent. 57 void UploadAllHistograms(int64_t sequence_number); 58 59 // Prepares histogram deltas for transmission. 60 std::unique_ptr<base::HistogramDeltaSerialization> 61 histogram_delta_serialization_; 62 }; 63 64 } // namespace metrics 65 66 #endif // COMPONENTS_METRICS_CHILD_HISTOGRAM_FETCHER_IMPL_H_ 67