blob: 1d21a33f3b6e651f715c2def2f92b17db1da449e [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
Darin Petkov38066762012-12-17 15:35:45 +01008#include <base/file_path.h>
Darin Petkovf0136cd2012-11-07 16:18:02 +01009#include <base/lazy_instance.h>
Darin Petkovf0136cd2012-11-07 16:18:02 +010010
11namespace shill {
12
Darin Petkov38066762012-12-17 15:35:45 +010013class Minijail;
14class ProcessKiller;
Darin Petkov328e19d2012-12-04 15:54:07 +010015class Time;
Darin Petkovf0136cd2012-11-07 16:18:02 +010016
17class DiagnosticsReporter {
18 public:
19 virtual ~DiagnosticsReporter();
20
21 // This is a singleton -- use DiagnosticsReporter::GetInstance()->Foo()
22 static DiagnosticsReporter *GetInstance();
23
Darin Petkov385b9bc2012-12-03 15:25:05 +010024 // Handle a connectivity event -- collect and stash diagnostics data, possibly
25 // uploading it for analysis.
26 virtual void OnConnectivityEvent();
Darin Petkovf0136cd2012-11-07 16:18:02 +010027
28 protected:
29 DiagnosticsReporter();
30
31 virtual bool IsReportingEnabled();
32
33 private:
34 friend struct base::DefaultLazyInstanceTraits<DiagnosticsReporter>;
35 friend class DiagnosticsReporterTest;
36
Darin Petkov328e19d2012-12-04 15:54:07 +010037 static const int kLogStashThrottleSeconds;
38
Darin Petkov38066762012-12-17 15:35:45 +010039 Minijail *minijail_;
40 ProcessKiller *process_killer_;
Darin Petkov328e19d2012-12-04 15:54:07 +010041 Time *time_;
42 uint64 last_log_stash_; // Monotonic time seconds.
Albert Chaulk0e1cdea2013-02-27 15:32:55 -080043 base::FilePath stashed_net_log_;
Darin Petkovf0136cd2012-11-07 16:18:02 +010044
45 DISALLOW_COPY_AND_ASSIGN(DiagnosticsReporter);
46};
47
48} // namespace shill
49
50#endif // SHILL_DIAGNOSTICS_REPORTER_H_