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

Side by Side Diff: components/net_log/net_log_file_writer.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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "components/net_log/net_log_file_writer.h" 5 #include "components/net_log/net_log_file_writer.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 return base::SetPosixFilePermissions(path, base::FILE_PERMISSION_MASK) 102 return base::SetPosixFilePermissions(path, base::FILE_PERMISSION_MASK)
103 ? path 103 ? path
104 : base::FilePath(); 104 : base::FilePath();
105 #else 105 #else
106 return path; 106 return path;
107 #endif 107 #endif
108 } 108 }
109 109
110 } // namespace 110 } // namespace
111 111
112 NetLogFileWriter::NetLogFileWriter( 112 NetLogFileWriter::NetLogFileWriter(ChromeNetLog* chrome_net_log)
113 ChromeNetLog* chrome_net_log,
114 const base::CommandLine::StringType& command_line_string,
115 const std::string& channel_string)
116 : state_(STATE_UNINITIALIZED), 113 : state_(STATE_UNINITIALIZED),
117 log_exists_(false), 114 log_exists_(false),
118 log_capture_mode_known_(false), 115 log_capture_mode_known_(false),
119 log_capture_mode_(net::NetLogCaptureMode::Default()), 116 log_capture_mode_(net::NetLogCaptureMode::Default()),
120 chrome_net_log_(chrome_net_log), 117 chrome_net_log_(chrome_net_log),
121 command_line_string_(command_line_string),
122 channel_string_(channel_string),
123 default_log_base_dir_getter_(base::Bind(&base::GetTempDir)), 118 default_log_base_dir_getter_(base::Bind(&base::GetTempDir)),
124 weak_ptr_factory_(this) {} 119 weak_ptr_factory_(this) {}
125 120
126 NetLogFileWriter::~NetLogFileWriter() { 121 NetLogFileWriter::~NetLogFileWriter() {
127 if (file_net_log_observer_) 122 if (file_net_log_observer_)
128 file_net_log_observer_->StopObserving(nullptr, base::Bind([] {})); 123 file_net_log_observer_->StopObserving(nullptr, base::Bind([] {}));
129 } 124 }
130 125
131 void NetLogFileWriter::AddObserver(StateObserver* observer) { 126 void NetLogFileWriter::AddObserver(StateObserver* observer) {
132 DCHECK(thread_checker_.CalledOnValidThread()); 127 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 29 matching lines...) Expand all
162 base::PostTaskAndReplyWithResult( 157 base::PostTaskAndReplyWithResult(
163 file_task_runner_.get(), FROM_HERE, 158 file_task_runner_.get(), FROM_HERE,
164 base::Bind(&SetUpDefaultLogPath, default_log_base_dir_getter_), 159 base::Bind(&SetUpDefaultLogPath, default_log_base_dir_getter_),
165 base::Bind(&NetLogFileWriter::SetStateAfterSetUpDefaultLogPath, 160 base::Bind(&NetLogFileWriter::SetStateAfterSetUpDefaultLogPath,
166 weak_ptr_factory_.GetWeakPtr())); 161 weak_ptr_factory_.GetWeakPtr()));
167 } 162 }
168 163
169 void NetLogFileWriter::StartNetLog( 164 void NetLogFileWriter::StartNetLog(
170 const base::FilePath& log_path, 165 const base::FilePath& log_path,
171 net::NetLogCaptureMode capture_mode, 166 net::NetLogCaptureMode capture_mode,
167 const base::CommandLine::StringType& command_line_string,
168 const std::string& channel_string,
172 const URLRequestContextGetterList& context_getters) { 169 const URLRequestContextGetterList& context_getters) {
173 DCHECK(thread_checker_.CalledOnValidThread()); 170 DCHECK(thread_checker_.CalledOnValidThread());
174 DCHECK(file_task_runner_); 171 DCHECK(file_task_runner_);
175 172
176 if (state_ != STATE_NOT_LOGGING) 173 if (state_ != STATE_NOT_LOGGING)
177 return; 174 return;
178 175
179 if (!log_path.empty()) 176 if (!log_path.empty())
180 log_path_ = log_path; 177 log_path_ = log_path;
181 178
182 DCHECK(!log_path_.empty()); 179 DCHECK(!log_path_.empty());
183 180
184 state_ = STATE_STARTING_LOG; 181 state_ = STATE_STARTING_LOG;
185 182
186 NotifyStateObserversAsync(); 183 NotifyStateObserversAsync();
187 184
188 std::unique_ptr<base::Value> constants( 185 std::unique_ptr<base::Value> constants(
189 ChromeNetLog::GetConstants(command_line_string_, channel_string_)); 186 ChromeNetLog::GetConstants(command_line_string, channel_string));
190 // Instantiate a FileNetLogObserver in unbounded mode. 187 // Instantiate a FileNetLogObserver in unbounded mode.
191 file_net_log_observer_ = net::FileNetLogObserver::CreateUnbounded( 188 file_net_log_observer_ = net::FileNetLogObserver::CreateUnbounded(
192 file_task_runner_, log_path_, std::move(constants)); 189 file_task_runner_, log_path_, std::move(constants));
193 190
194 net_task_runner_->PostTaskAndReply( 191 net_task_runner_->PostTaskAndReply(
195 FROM_HERE, 192 FROM_HERE,
196 base::Bind(&CreateNetLogEntriesForActiveObjects, context_getters, 193 base::Bind(&CreateNetLogEntriesForActiveObjects, context_getters,
197 base::Unretained(file_net_log_observer_.get())), 194 base::Unretained(file_net_log_observer_.get())),
198 base::Bind( 195 base::Bind(
199 &NetLogFileWriter::StartNetLogAfterCreateEntriesForActiveObjects, 196 &NetLogFileWriter::StartNetLogAfterCreateEntriesForActiveObjects,
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 368
372 void NetLogFileWriter::ResetObserverThenSetStateNotLogging() { 369 void NetLogFileWriter::ResetObserverThenSetStateNotLogging() {
373 DCHECK(thread_checker_.CalledOnValidThread()); 370 DCHECK(thread_checker_.CalledOnValidThread());
374 file_net_log_observer_.reset(); 371 file_net_log_observer_.reset();
375 state_ = STATE_NOT_LOGGING; 372 state_ = STATE_NOT_LOGGING;
376 373
377 NotifyStateObservers(); 374 NotifyStateObservers();
378 } 375 }
379 376
380 } // namespace net_log 377 } // namespace net_log
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698