File: feedback_data.h

package info (click to toggle)
chromium 145.0.7632.159-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,976,224 kB
  • sloc: cpp: 36,198,469; ansic: 7,634,080; javascript: 3,564,060; python: 1,649,622; xml: 838,470; asm: 717,087; pascal: 185,708; sh: 88,786; perl: 88,718; objc: 79,984; sql: 59,811; cs: 42,452; fortran: 24,101; makefile: 21,144; tcl: 15,277; php: 14,022; yacc: 9,066; ruby: 7,553; awk: 3,720; lisp: 3,233; lex: 1,328; ada: 727; jsp: 228; sed: 36
file content (121 lines) | stat: -rw-r--r-- 3,841 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_FEEDBACK_FEEDBACK_DATA_H_
#define COMPONENTS_FEEDBACK_FEEDBACK_DATA_H_

#include <memory>
#include <string>

#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h"
#include "components/feedback/feedback_common.h"
#include "components/feedback/feedback_uploader.h"

namespace base {
class RefCountedString;
}

class TracingManager;

namespace feedback {

class FeedbackData : public FeedbackCommon {
 public:
  FeedbackData(base::WeakPtr<feedback::FeedbackUploader> uploader,
               TracingManager* tracing_manager);

  FeedbackData(const FeedbackData&) = delete;
  FeedbackData& operator=(const FeedbackData&) = delete;

  // Called once we've updated all the data from the feedback page.
  void OnFeedbackPageDataComplete();

  // Kicks off compression of the system information for this instance.
  void CompressSystemInfo();

  // Sets the histograms for this instance and kicks off its
  // compression.
  void SetAndCompressHistograms(std::string histograms);

  // Kicks off compression of the autofill metadata for this instance.
  void CompressAutofillMetadata();

  // Sets the attached file data and kicks off its compression.
  void AttachAndCompressFileData(std::string attached_filedata);

  // Returns true if we've completed all the tasks needed before we can send
  // feedback - at this time this is includes getting the feedback page data
  // and compressing the system logs.
  bool IsDataComplete();

  // Sends the feedback report if we have all our data complete.
  void SendReport();

  // Getters
  const std::string& attached_filename() const {
    DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
    return attached_filename_;
  }
  const std::string& attached_file_uuid() const {
    DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
    return attached_file_uuid_;
  }
  const std::string& screenshot_uuid() const {
    DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
    return screenshot_uuid_;
  }
  int trace_id() const {
    DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
    return trace_id_;
  }

  // Setters
  void set_attached_filename(const std::string& attached_filename) {
    DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
    attached_filename_ = attached_filename;
  }
  void set_attached_file_uuid(const std::string& uuid) {
    DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
    attached_file_uuid_ = uuid;
  }
  void set_screenshot_uuid(const std::string& uuid) {
    DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
    screenshot_uuid_ = uuid;
  }
  void set_trace_id(int trace_id) {
    DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
    trace_id_ = trace_id;
  }

 private:
  ~FeedbackData() override;

  // Called once a compression operation is complete.
  void OnCompressComplete();

  void OnGetTraceData(int trace_id,
                      scoped_refptr<base::RefCountedString> trace_data);

  SEQUENCE_CHECKER(sequence_checker_);

  // The uploader_ is tied to a profile. When the profile is deleted, the
  // uploader_ will be destroyed.
  base::WeakPtr<feedback::FeedbackUploader> uploader_;

  std::string attached_filename_ GUARDED_BY_CONTEXT(sequence_checker_);
  std::string attached_file_uuid_ GUARDED_BY_CONTEXT(sequence_checker_);
  std::string screenshot_uuid_ GUARDED_BY_CONTEXT(sequence_checker_);

  base::WeakPtr<TracingManager> tracing_manager_;
  int trace_id_ GUARDED_BY_CONTEXT(sequence_checker_) = 0;

  int pending_op_count_ GUARDED_BY_CONTEXT(sequence_checker_) = 1;
  bool report_sent_ GUARDED_BY_CONTEXT(sequence_checker_) = false;
};

}  // namespace feedback

#endif  // COMPONENTS_FEEDBACK_FEEDBACK_DATA_H_