1 // Copyright (c) 2011 The Chromium 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.
5 #ifndef CHROME_BROWSER_CRASH_UPLOAD_LIST_H_
6 #define CHROME_BROWSER_CRASH_UPLOAD_LIST_H_
9 #include "base/memory/ref_counted.h"
10 #include "base/time.h"
15 class CrashUploadList
: public base::RefCountedThreadSafe
<CrashUploadList
> {
18 CrashInfo(const std::string
& c
, const base::Time
& t
);
22 base::Time crash_time
;
27 // Invoked when the crash list has been loaded. Will be called on the
29 virtual void OnCrashListAvailable() = 0;
32 virtual ~Delegate() {}
35 // Static factory method that creates the platform-specific implementation
36 // of the crash upload list with the given callback delegate.
37 static CrashUploadList
* Create(Delegate
* delegate
);
39 // Creates a new crash upload list with the given callback delegate.
40 explicit CrashUploadList(Delegate
* delegate
);
42 // Starts loading the crash list. OnCrashListAvailable will be called when
43 // loading is complete.
44 void LoadCrashListAsynchronously();
46 // Clears the delegate, so that any outstanding asynchronous load will not
47 // call the delegate on completion.
50 // Populates |crashes| with the |max_count| most recent uploaded crashes,
51 // in reverse chronological order.
52 // Must be called only after OnCrashListAvailable has been called.
53 void GetUploadedCrashes(unsigned int max_count
,
54 std::vector
<CrashInfo
>* crashes
);
57 virtual ~CrashUploadList();
59 // Reads the upload log and stores the entries in crashes_.
60 virtual void LoadCrashList();
62 // Returns a reference to the list of crashes.
63 std::vector
<CrashInfo
>& crashes();
66 friend class base::RefCountedThreadSafe
<CrashUploadList
>;
68 // Manages the background thread work for LoadCrashListAsynchronously().
69 void LoadCrashListAndInformDelegateOfCompletion();
71 // Calls the delegate's callback method, if there is a delegate.
72 void InformDelegateOfCompletion();
74 // Parses crash log lines, converting them to CrashInfo entries.
75 void ParseLogEntries(const std::vector
<std::string
>& log_entries
);
77 std::vector
<CrashInfo
> crashes_
;
80 DISALLOW_COPY_AND_ASSIGN(CrashUploadList
);
83 #endif // CHROME_BROWSER_CRASH_UPLOAD_LIST_H_