Darin Petkov | f0136cd | 2012-11-07 16:18:02 +0100 | [diff] [blame] | 1 | // 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 Petkov | 3806676 | 2012-12-17 15:35:45 +0100 | [diff] [blame] | 8 | #include <base/file_path.h> |
Darin Petkov | f0136cd | 2012-11-07 16:18:02 +0100 | [diff] [blame] | 9 | #include <base/lazy_instance.h> |
Darin Petkov | f0136cd | 2012-11-07 16:18:02 +0100 | [diff] [blame] | 10 | |
| 11 | namespace shill { |
| 12 | |
Darin Petkov | 3806676 | 2012-12-17 15:35:45 +0100 | [diff] [blame] | 13 | class Minijail; |
| 14 | class ProcessKiller; |
Darin Petkov | 328e19d | 2012-12-04 15:54:07 +0100 | [diff] [blame] | 15 | class Time; |
Darin Petkov | f0136cd | 2012-11-07 16:18:02 +0100 | [diff] [blame] | 16 | |
| 17 | class DiagnosticsReporter { |
| 18 | public: |
| 19 | virtual ~DiagnosticsReporter(); |
| 20 | |
| 21 | // This is a singleton -- use DiagnosticsReporter::GetInstance()->Foo() |
| 22 | static DiagnosticsReporter *GetInstance(); |
| 23 | |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 24 | // Handle a connectivity event -- collect and stash diagnostics data, possibly |
| 25 | // uploading it for analysis. |
| 26 | virtual void OnConnectivityEvent(); |
Darin Petkov | f0136cd | 2012-11-07 16:18:02 +0100 | [diff] [blame] | 27 | |
| 28 | protected: |
| 29 | DiagnosticsReporter(); |
| 30 | |
| 31 | virtual bool IsReportingEnabled(); |
| 32 | |
| 33 | private: |
| 34 | friend struct base::DefaultLazyInstanceTraits<DiagnosticsReporter>; |
| 35 | friend class DiagnosticsReporterTest; |
| 36 | |
Darin Petkov | 328e19d | 2012-12-04 15:54:07 +0100 | [diff] [blame] | 37 | static const int kLogStashThrottleSeconds; |
| 38 | |
Darin Petkov | 3806676 | 2012-12-17 15:35:45 +0100 | [diff] [blame] | 39 | Minijail *minijail_; |
| 40 | ProcessKiller *process_killer_; |
Darin Petkov | 328e19d | 2012-12-04 15:54:07 +0100 | [diff] [blame] | 41 | Time *time_; |
| 42 | uint64 last_log_stash_; // Monotonic time seconds. |
Albert Chaulk | 0e1cdea | 2013-02-27 15:32:55 -0800 | [diff] [blame] | 43 | base::FilePath stashed_net_log_; |
Darin Petkov | f0136cd | 2012-11-07 16:18:02 +0100 | [diff] [blame] | 44 | |
| 45 | DISALLOW_COPY_AND_ASSIGN(DiagnosticsReporter); |
| 46 | }; |
| 47 | |
| 48 | } // namespace shill |
| 49 | |
| 50 | #endif // SHILL_DIAGNOSTICS_REPORTER_H_ |