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

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

Issue 2333923004: Extracting NetLog inner classes into their own classes. (Closed)
Patch Set: Some nit fixes and better, impl-agnostic naming of net_log_parameters_callback_typedef.h -> net/log… Created 4 years, 2 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
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/strings/string_number_conversions.h"
17 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
18 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "net/log/net_log_entry.h"
20 #include "net/log/net_log_util.h" 21 #include "net/log/net_log_util.h"
21 #include "net/url_request/url_request_context.h" 22 #include "net/url_request/url_request_context.h"
22 23
23 namespace { 24 namespace {
24 25
25 // Number of events that can build up in |write_queue_| before file thread 26 // Number of events that can build up in |write_queue_| before file thread
26 // is triggered to drain the queue. 27 // is triggered to drain the queue.
27 const int kNumWriteQueueEvents = 15; 28 const int kNumWriteQueueEvents = 15;
28 29
29 } // namespace 30 } // namespace
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 base::Unretained(file_writer_), 242 base::Unretained(file_writer_),
242 base::Passed(url_request_context 243 base::Passed(url_request_context
243 ? GetNetInfo(url_request_context, 244 ? GetNetInfo(url_request_context,
244 NET_INFO_ALL_SOURCES) 245 NET_INFO_ALL_SOURCES)
245 : nullptr)), 246 : nullptr)),
246 callback); 247 callback);
247 248
248 net_log()->DeprecatedRemoveObserver(this); 249 net_log()->DeprecatedRemoveObserver(this);
249 } 250 }
250 251
251 void BoundedFileNetLogObserver::OnAddEntry(const NetLog::Entry& entry) { 252 void BoundedFileNetLogObserver::OnAddEntry(const NetLogEntry& entry) {
252 std::unique_ptr<std::string> json(new std::string); 253 std::unique_ptr<std::string> json(new std::string);
253 254
254 // If |entry| cannot be converted to proper JSON, ignore it. 255 // If |entry| cannot be converted to proper JSON, ignore it.
255 if (!base::JSONWriter::Write(*entry.ToValue(), json.get())) 256 if (!base::JSONWriter::Write(*entry.ToValue(), json.get()))
256 return; 257 return;
257 258
258 size_t queue_size = write_queue_->AddEntryToQueue(std::move(json)); 259 size_t queue_size = write_queue_->AddEntryToQueue(std::move(json));
259 260
260 // If events build up in |write_queue_|, trigger the file thread to drain 261 // If events build up in |write_queue_|, trigger the file thread to drain
261 // the queue. 262 // the queue.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 base::DeleteFile(directory_.AppendASCII("constants.json"), false); 396 base::DeleteFile(directory_.AppendASCII("constants.json"), false);
396 base::DeleteFile(directory_.AppendASCII("end_netlog.json"), false); 397 base::DeleteFile(directory_.AppendASCII("end_netlog.json"), false);
397 for (size_t i = 0; i < total_num_files_; i++) { 398 for (size_t i = 0; i < total_num_files_; i++) {
398 base::DeleteFile(directory_.AppendASCII("event_file_" + 399 base::DeleteFile(directory_.AppendASCII("event_file_" +
399 base::SizeTToString(i) + ".json"), 400 base::SizeTToString(i) + ".json"),
400 false); 401 false);
401 } 402 }
402 } 403 }
403 404
404 } // namespace net 405 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698