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

Side by Side Diff: net/log/bounded_file_net_log_observer.cc

Issue 2264993002: Use base::SizeTToString instead of std::to_string (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "net/log/bounded_file_net_log_observer.h" 5 #include "net/log/bounded_file_net_log_observer.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/strings/string_number_conversions.h"
16 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
17 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
18 #include "base/values.h" 19 #include "base/values.h"
19 #include "net/log/net_log_util.h" 20 #include "net/log/net_log_util.h"
20 #include "net/url_request/url_request_context.h" 21 #include "net/url_request/url_request_context.h"
21 22
22 namespace { 23 namespace {
23 24
24 // Number of events that can build up in |write_queue_| before file thread 25 // Number of events that can build up in |write_queue_| before file thread
25 // is triggered to drain the queue. 26 // is triggered to drain the queue.
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 event_files_.clear(); 348 event_files_.clear();
348 } 349 }
349 350
350 void BoundedFileNetLogObserver::FileWriter::IncrementCurrentFile() { 351 void BoundedFileNetLogObserver::FileWriter::IncrementCurrentFile() {
351 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 352 DCHECK(task_runner_->RunsTasksOnCurrentThread());
352 353
353 current_file_idx_++; 354 current_file_idx_++;
354 current_file_idx_ %= total_num_files_; 355 current_file_idx_ %= total_num_files_;
355 event_files_[current_file_idx_].reset(); 356 event_files_[current_file_idx_].reset();
356 event_files_[current_file_idx_] = base::ScopedFILE(base::OpenFile( 357 event_files_[current_file_idx_] = base::ScopedFILE(base::OpenFile(
357 directory_.AppendASCII("event_file_" + std::to_string(current_file_idx_) + 358 directory_.AppendASCII("event_file_" +
358 ".json"), 359 base::SizeTToString(current_file_idx_) + ".json"),
359 "w")); 360 "w"));
360 } 361 }
361 362
362 void BoundedFileNetLogObserver::FileWriter::Flush( 363 void BoundedFileNetLogObserver::FileWriter::Flush(
363 scoped_refptr<BoundedFileNetLogObserver::WriteQueue> write_queue) { 364 scoped_refptr<BoundedFileNetLogObserver::WriteQueue> write_queue) {
364 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 365 DCHECK(task_runner_->RunsTasksOnCurrentThread());
365 366
366 EventQueue local_file_queue; 367 EventQueue local_file_queue;
367 write_queue->SwapQueue(&local_file_queue); 368 write_queue->SwapQueue(&local_file_queue);
368 369
(...skipping 18 matching lines...) Expand all
387 void BoundedFileNetLogObserver::FileWriter::DeleteAllFiles() { 388 void BoundedFileNetLogObserver::FileWriter::DeleteAllFiles() {
388 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 389 DCHECK(task_runner_->RunsTasksOnCurrentThread());
389 390
390 // Reset |event_files_| to release all file handles so base::DeleteFile can 391 // Reset |event_files_| to release all file handles so base::DeleteFile can
391 // safely access files. 392 // safely access files.
392 event_files_.clear(); 393 event_files_.clear();
393 394
394 base::DeleteFile(directory_.AppendASCII("constants.json"), false); 395 base::DeleteFile(directory_.AppendASCII("constants.json"), false);
395 base::DeleteFile(directory_.AppendASCII("end_netlog.json"), false); 396 base::DeleteFile(directory_.AppendASCII("end_netlog.json"), false);
396 for (size_t i = 0; i < total_num_files_; i++) { 397 for (size_t i = 0; i < total_num_files_; i++) {
397 base::DeleteFile( 398 base::DeleteFile(directory_.AppendASCII("event_file_" +
398 directory_.AppendASCII("event_file_" + std::to_string(i) + ".json"), 399 base::SizeTToString(i) + ".json"),
399 false); 400 false);
400 } 401 }
401 } 402 }
402 403
403 } // namespace net 404 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698