Chromium Code Reviews| Index: components/ukm/public/ukm_recorder.h |
| diff --git a/components/ukm/public/ukm_recorder.h b/components/ukm/public/ukm_recorder.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..79b5a20d9187accae822304ee7b247d752e262fe |
| --- /dev/null |
| +++ b/components/ukm/public/ukm_recorder.h |
| @@ -0,0 +1,97 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_UKM_PUBLIC_UKM_RECORDER_H_ |
| +#define COMPONENTS_UKM_PUBLIC_UKM_RECORDER_H_ |
| + |
| +#include <stddef.h> |
| + |
| +#include "base/callback.h" |
| +#include "base/feature_list.h" |
| +#include "base/macros.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "components/ukm/public/interfaces/ukm_interface.mojom.h" |
| +#include "components/ukm/public/ukm_entry_builder.h" |
| +#include "url/gurl.h" |
| + |
| +class PluginInfoMessageFilter; |
| +class UkmPageLoadMetricsObserver; |
| + |
| +namespace autofill { |
| +class AutofillMetrics; |
| +} // namespace autofill |
|
oystein (OOO til 10th of July)
2017/05/17 18:25:06
nit: no need for the //namespace comment for forwa
Steven Holte
2017/05/17 20:44:31
Done.
|
| + |
| +namespace content { |
| +class RenderFrameImpl; |
| +} |
| + |
| +namespace translate { |
| +class TranslateRankerImpl; |
| +} |
| + |
| +namespace payments { |
| +class JourneyLogger; |
| +} // namespace payments |
|
oystein (OOO til 10th of July)
2017/05/17 18:25:06
nit: same as above about redundant comment.
Steven Holte
2017/05/17 20:44:31
Done.
|
| + |
| +namespace ukm { |
| + |
| +class UkmEntryBuilder; |
| +class UkmInterface; |
| +class TestRecordingHelper; |
| + |
| +// This feature controls whether UkmService should be created. |
| +extern const base::Feature kUkmFeature; |
| + |
| +typedef int64_t SourceId; |
| + |
| +// Interface for recording UKM |
| +class UkmRecorder { |
| + public: |
| + UkmRecorder(); |
| + virtual ~UkmRecorder(); |
| + |
| + // Get the new source ID, which is unique for the duration of a browser |
| + // session. |
| + static SourceId GetNewSourceID(); |
| + |
| + // Update the URL on the source keyed to the given source ID. If the source |
| + // does not exist, it will create a new UkmSource object. |
| + virtual void UpdateSourceURL(SourceId source_id, const GURL& url) = 0; |
| + |
| + private: |
| + friend autofill::AutofillMetrics; |
| + friend payments::JourneyLogger; |
| + friend PluginInfoMessageFilter; |
| + friend UkmPageLoadMetricsObserver; |
| + friend translate::TranslateRankerImpl; |
| + friend TestRecordingHelper; |
| + friend UkmInterface; |
| + friend content::RenderFrameImpl; |
| + FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, AddEntryWithEmptyMetrics); |
| + FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, EntryBuilderAndSerialization); |
| + FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, |
| + LogsUploadedOnlyWhenHavingSourcesOrEntries); |
| + FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, MetricsProviderTest); |
| + FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, PersistAndPurge); |
| + FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, WhitelistEntryTest); |
| + |
| + // Get a new UkmEntryBuilder object for the specified source ID and event, |
| + // which can get metrics added to. |
| + // |
| + // This API being private is intentional. Any client using UKM needs to |
| + // declare itself to be a friend of UkmService and go through code review |
| + // process. |
| + std::unique_ptr<UkmEntryBuilder> GetEntryBuilder(SourceId source_id, |
| + const char* event_name); |
| + |
| + private: |
| + // Add an entry to the UkmEntry list. |
| + virtual void AddEntry(mojom::UkmEntryPtr entry) = 0; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(UkmRecorder); |
| +}; |
| + |
| +} // namespace ukm |
| + |
| +#endif // COMPONENTS_UKM_PUBLIC_UKM_RECORDER_H_ |