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 #include "chrome/browser/crash_upload_list.h" | 5 #include "chrome/browser/crash_upload_list.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #else | 32 #else |
33 return new CrashUploadList(delegate); | 33 return new CrashUploadList(delegate); |
34 #endif | 34 #endif |
35 } | 35 } |
36 | 36 |
37 CrashUploadList::CrashUploadList(Delegate* delegate) : delegate_(delegate) {} | 37 CrashUploadList::CrashUploadList(Delegate* delegate) : delegate_(delegate) {} |
38 | 38 |
39 CrashUploadList::~CrashUploadList() {} | 39 CrashUploadList::~CrashUploadList() {} |
40 | 40 |
41 void CrashUploadList::LoadCrashListAsynchronously() { | 41 void CrashUploadList::LoadCrashListAsynchronously() { |
42 BrowserThread::PostBlockingPoolTask( | 42 BrowserThread::PostTask( |
| 43 BrowserThread::FILE, |
43 FROM_HERE, | 44 FROM_HERE, |
44 base::Bind(&CrashUploadList::LoadCrashListAndInformDelegateOfCompletion, | 45 base::Bind(&CrashUploadList::LoadCrashListAndInformDelegateOfCompletion, |
45 this)); | 46 this)); |
46 } | 47 } |
47 | 48 |
48 void CrashUploadList::ClearDelegate() { | 49 void CrashUploadList::ClearDelegate() { |
49 delegate_ = NULL; | 50 delegate_ = NULL; |
50 } | 51 } |
51 | 52 |
52 | 53 |
53 void CrashUploadList::LoadCrashListAndInformDelegateOfCompletion() { | 54 void CrashUploadList::LoadCrashListAndInformDelegateOfCompletion() { |
54 LoadCrashList(); | 55 LoadCrashList(); |
55 BrowserThread::PostTask( | 56 BrowserThread::PostTask( |
56 BrowserThread::UI, | 57 BrowserThread::UI, |
57 FROM_HERE, | 58 FROM_HERE, |
58 base::Bind(&CrashUploadList::InformDelegateOfCompletion, this)); | 59 base::Bind(&CrashUploadList::InformDelegateOfCompletion, this)); |
59 } | 60 } |
60 | 61 |
61 void CrashUploadList::LoadCrashList() { | 62 void CrashUploadList::LoadCrashList() { |
| 63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
62 FilePath crash_dir_path; | 64 FilePath crash_dir_path; |
63 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dir_path); | 65 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dir_path); |
64 FilePath upload_log_path = crash_dir_path.AppendASCII("uploads.log"); | 66 FilePath upload_log_path = crash_dir_path.AppendASCII("uploads.log"); |
65 if (file_util::PathExists(upload_log_path)) { | 67 if (file_util::PathExists(upload_log_path)) { |
66 std::string contents; | 68 std::string contents; |
67 file_util::ReadFileToString(upload_log_path, &contents); | 69 file_util::ReadFileToString(upload_log_path, &contents); |
68 std::vector<std::string> log_entries; | 70 std::vector<std::string> log_entries; |
69 base::SplitStringAlongWhitespace(contents, &log_entries); | 71 base::SplitStringAlongWhitespace(contents, &log_entries); |
70 ParseLogEntries(log_entries); | 72 ParseLogEntries(log_entries); |
71 } | 73 } |
(...skipping 25 matching lines...) Expand all Loading... |
97 void CrashUploadList::GetUploadedCrashes(unsigned int max_count, | 99 void CrashUploadList::GetUploadedCrashes(unsigned int max_count, |
98 std::vector<CrashInfo>* crashes) { | 100 std::vector<CrashInfo>* crashes) { |
99 std::copy(crashes_.begin(), | 101 std::copy(crashes_.begin(), |
100 crashes_.begin() + std::min<size_t>(crashes_.size(), max_count), | 102 crashes_.begin() + std::min<size_t>(crashes_.size(), max_count), |
101 std::back_inserter(*crashes)); | 103 std::back_inserter(*crashes)); |
102 } | 104 } |
103 | 105 |
104 std::vector<CrashUploadList::CrashInfo>& CrashUploadList::crashes() { | 106 std::vector<CrashUploadList::CrashInfo>& CrashUploadList::crashes() { |
105 return crashes_; | 107 return crashes_; |
106 } | 108 } |
OLD | NEW |