OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_CRASH_UPLOAD_LIST_H_ | |
6 #define CHROME_BROWSER_CRASH_UPLOAD_LIST_H_ | |
7 #pragma once | |
8 | |
9 #include "base/ref_counted.h" | |
10 #include "base/time.h" | |
11 | |
12 #include <string> | |
13 #include <vector> | |
14 | |
15 class CrashUploadList : public base::RefCountedThreadSafe<CrashUploadList> { | |
16 public: | |
17 struct CrashInfo { | |
Nico
2011/02/18 18:16:01
erg would probably like it if you would have expli
stuartmorgan
2011/02/18 19:41:21
Whoops, I forgot about that email. Thanks for the
| |
18 std::string crash_id; | |
19 base::Time crash_time; | |
20 }; | |
21 | |
22 class Delegate { | |
23 public: | |
24 // Invoked when the crash list has been loaded. | |
Nico
2011/02/18 18:16:01
Maybe mention which thread the delegate will be ca
stuartmorgan
2011/02/18 19:41:21
Done.
| |
25 virtual void OnCrashListAvailable() = 0; | |
26 | |
27 protected: | |
28 virtual ~Delegate() {} | |
29 }; | |
30 | |
31 // Creates a new crash upload list with the given callback delegate. | |
32 explicit CrashUploadList(Delegate* delegate); | |
33 | |
34 // Starts loading the crash list. OnCrashListAvailable will be called when | |
35 // loading is complete. | |
36 void LoadCrashListAsynchronously(); | |
37 | |
38 // Clears the delegate, so that any outstanding asynchronous load will not | |
39 // call the delegate on completion. | |
40 void ClearDelegate(); | |
41 | |
42 // Populates |crashes| with the |max_count| most recent uploaded crashes, | |
43 // in reverse chronological order. | |
44 // Must be called only after OnCrashListAvailable has been called. | |
45 void GetUploadedCrashes(unsigned int max_count, | |
46 std::vector<CrashInfo>* crashes); | |
47 | |
48 private: | |
49 friend class base::RefCountedThreadSafe<CrashUploadList>; | |
50 virtual ~CrashUploadList(); | |
51 | |
52 // Reads the upload log and stores the lines in log_entries_. | |
53 void LoadUploadLog(); | |
54 | |
55 // Calls the delegate's callback method, if there is a delegate. | |
56 void InformDelegateOfCompletion(); | |
57 | |
58 std::vector<std::string> log_entries_; | |
59 Delegate* delegate_; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(CrashUploadList); | |
62 }; | |
63 | |
64 #endif // CHROME_BROWSER_CRASH_UPLOAD_LIST_H_ | |
OLD | NEW |