blob: c106b65d3d8412c2a860e1d530f301bff819890a [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2013 The Chromium Authors
[email protected]43b74f02013-10-04 00:37:192// 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_BROWSER_ANDROID_TRACING_CONTROLLER_ANDROID_H_
6#define CONTENT_BROWSER_ANDROID_TRACING_CONTROLLER_ANDROID_H_
7
[email protected]2cbd5ed22014-05-07 17:37:198#include <set>
9
[email protected]6a718ab2014-04-23 20:01:2010#include "base/android/jni_weak_ref.h"
[email protected]6174a362013-12-03 19:48:1911#include "base/files/file_path.h"
12#include "base/memory/weak_ptr.h"
[email protected]43b74f02013-10-04 00:37:1913
14namespace content {
15
16// This class implements the native methods of TracingControllerAndroid.java
17class TracingControllerAndroid {
18 public:
Andrew Grievedf3420a4e2024-08-30 21:02:4819 TracingControllerAndroid(JNIEnv* env, const jni_zero::JavaRef<jobject>& obj);
Peter Boström9b036532021-10-28 23:37:2820
21 TracingControllerAndroid(const TracingControllerAndroid&) = delete;
22 TracingControllerAndroid& operator=(const TracingControllerAndroid&) = delete;
23
Andrew Grieveab2c9152025-07-02 19:53:1324 void Destroy(JNIEnv* env);
[email protected]43b74f02013-10-04 00:37:1925
26 bool StartTracing(JNIEnv* env,
tornee1bfee92015-12-01 14:05:0127 const base::android::JavaParamRef<jstring>& categories,
Sami Kyostilaab4673c2020-07-30 18:32:3328 const base::android::JavaParamRef<jstring>& trace_options,
29 bool use_protobuf);
tornee1bfee92015-12-01 14:05:0130 void StopTracing(JNIEnv* env,
Eric Secklera0353e802018-10-29 14:39:0131 const base::android::JavaParamRef<jstring>& jfilepath,
Sami Kyostilaab4673c2020-07-30 18:32:3332 bool compress_file,
33 bool use_protobuf,
Eric Secklera0353e802018-10-29 14:39:0134 const base::android::JavaParamRef<jobject>& callback);
35 bool GetKnownCategoriesAsync(
tornee1bfee92015-12-01 14:05:0136 JNIEnv* env,
Eric Secklera0353e802018-10-29 14:39:0137 const base::android::JavaParamRef<jobject>& callback);
38 bool GetTraceBufferUsageAsync(
39 JNIEnv* env,
Eric Secklera0353e802018-10-29 14:39:0140 const base::android::JavaParamRef<jobject>& callback);
Alexander Timin9419b1d52021-01-03 11:57:4841
42 // Locate the appropriate directory to write the trace to and use it to
43 // generate the path. |basename| might be empty, then TracingControllerAndroid
44 // will generate an appropriate one as well.
45 static base::FilePath GenerateTracingFilePath(const std::string& basename);
[email protected]43b74f02013-10-04 00:37:1946
47 private:
48 ~TracingControllerAndroid();
Eric Secklera0353e802018-10-29 14:39:0149 void OnTracingStopped(
50 const base::android::ScopedJavaGlobalRef<jobject>& callback);
[email protected]2cbd5ed22014-05-07 17:37:1951 void OnKnownCategoriesReceived(
Eric Secklera0353e802018-10-29 14:39:0152 const base::android::ScopedJavaGlobalRef<jobject>& callback,
[email protected]2cbd5ed22014-05-07 17:37:1953 const std::set<std::string>& categories_received);
Eric Secklera0353e802018-10-29 14:39:0154 void OnTraceBufferUsageReceived(
55 const base::android::ScopedJavaGlobalRef<jobject>& callback,
56 float percent_full,
57 size_t approximate_event_count);
[email protected]43b74f02013-10-04 00:37:1958
59 JavaObjectWeakGlobalRef weak_java_object_;
Jeremy Roman877cf8b42019-08-14 20:18:2860 base::WeakPtrFactory<TracingControllerAndroid> weak_factory_{this};
[email protected]43b74f02013-10-04 00:37:1961};
62
[email protected]43b74f02013-10-04 00:37:1963} // namespace content
64
65#endif // CONTENT_BROWSER_ANDROID_TRACING_CONTROLLER_ANDROID_H_