Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/media/webrtc_log_uploader.cc

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/media/webrtc_log_uploader.h" 5 #include "chrome/browser/media/webrtc_log_uploader.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 void WebRtcLogUploader::DecreaseLogCount() { 220 void WebRtcLogUploader::DecreaseLogCount() {
221 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 221 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
222 --log_count_; 222 --log_count_;
223 } 223 }
224 224
225 void WebRtcLogUploader::AddUploadedLogInfoToUploadListFile( 225 void WebRtcLogUploader::AddUploadedLogInfoToUploadListFile(
226 const std::string& report_id) { 226 const std::string& report_id) {
227 std::string contents; 227 std::string contents;
228 228
229 if (file_util::PathExists(upload_list_path_)) { 229 if (base::PathExists(upload_list_path_)) {
230 bool read_ok = file_util::ReadFileToString(upload_list_path_, &contents); 230 bool read_ok = file_util::ReadFileToString(upload_list_path_, &contents);
231 DPCHECK(read_ok); 231 DPCHECK(read_ok);
232 232
233 // Limit the number of log entries to |kLogListLimitLines| - 1, to make room 233 // Limit the number of log entries to |kLogListLimitLines| - 1, to make room
234 // for the new entry. Each line including the last ends with a '\n', so hit 234 // for the new entry. Each line including the last ends with a '\n', so hit
235 // n will be before line n-1 (from the back). 235 // n will be before line n-1 (from the back).
236 int lf_count = 0; 236 int lf_count = 0;
237 int i = contents.size() - 1; 237 int i = contents.size() - 1;
238 for (; i >= 0 && lf_count < kLogListLimitLines; --i) { 238 for (; i >= 0 && lf_count < kLogListLimitLines; --i) {
239 if (contents[i] == '\n') 239 if (contents[i] == '\n')
240 ++lf_count; 240 ++lf_count;
241 } 241 }
242 if (lf_count >= kLogListLimitLines) { 242 if (lf_count >= kLogListLimitLines) {
243 // + 1 to compensate for the for loop decrease before the conditional 243 // + 1 to compensate for the for loop decrease before the conditional
244 // check and + 1 to get the length. 244 // check and + 1 to get the length.
245 contents.erase(0, i + 2); 245 contents.erase(0, i + 2);
246 } 246 }
247 } 247 }
248 248
249 // Write the Unix time and report ID to the log list file. 249 // Write the Unix time and report ID to the log list file.
250 base::Time time_now = base::Time::Now(); 250 base::Time time_now = base::Time::Now();
251 contents += base::DoubleToString(time_now.ToDoubleT()) + 251 contents += base::DoubleToString(time_now.ToDoubleT()) +
252 "," + report_id + '\n'; 252 "," + report_id + '\n';
253 253
254 int written = file_util::WriteFile(upload_list_path_, &contents[0], 254 int written = file_util::WriteFile(upload_list_path_, &contents[0],
255 contents.size()); 255 contents.size());
256 DPCHECK(written == static_cast<int>(contents.size())); 256 DPCHECK(written == static_cast<int>(contents.size()));
257 } 257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698