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 "chrome/browser/net/net_log_temp_file.h" | 5 #include "chrome/browser/net/net_log_temp_file.h" |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/files/scoped_file.h" | 8 #include "base/files/scoped_file.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/net/chrome_net_log.h" | 10 #include "chrome/browser/net/chrome_net_log.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 dict->SetString("logType", "NORMAL"); | 86 dict->SetString("logType", "NORMAL"); |
87 break; | 87 break; |
88 case LOG_TYPE_STRIP_PRIVATE_DATA: | 88 case LOG_TYPE_STRIP_PRIVATE_DATA: |
89 dict->SetString("logType", "STRIP_PRIVATE_DATA"); | 89 dict->SetString("logType", "STRIP_PRIVATE_DATA"); |
90 break; | 90 break; |
91 } | 91 } |
92 | 92 |
93 return dict; | 93 return dict; |
94 } | 94 } |
95 | 95 |
96 net::NetLog::LogLevel NetLogTempFile::GetLogLevelForLogType(LogType log_type) { | 96 net::NetLogCaptureMode NetLogTempFile::GetCaptureModeForLogType( |
| 97 LogType log_type) { |
97 switch (log_type) { | 98 switch (log_type) { |
98 case LOG_TYPE_LOG_BYTES: | 99 case LOG_TYPE_LOG_BYTES: |
99 return net::NetLog::LOG_ALL; | 100 return net::NetLogCaptureMode::IncludeSocketBytes(); |
100 case LOG_TYPE_NORMAL: | 101 case LOG_TYPE_NORMAL: |
101 return net::NetLog::LOG_ALL_BUT_BYTES; | 102 return net::NetLogCaptureMode::IncludeCookiesAndCredentials(); |
102 case LOG_TYPE_STRIP_PRIVATE_DATA: | 103 case LOG_TYPE_STRIP_PRIVATE_DATA: |
103 return net::NetLog::LOG_STRIP_PRIVATE_DATA; | 104 return net::NetLogCaptureMode::Default(); |
104 case LOG_TYPE_NONE: | 105 case LOG_TYPE_NONE: |
105 case LOG_TYPE_UNKNOWN: | 106 case LOG_TYPE_UNKNOWN: |
106 NOTREACHED(); | 107 NOTREACHED(); |
107 } | 108 } |
108 return net::NetLog::LOG_STRIP_PRIVATE_DATA; | 109 return net::NetLogCaptureMode::Default(); |
109 } | 110 } |
110 | 111 |
111 bool NetLogTempFile::EnsureInit() { | 112 bool NetLogTempFile::EnsureInit() { |
112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); | 113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); |
113 if (state_ != STATE_UNINITIALIZED) | 114 if (state_ != STATE_UNINITIALIZED) |
114 return true; | 115 return true; |
115 | 116 |
116 if (!GetNetExportLog()) | 117 if (!GetNetExportLog()) |
117 return false; | 118 return false; |
118 | 119 |
(...skipping 19 matching lines...) Expand all Loading... |
138 // to the user if we couldn't create the file. | 139 // to the user if we couldn't create the file. |
139 base::ScopedFILE file(base::OpenFile(log_path_, "w")); | 140 base::ScopedFILE file(base::OpenFile(log_path_, "w")); |
140 if (!file) | 141 if (!file) |
141 return; | 142 return; |
142 | 143 |
143 log_type_ = log_type; | 144 log_type_ = log_type; |
144 state_ = STATE_LOGGING; | 145 state_ = STATE_LOGGING; |
145 | 146 |
146 scoped_ptr<base::Value> constants(NetInternalsUI::GetConstants()); | 147 scoped_ptr<base::Value> constants(NetInternalsUI::GetConstants()); |
147 net_log_logger_.reset(new net::WriteToFileNetLogObserver()); | 148 net_log_logger_.reset(new net::WriteToFileNetLogObserver()); |
148 net_log_logger_->set_log_level(GetLogLevelForLogType(log_type)); | 149 net_log_logger_->set_capture_mode(GetCaptureModeForLogType(log_type)); |
149 net_log_logger_->StartObserving(chrome_net_log_, file.Pass(), constants.get(), | 150 net_log_logger_->StartObserving(chrome_net_log_, file.Pass(), constants.get(), |
150 nullptr); | 151 nullptr); |
151 } | 152 } |
152 | 153 |
153 void NetLogTempFile::StopNetLog() { | 154 void NetLogTempFile::StopNetLog() { |
154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); | 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); |
155 if (state_ != STATE_LOGGING) | 156 if (state_ != STATE_LOGGING) |
156 return; | 157 return; |
157 | 158 |
158 net_log_logger_->StopObserving(nullptr); | 159 net_log_logger_->StopObserving(nullptr); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 bool NetLogTempFile::GetNetExportLogDirectory(base::FilePath* path) { | 193 bool NetLogTempFile::GetNetExportLogDirectory(base::FilePath* path) { |
193 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); | 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); |
194 return base::GetTempDir(path); | 195 return base::GetTempDir(path); |
195 } | 196 } |
196 | 197 |
197 bool NetLogTempFile::NetExportLogExists() { | 198 bool NetLogTempFile::NetExportLogExists() { |
198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); | 199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); |
199 DCHECK(!log_path_.empty()); | 200 DCHECK(!log_path_.empty()); |
200 return base::PathExists(log_path_); | 201 return base::PathExists(log_path_); |
201 } | 202 } |
OLD | NEW |