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

Side by Side Diff: components/net_log/chrome_net_log.cc

Issue 2965623002: Fix about:flags information not showing up in chrome://net-export/ logs (Closed)
Patch Set: . Created 3 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
« no previous file with comments | « components/net_log/chrome_net_log.h ('k') | components/net_log/net_log_file_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/net_log/chrome_net_log.h" 5 #include "components/net_log/chrome_net_log.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 11 matching lines...) Expand all
22 #include "net/log/trace_net_log_observer.h" 22 #include "net/log/trace_net_log_observer.h"
23 #include "net/log/write_to_file_net_log_observer.h" 23 #include "net/log/write_to_file_net_log_observer.h"
24 24
25 namespace net_log { 25 namespace net_log {
26 26
27 ChromeNetLog::ChromeNetLog( 27 ChromeNetLog::ChromeNetLog(
28 const base::FilePath& log_file, 28 const base::FilePath& log_file,
29 net::NetLogCaptureMode log_file_mode, 29 net::NetLogCaptureMode log_file_mode,
30 const base::CommandLine::StringType& command_line_string, 30 const base::CommandLine::StringType& command_line_string,
31 const std::string& channel_string) 31 const std::string& channel_string)
32 : net_log_file_writer_( 32 : net_log_file_writer_(new NetLogFileWriter(this)) {
33 new NetLogFileWriter(this, command_line_string, channel_string)) {
34 if (!log_file.empty()) { 33 if (!log_file.empty()) {
35 // Much like logging.h, bypass threading restrictions by using fopen 34 // Much like logging.h, bypass threading restrictions by using fopen
36 // directly. Have to write on a thread that's shutdown to handle events on 35 // directly. Have to write on a thread that's shutdown to handle events on
37 // shutdown properly, and posting events to another thread as they occur 36 // shutdown properly, and posting events to another thread as they occur
38 // would result in an unbounded buffer size, so not much can be gained by 37 // would result in an unbounded buffer size, so not much can be gained by
39 // doing this on another thread. It's only used when debugging Chrome, so 38 // doing this on another thread. It's only used when debugging Chrome, so
40 // performance is not a big concern. 39 // performance is not a big concern.
41 base::ScopedFILE file; 40 base::ScopedFILE file;
42 #if defined(OS_WIN) 41 #if defined(OS_WIN)
43 file.reset(_wfopen(log_file.value().c_str(), L"w")); 42 file.reset(_wfopen(log_file.value().c_str(), L"w"));
44 #elif defined(OS_POSIX) 43 #elif defined(OS_POSIX)
45 file.reset(fopen(log_file.value().c_str(), "w")); 44 file.reset(fopen(log_file.value().c_str(), "w"));
46 #endif 45 #endif
47 46
48 if (!file) { 47 if (!file) {
49 LOG(ERROR) << "Could not open file " << log_file.value() 48 LOG(ERROR) << "Could not open file " << log_file.value()
50 << " for net logging"; 49 << " for net logging";
51 } else { 50 } else {
52 std::unique_ptr<base::Value> constants( 51 std::unique_ptr<base::Value> constants(
53 GetConstants(command_line_string, channel_string)); 52 GetConstants(command_line_string, channel_string));
davidben 2017/06/30 18:03:26 This bit means we still won't capture about:flags
eroman 2017/06/30 18:24:37 Correct. --log-net-log needs some more loving, bef
54 write_to_file_observer_.reset(new net::WriteToFileNetLogObserver()); 53 write_to_file_observer_.reset(new net::WriteToFileNetLogObserver());
55 54
56 write_to_file_observer_->set_capture_mode(log_file_mode); 55 write_to_file_observer_->set_capture_mode(log_file_mode);
57 56
58 write_to_file_observer_->StartObserving(this, std::move(file), 57 write_to_file_observer_->StartObserving(this, std::move(file),
59 constants.get(), nullptr); 58 constants.get(), nullptr);
60 } 59 }
61 } 60 }
62 61
63 trace_net_log_observer_.reset(new net::TraceNetLogObserver()); 62 trace_net_log_observer_.reset(new net::TraceNetLogObserver());
64 trace_net_log_observer_->WatchForTraceStart(this); 63 trace_net_log_observer_->WatchForTraceStart(this);
65 } 64 }
66 65
67 ChromeNetLog::~ChromeNetLog() { 66 ChromeNetLog::~ChromeNetLog() {
68 net_log_file_writer_.reset(); 67 net_log_file_writer_.reset();
69 // Remove the observers we own before we're destroyed. 68 // Remove the observers we own before we're destroyed.
70 if (write_to_file_observer_) 69 if (write_to_file_observer_)
71 write_to_file_observer_->StopObserving(nullptr); 70 write_to_file_observer_->StopObserving(nullptr);
72 if (trace_net_log_observer_) 71 if (trace_net_log_observer_)
73 trace_net_log_observer_->StopWatchForTraceStart(); 72 trace_net_log_observer_->StopWatchForTraceStart();
74 } 73 }
75 74
75 NetLogFileWriter* ChromeNetLog::net_log_file_writer() {
76 if (!net_log_file_writer_)
77 net_log_file_writer_ = base::WrapUnique(new NetLogFileWriter(this));
78 return net_log_file_writer_.get();
79 }
80
76 // static 81 // static
77 std::unique_ptr<base::Value> ChromeNetLog::GetConstants( 82 std::unique_ptr<base::Value> ChromeNetLog::GetConstants(
78 const base::CommandLine::StringType& command_line_string, 83 const base::CommandLine::StringType& command_line_string,
79 const std::string& channel_string) { 84 const std::string& channel_string) {
80 std::unique_ptr<base::DictionaryValue> constants_dict = 85 std::unique_ptr<base::DictionaryValue> constants_dict =
81 net::GetNetConstants(); 86 net::GetNetConstants();
82 DCHECK(constants_dict); 87 DCHECK(constants_dict);
83 88
84 // Add a dictionary with the version of the client and its command line 89 // Add a dictionary with the version of the client and its command line
85 // arguments. 90 // arguments.
(...skipping 15 matching lines...) Expand all
101 106
102 constants_dict->Set("clientInfo", std::move(dict)); 107 constants_dict->Set("clientInfo", std::move(dict));
103 108
104 data_reduction_proxy::DataReductionProxyEventStore::AddConstants( 109 data_reduction_proxy::DataReductionProxyEventStore::AddConstants(
105 constants_dict.get()); 110 constants_dict.get());
106 111
107 return std::move(constants_dict); 112 return std::move(constants_dict);
108 } 113 }
109 114
110 } // namespace net_log 115 } // namespace net_log
OLDNEW
« no previous file with comments | « components/net_log/chrome_net_log.h ('k') | components/net_log/net_log_file_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698