blob: 78af39d95a20b4512aa5cba279ac2be20b6072ff (
plain)
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
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CRASH_UPLOAD_LIST_H_
#define CHROME_BROWSER_CRASH_UPLOAD_LIST_H_
#include <string>
#include <vector>
#include "base/memory/ref_counted.h"
#include "base/time.h"
class CrashUploadList : public base::RefCountedThreadSafe<CrashUploadList> {
public:
struct CrashInfo {
CrashInfo(const std::string& c, const base::Time& t);
~CrashInfo();
std::string crash_id;
base::Time crash_time;
};
class Delegate {
public:
// Invoked when the crash list has been loaded. Will be called on the
// UI thread.
virtual void OnCrashListAvailable() = 0;
protected:
virtual ~Delegate() {}
};
// Static factory method that creates the platform-specific implementation
// of the crash upload list with the given callback delegate.
static CrashUploadList* Create(Delegate* delegate);
// Should match kReporterLogFilename in
// breakpad/src/client/apple/Framework/BreakpadDefines.h.
static const char* kReporterLogFilename;
// Creates a new crash upload list with the given callback delegate.
explicit CrashUploadList(Delegate* delegate);
// Starts loading the crash list. OnCrashListAvailable will be called when
// loading is complete.
void LoadCrashListAsynchronously();
// Clears the delegate, so that any outstanding asynchronous load will not
// call the delegate on completion.
void ClearDelegate();
// Populates |crashes| with the |max_count| most recent uploaded crashes,
// in reverse chronological order.
// Must be called only after OnCrashListAvailable has been called.
void GetUploadedCrashes(unsigned int max_count,
std::vector<CrashInfo>* crashes);
protected:
virtual ~CrashUploadList();
// Reads the upload log and stores the entries in crashes_.
virtual void LoadCrashList();
// Returns a reference to the list of crashes.
std::vector<CrashInfo>& crashes();
private:
friend class base::RefCountedThreadSafe<CrashUploadList>;
// Manages the background thread work for LoadCrashListAsynchronously().
void LoadCrashListAndInformDelegateOfCompletion();
// Calls the delegate's callback method, if there is a delegate.
void InformDelegateOfCompletion();
// Parses crash log lines, converting them to CrashInfo entries.
void ParseLogEntries(const std::vector<std::string>& log_entries);
std::vector<CrashInfo> crashes_;
Delegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(CrashUploadList);
};
#endif // CHROME_BROWSER_CRASH_UPLOAD_LIST_H_
|