Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CRASH_UPLOAD_LIST_H_ | 5 #ifndef CHROME_BROWSER_CRASH_UPLOAD_LIST_H_ |
| 6 #define CHROME_BROWSER_CRASH_UPLOAD_LIST_H_ | 6 #define CHROME_BROWSER_CRASH_UPLOAD_LIST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 class Delegate { | 25 class Delegate { |
| 26 public: | 26 public: |
| 27 // Invoked when the crash list has been loaded. Will be called on the | 27 // Invoked when the crash list has been loaded. Will be called on the |
| 28 // UI thread. | 28 // UI thread. |
| 29 virtual void OnCrashListAvailable() = 0; | 29 virtual void OnCrashListAvailable() = 0; |
| 30 | 30 |
| 31 protected: | 31 protected: |
| 32 virtual ~Delegate() {} | 32 virtual ~Delegate() {} |
| 33 }; | 33 }; |
| 34 | 34 |
| 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); | |
| 38 | |
| 35 // Creates a new crash upload list with the given callback delegate. | 39 // Creates a new crash upload list with the given callback delegate. |
| 36 explicit CrashUploadList(Delegate* delegate); | 40 explicit CrashUploadList(Delegate* delegate); |
| 37 | 41 |
| 38 // Starts loading the crash list. OnCrashListAvailable will be called when | 42 // Starts loading the crash list. OnCrashListAvailable will be called when |
| 39 // loading is complete. | 43 // loading is complete. |
| 40 void LoadCrashListAsynchronously(); | 44 void LoadCrashListAsynchronously(); |
| 41 | 45 |
| 42 // Clears the delegate, so that any outstanding asynchronous load will not | 46 // Clears the delegate, so that any outstanding asynchronous load will not |
| 43 // call the delegate on completion. | 47 // call the delegate on completion. |
| 44 void ClearDelegate(); | 48 void ClearDelegate(); |
| 45 | 49 |
| 46 // Populates |crashes| with the |max_count| most recent uploaded crashes, | 50 // Populates |crashes| with the |max_count| most recent uploaded crashes, |
| 47 // in reverse chronological order. | 51 // in reverse chronological order. |
| 48 // Must be called only after OnCrashListAvailable has been called. | 52 // Must be called only after OnCrashListAvailable has been called. |
| 49 void GetUploadedCrashes(unsigned int max_count, | 53 void GetUploadedCrashes(unsigned int max_count, |
| 50 std::vector<CrashInfo>* crashes); | 54 std::vector<CrashInfo>* crashes); |
| 51 | 55 |
| 52 private: | 56 protected: |
| 53 friend class base::RefCountedThreadSafe<CrashUploadList>; | |
| 54 virtual ~CrashUploadList(); | 57 virtual ~CrashUploadList(); |
| 55 | 58 |
| 56 // Reads the upload log and stores the lines in log_entries_. | 59 // Reads the upload log and stores the lines in log_entries_. |
|
stuartmorgan
2011/03/30 16:28:10
s/log_entries_/crashes_/
Alexei Svitkine (slow)
2011/03/30 18:54:37
Done.
| |
| 57 void LoadUploadLog(); | 60 virtual void LoadCrashList(); |
| 61 | |
| 62 // Returns a reference to the list of log entries. | |
|
stuartmorgan
2011/03/30 16:28:10
s/log entries/crashes/
Alexei Svitkine (slow)
2011/03/30 18:54:37
Done.
| |
| 63 std::vector<CrashInfo>& crashes(); | |
| 64 | |
| 65 private: | |
| 66 friend class base::RefCountedThreadSafe<CrashUploadList>; | |
| 67 | |
| 68 std::vector<CrashInfo> crashes_; | |
| 69 Delegate* delegate_; | |
|
stuartmorgan
2011/03/30 16:28:10
Variables should be after functions.
Alexei Svitkine (slow)
2011/03/30 18:54:37
Done.
| |
| 70 | |
| 71 // Calls LoadCrashList() followed by InformDelegateOfCompletion() | |
| 72 // asynchronously. | |
|
stuartmorgan
2011/03/30 16:28:10
Too much implementation detail for the header; how
Alexei Svitkine (slow)
2011/03/30 18:54:37
Done.
| |
| 73 void LoadCrashListAndInformDelegateOfCompletion(); | |
| 58 | 74 |
| 59 // Calls the delegate's callback method, if there is a delegate. | 75 // Calls the delegate's callback method, if there is a delegate. |
| 60 void InformDelegateOfCompletion(); | 76 void InformDelegateOfCompletion(); |
| 61 | 77 |
| 62 std::vector<std::string> log_entries_; | |
| 63 Delegate* delegate_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(CrashUploadList); | 78 DISALLOW_COPY_AND_ASSIGN(CrashUploadList); |
| 66 }; | 79 }; |
| 67 | 80 |
| 68 #endif // CHROME_BROWSER_CRASH_UPLOAD_LIST_H_ | 81 #endif // CHROME_BROWSER_CRASH_UPLOAD_LIST_H_ |
| OLD | NEW |