| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/upload_list.h" | 5 #include "chrome/browser/upload_list.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 69 } |
| 70 | 70 |
| 71 void UploadList::ClearUploads() { | 71 void UploadList::ClearUploads() { |
| 72 uploads_.clear(); | 72 uploads_.clear(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void UploadList::ParseLogEntries( | 75 void UploadList::ParseLogEntries( |
| 76 const std::vector<std::string>& log_entries) { | 76 const std::vector<std::string>& log_entries) { |
| 77 std::vector<std::string>::const_reverse_iterator i; | 77 std::vector<std::string>::const_reverse_iterator i; |
| 78 for (i = log_entries.rbegin(); i != log_entries.rend(); ++i) { | 78 for (i = log_entries.rbegin(); i != log_entries.rend(); ++i) { |
| 79 std::vector<std::string> components; | 79 std::vector<std::string> components = base::SplitString( |
| 80 base::SplitString(*i, ',', &components); | 80 *i, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 81 // Skip any blank (or corrupted) lines. | 81 // Skip any blank (or corrupted) lines. |
| 82 if (components.size() != 2 && components.size() != 3) | 82 if (components.size() != 2 && components.size() != 3) |
| 83 continue; | 83 continue; |
| 84 base::Time upload_time; | 84 base::Time upload_time; |
| 85 double seconds_since_epoch; | 85 double seconds_since_epoch; |
| 86 if (!components[0].empty()) { | 86 if (!components[0].empty()) { |
| 87 if (!base::StringToDouble(components[0], &seconds_since_epoch)) | 87 if (!base::StringToDouble(components[0], &seconds_since_epoch)) |
| 88 continue; | 88 continue; |
| 89 upload_time = base::Time::FromDoubleT(seconds_since_epoch); | 89 upload_time = base::Time::FromDoubleT(seconds_since_epoch); |
| 90 } | 90 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 101 delegate_->OnUploadListAvailable(); | 101 delegate_->OnUploadListAvailable(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void UploadList::GetUploads(unsigned int max_count, | 104 void UploadList::GetUploads(unsigned int max_count, |
| 105 std::vector<UploadInfo>* uploads) { | 105 std::vector<UploadInfo>* uploads) { |
| 106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 107 std::copy(uploads_.begin(), | 107 std::copy(uploads_.begin(), |
| 108 uploads_.begin() + std::min<size_t>(uploads_.size(), max_count), | 108 uploads_.begin() + std::min<size_t>(uploads_.size(), max_count), |
| 109 std::back_inserter(*uploads)); | 109 std::back_inserter(*uploads)); |
| 110 } | 110 } |
| OLD | NEW |