OLD | NEW |
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_temp_file.h" | 5 #include "components/net_log/net_log_temp_file.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // Try to make sure we can create the file. | 179 // Try to make sure we can create the file. |
180 // TODO(rtenneti): Find a better for doing the following. Surface some error | 180 // TODO(rtenneti): Find a better for doing the following. Surface some error |
181 // to the user if we couldn't create the file. | 181 // to the user if we couldn't create the file. |
182 base::ScopedFILE file(base::OpenFile(log_path_, "w")); | 182 base::ScopedFILE file(base::OpenFile(log_path_, "w")); |
183 if (!file) | 183 if (!file) |
184 return; | 184 return; |
185 | 185 |
186 log_type_ = log_type; | 186 log_type_ = log_type; |
187 state_ = STATE_LOGGING; | 187 state_ = STATE_LOGGING; |
188 | 188 |
189 scoped_ptr<base::Value> constants( | 189 std::unique_ptr<base::Value> constants( |
190 ChromeNetLog::GetConstants(command_line_string_, channel_string_)); | 190 ChromeNetLog::GetConstants(command_line_string_, channel_string_)); |
191 write_to_file_observer_.reset(new net::WriteToFileNetLogObserver()); | 191 write_to_file_observer_.reset(new net::WriteToFileNetLogObserver()); |
192 write_to_file_observer_->set_capture_mode(GetCaptureModeForLogType(log_type)); | 192 write_to_file_observer_->set_capture_mode(GetCaptureModeForLogType(log_type)); |
193 write_to_file_observer_->StartObserving(chrome_net_log_, std::move(file), | 193 write_to_file_observer_->StartObserving(chrome_net_log_, std::move(file), |
194 constants.get(), nullptr); | 194 constants.get(), nullptr); |
195 } | 195 } |
196 | 196 |
197 void NetLogTempFile::StopNetLog() { | 197 void NetLogTempFile::StopNetLog() { |
198 DCHECK(thread_checker_.CalledOnValidThread()); | 198 DCHECK(thread_checker_.CalledOnValidThread()); |
199 if (state_ != STATE_LOGGING) | 199 if (state_ != STATE_LOGGING) |
(...skipping 23 matching lines...) Expand all Loading... |
223 return true; | 223 return true; |
224 } | 224 } |
225 | 225 |
226 bool NetLogTempFile::NetExportLogExists() const { | 226 bool NetLogTempFile::NetExportLogExists() const { |
227 DCHECK(thread_checker_.CalledOnValidThread()); | 227 DCHECK(thread_checker_.CalledOnValidThread()); |
228 DCHECK(!log_path_.empty()); | 228 DCHECK(!log_path_.empty()); |
229 return base::PathExists(log_path_); | 229 return base::PathExists(log_path_); |
230 } | 230 } |
231 | 231 |
232 } // namespace net_log | 232 } // namespace net_log |
OLD | NEW |