blob: 856af35b9c6f41f5d6d637e5bd7f1882170a36cb [file] [log] [blame]
Darin Petkovf0136cd2012-11-07 16:18:02 +01001// Copyright (c) 2012 The Chromium OS 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 SHILL_DIAGNOSTICS_REPORTER_H_
6#define SHILL_DIAGNOSTICS_REPORTER_H_
7
Ben Chana0ddf462014-02-06 11:32:42 -08008#include <base/files/file_path.h>
Darin Petkovf0136cd2012-11-07 16:18:02 +01009#include <base/lazy_instance.h>
Darin Petkovf0136cd2012-11-07 16:18:02 +010010
Utkarsh Sanghi83bd64b2014-07-29 16:01:43 -070011namespace chromeos {
Darin Petkovf0136cd2012-11-07 16:18:02 +010012
Darin Petkov38066762012-12-17 15:35:45 +010013class Minijail;
Utkarsh Sanghi83bd64b2014-07-29 16:01:43 -070014
15} // namespace chromeos
16
17namespace shill {
18
Darin Petkov38066762012-12-17 15:35:45 +010019class ProcessKiller;
Darin Petkov328e19d2012-12-04 15:54:07 +010020class Time;
Darin Petkovf0136cd2012-11-07 16:18:02 +010021
22class DiagnosticsReporter {
23 public:
24 virtual ~DiagnosticsReporter();
25
mukesh agrawalf407d592013-07-31 11:37:57 -070026 // This is a singleton -- use DiagnosticsReporter::GetInstance()->Foo().
Paul Stewarta794cd62015-06-16 13:13:10 -070027 static DiagnosticsReporter* GetInstance();
Darin Petkovf0136cd2012-11-07 16:18:02 +010028
Darin Petkov385b9bc2012-12-03 15:25:05 +010029 // Handle a connectivity event -- collect and stash diagnostics data, possibly
30 // uploading it for analysis.
31 virtual void OnConnectivityEvent();
Darin Petkovf0136cd2012-11-07 16:18:02 +010032
33 protected:
34 DiagnosticsReporter();
35
36 virtual bool IsReportingEnabled();
37
38 private:
39 friend struct base::DefaultLazyInstanceTraits<DiagnosticsReporter>;
40 friend class DiagnosticsReporterTest;
41
Darin Petkov328e19d2012-12-04 15:54:07 +010042 static const int kLogStashThrottleSeconds;
43
Paul Stewarta794cd62015-06-16 13:13:10 -070044 chromeos::Minijail* minijail_;
45 ProcessKiller* process_killer_;
46 Time* time_;
Ben Chan7fab8972014-08-10 17:14:46 -070047 uint64_t last_log_stash_; // Monotonic time seconds.
Albert Chaulk0e1cdea2013-02-27 15:32:55 -080048 base::FilePath stashed_net_log_;
Darin Petkovf0136cd2012-11-07 16:18:02 +010049
50 DISALLOW_COPY_AND_ASSIGN(DiagnosticsReporter);
51};
52
53} // namespace shill
54
55#endif // SHILL_DIAGNOSTICS_REPORTER_H_