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 { |
| 18 CrashInfo(const std::string& c, const base::Time& t); |
| 19 ~CrashInfo(); |
| 20 |
| 21 std::string crash_id; |
| 22 base::Time crash_time; |
| 23 }; |
| 24 |
| 25 class Delegate { |
| 26 public: |
| 27 // Invoked when the crash list has been loaded. Will be called on the |
| 28 // UI thread. |
| 29 virtual void OnCrashListAvailable() = 0; |
| 30 |
| 31 protected: |
| 32 virtual ~Delegate() {} |
| 33 }; |
| 34 |
| 35 // Creates a new crash upload list with the given callback delegate. |
| 36 explicit CrashUploadList(Delegate* delegate); |
| 37 |
| 38 // Starts loading the crash list. OnCrashListAvailable will be called when |
| 39 // loading is complete. |
| 40 void LoadCrashListAsynchronously(); |
| 41 |
| 42 // Clears the delegate, so that any outstanding asynchronous load will not |
| 43 // call the delegate on completion. |
| 44 void ClearDelegate(); |
| 45 |
| 46 // Populates |crashes| with the |max_count| most recent uploaded crashes, |
| 47 // in reverse chronological order. |
| 48 // Must be called only after OnCrashListAvailable has been called. |
| 49 void GetUploadedCrashes(unsigned int max_count, |
| 50 std::vector<CrashInfo>* crashes); |
| 51 |
| 52 private: |
| 53 friend class base::RefCountedThreadSafe<CrashUploadList>; |
| 54 virtual ~CrashUploadList(); |
| 55 |
| 56 // Reads the upload log and stores the lines in log_entries_. |
| 57 void LoadUploadLog(); |
| 58 |
| 59 // Calls the delegate's callback method, if there is a delegate. |
| 60 void InformDelegateOfCompletion(); |
| 61 |
| 62 std::vector<std::string> log_entries_; |
| 63 Delegate* delegate_; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(CrashUploadList); |
| 66 }; |
| 67 |
| 68 #endif // CHROME_BROWSER_CRASH_UPLOAD_LIST_H_ |
OLD | NEW |