1 // Copyright 2019 The Chromium Authors. All rights reserved. 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 CONTENT_PUBLIC_BROWSER_DEVTOOLS_BACKGROUND_SERVICES_CONTEXT_H_ 6 #define CONTENT_PUBLIC_BROWSER_DEVTOOLS_BACKGROUND_SERVICES_CONTEXT_H_ 7 8 #include <stdint.h> 9 #include <map> 10 #include <string> 11 12 #include "base/macros.h" 13 #include "content/common/content_export.h" 14 15 namespace url { 16 class Origin; 17 } // namespace url 18 19 namespace content { 20 21 enum class DevToolsBackgroundService { 22 kBackgroundFetch = 2, 23 kBackgroundSync = 3, 24 kPushMessaging = 4, 25 kNotifications = 5, 26 kPaymentHandler = 6, 27 kPeriodicBackgroundSync = 7, 28 29 // Keep at the end. 30 kMaxValue = kPeriodicBackgroundSync, 31 }; 32 33 // This class is responsible for persisting the debugging events for the 34 // relevant Web Platform Features. 35 class CONTENT_EXPORT DevToolsBackgroundServicesContext { 36 public: 37 DevToolsBackgroundServicesContext() = default; 38 virtual ~DevToolsBackgroundServicesContext() = default; 39 40 // Whether events related to |service| should be recorded. 41 virtual bool IsRecording(DevToolsBackgroundService service) = 0; 42 43 // Logs the event if recording for |service| is enabled. 44 // |event_name| is a description of the event. 45 // |instance_id| is for tracking events related to the same feature instance. 46 // Any additional useful information relating to the feature can be sent via 47 // |event_metadata|. Called from the UI thread. 48 virtual void LogBackgroundServiceEvent( 49 uint64_t service_worker_registration_id, 50 const url::Origin& origin, 51 DevToolsBackgroundService service, 52 const std::string& event_name, 53 const std::string& instance_id, 54 const std::map<std::string, std::string>& event_metadata) = 0; 55 56 private: 57 DISALLOW_COPY_AND_ASSIGN(DevToolsBackgroundServicesContext); 58 }; 59 60 } // namespace content 61 62 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_BACKGROUND_SERVICES_CONTEXT_H_ 63