Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1255)

Unified Diff: components/ukm/ukm_service.h

Issue 2883563002: Refactor UKM interface for mojo-ification (Closed)
Patch Set: Fix uma_session_stats.cc Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/ukm/ukm_service.h
diff --git a/components/ukm/ukm_service.h b/components/ukm/ukm_service.h
index 584be39f911088fd8d3e0cb3927daf1a304bac09..9af221183c46f3ac7539228835dde46d6204f08e 100644
--- a/components/ukm/ukm_service.h
+++ b/components/ukm/ukm_service.h
@@ -9,33 +9,17 @@
#include <memory>
#include <vector>
-#include "base/callback.h"
-#include "base/feature_list.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
#include "build/build_config.h"
#include "components/metrics/metrics_provider.h"
#include "components/metrics/metrics_rotation_scheduler.h"
+#include "components/ukm/ukm_recorder_impl.h"
#include "components/ukm/ukm_reporting_service.h"
-#include "url/gurl.h"
-class PluginInfoMessageFilter;
class PrefRegistrySimple;
class PrefService;
-class UkmPageLoadMetricsObserver;
-
-namespace autofill {
-class AutofillMetrics;
-} // namespace autofill
-
-namespace translate {
-class TranslateRankerImpl;
-}
-
-namespace payments {
-class JourneyLogger;
-} // namespace payments
namespace metrics {
class MetricsServiceClient;
@@ -43,43 +27,24 @@ class MetricsServiceClient;
namespace ukm {
-class UkmEntry;
-class UkmEntryBuilder;
-class UkmSource;
-
namespace debug {
class DebugPage;
}
-// This feature controls whether UkmService should be created.
-extern const base::Feature kUkmFeature;
-
// The URL-Keyed Metrics (UKM) service is responsible for gathering and
// uploading reports that contain fine grained performance metrics including
// URLs for top-level navigations.
-class UkmService {
+class UkmService : public UkmRecorderImpl {
public:
// Constructs a UkmService.
// Calling code is responsible for ensuring that the lifetime of
// |pref_service| is longer than the lifetime of UkmService.
UkmService(PrefService* pref_service, metrics::MetricsServiceClient* client);
- virtual ~UkmService();
-
- // Get the new source ID, which is unique for the duration of a browser
- // session.
- static int32_t 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.
- void UpdateSourceURL(int32_t source_id, const GURL& url);
+ ~UkmService() override;
// Initializes the UKM service.
void Initialize();
- // Enables/disables recording control if data is allowed to be collected.
- void EnableRecording();
- void DisableRecording();
-
// Enables/disables transmission of accumulated logs. Logs that have already
// been created will remain persisted to disk.
void EnableReporting();
@@ -108,25 +73,8 @@ class UkmService {
// the provided PrefRegistry.
static void RegisterPrefs(PrefRegistrySimple* registry);
- using AddEntryCallback = base::Callback<void(std::unique_ptr<UkmEntry>)>;
-
- protected:
- const std::map<int32_t, std::unique_ptr<UkmSource>>& sources_for_testing()
- const {
- return sources_;
- }
-
- const std::vector<std::unique_ptr<UkmEntry>>& entries_for_testing() const {
- return entries_;
- }
-
private:
friend ::ukm::debug::DebugPage;
- friend autofill::AutofillMetrics;
- friend payments::JourneyLogger;
- friend PluginInfoMessageFilter;
- friend UkmPageLoadMetricsObserver;
- friend translate::TranslateRankerImpl;
FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, AddEntryWithEmptyMetrics);
FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, EntryBuilderAndSerialization);
FRIEND_TEST_ALL_PREFIXES(UkmServiceTest,
@@ -135,15 +83,6 @@ class UkmService {
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(int32_t source_id,
- const char* event_name);
-
// Starts metrics client initialization.
void StartInitTask();
@@ -164,18 +103,9 @@ class UkmService {
// Called by log_uploader_ when the an upload is completed.
void OnLogUploadComplete(int response_code);
- // Add an entry to the UkmEntry list.
- void AddEntry(std::unique_ptr<UkmEntry> entry);
-
- // Cache the list of whitelisted entries from the field trial parameter.
- void StoreWhitelistedEntries();
-
// A weak pointer to the PrefService used to read and write preferences.
PrefService* pref_service_;
- // Whether recording new data is currently allowed.
- bool recording_enabled_;
-
// The UKM client id stored in prefs.
uint64_t client_id_;
@@ -200,14 +130,6 @@ class UkmService {
bool initialize_started_;
bool initialize_complete_;
- // Contains newly added sources and entries of UKM metrics which periodically
- // get serialized and cleared by BuildAndStoreLog().
- std::map<int32_t, std::unique_ptr<UkmSource>> sources_;
- std::vector<std::unique_ptr<UkmEntry>> entries_;
-
- // Whitelisted Entry hashes, only the ones in this set will be recorded.
- std::set<uint64_t> whitelisted_entry_hashes_;
-
// Weak pointers factory used to post task on different threads. All weak
// pointers managed by this factory have the same lifetime as UkmService.
base::WeakPtrFactory<UkmService> self_ptr_factory_;

Powered by Google App Engine
This is Rietveld 408576698