Chromium Code Reviews| Index: components/rappor/public/rappor_public_service.h |
| diff --git a/components/rappor/public/rappor_public_service.h b/components/rappor/public/rappor_public_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..92da2a67f3260976e96215cd71fbf5ba9f8110e5 |
| --- /dev/null |
| +++ b/components/rappor/public/rappor_public_service.h |
| @@ -0,0 +1,44 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
|
ncarter (slow)
2016/12/05 19:50:50
2016 (I think you missed this)
Navid Zolghadr
2016/12/06 19:10:33
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_RAPPOR_PUBLIC_RAPPOR_PUBLIC_SERVICE_H_ |
|
ncarter (slow)
2016/12/05 19:50:50
This file should be renamed to rappor/public/rappo
Navid Zolghadr
2016/12/06 19:10:33
Done.
|
| +#define COMPONENTS_RAPPOR_PUBLIC_RAPPOR_PUBLIC_SERVICE_H_ |
| + |
| +#include <memory> |
| +#include <string> |
| + |
| +#include "base/memory/weak_ptr.h" |
| +#include "components/rappor/public/rappor_parameters.h" |
| +#include "components/rappor/public/sample.h" |
| + |
| +namespace rappor { |
| + |
| +// This class provides a public interface for recording samples for rappor |
| +// metrics, which other components can be depended on. |
| +class RapporService : public base::SupportsWeakPtr<RapporService> { |
| + public: |
| + // Constructs a Sample object for the caller to record fields in. |
| + virtual std::unique_ptr<Sample> CreateSample(RapporType) = 0; |
| + |
| + // Records a Sample of rappor metric specified by |metric_name|. |
| + // |
| + // example: |
| + // std::unique_ptr<Sample> sample = |
| + // rappor_service->CreateSample(MY_METRIC_TYPE); |
| + // sample->SetStringField("Field1", "some string"); |
| + // sample->SetFlagsValue("Field2", SOME|FLAGS); |
| + // rappor_service->RecordSample("MyMetric", std::move(sample)); |
| + virtual void RecordSample(const std::string& metric_name, |
| + std::unique_ptr<Sample> sample) = 0; |
| + |
| + // Records a sample of the rappor metric specified by |metric_name|. |
| + // Creates and initializes the metric, if it doesn't yet exist. |
| + virtual void RecordSampleString(const std::string& metric_name, |
| + RapporType type, |
| + const std::string& sample) = 0; |
| +}; |
| + |
| +} // namespace rappor |
| + |
| +#endif // COMPONENTS_RAPPOR_PUBLIC_RAPPOR_PUBLIC_SERVICE_H_ |