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/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 base::FilePath net_export_file_path; | 142 base::FilePath net_export_file_path; |
143 EXPECT_FALSE(net_log_temp_file_->GetFilePath(&net_export_file_path)); | 143 EXPECT_FALSE(net_log_temp_file_->GetFilePath(&net_export_file_path)); |
144 EXPECT_FALSE(net_log_temp_file_->NetExportLogExists()); | 144 EXPECT_FALSE(net_log_temp_file_->NetExportLogExists()); |
145 } | 145 } |
146 | 146 |
147 // The following methods make sure the export file has been successfully | 147 // The following methods make sure the export file has been successfully |
148 // initialized by a DO_START command of the given type. | 148 // initialized by a DO_START command of the given type. |
149 | 149 |
150 void VerifyFileAndStateAfterDoStart() { | 150 void VerifyFileAndStateAfterDoStart() { |
151 VerifyFileAndStateAfterStart(NetLogTempFile::LOG_TYPE_NORMAL, "NORMAL", | 151 VerifyFileAndStateAfterStart( |
152 net::NetLog::LOG_ALL_BUT_BYTES); | 152 NetLogTempFile::LOG_TYPE_NORMAL, "NORMAL", |
| 153 net::NetLogCaptureMode::IncludeCookiesAndCredentials()); |
153 } | 154 } |
154 | 155 |
155 void VerifyFileAndStateAfterDoStartStripPrivateData() const { | 156 void VerifyFileAndStateAfterDoStartStripPrivateData() const { |
156 VerifyFileAndStateAfterStart(NetLogTempFile::LOG_TYPE_STRIP_PRIVATE_DATA, | 157 VerifyFileAndStateAfterStart(NetLogTempFile::LOG_TYPE_STRIP_PRIVATE_DATA, |
157 "STRIP_PRIVATE_DATA", | 158 "STRIP_PRIVATE_DATA", |
158 net::NetLog::LOG_STRIP_PRIVATE_DATA); | 159 net::NetLogCaptureMode::Default()); |
159 } | 160 } |
160 | 161 |
161 void VerifyFileAndStateAfterDoStartLogBytes() const { | 162 void VerifyFileAndStateAfterDoStartLogBytes() const { |
162 VerifyFileAndStateAfterStart(NetLogTempFile::LOG_TYPE_LOG_BYTES, | 163 VerifyFileAndStateAfterStart(NetLogTempFile::LOG_TYPE_LOG_BYTES, |
163 "LOG_BYTES", net::NetLog::LOG_ALL); | 164 "LOG_BYTES", |
| 165 net::NetLogCaptureMode::IncludeSocketBytes()); |
164 } | 166 } |
165 | 167 |
166 // Make sure the export file has been successfully initialized after DO_STOP | 168 // Make sure the export file has been successfully initialized after DO_STOP |
167 // command following a DO_START command of the given type. | 169 // command following a DO_START command of the given type. |
168 | 170 |
169 void VerifyFileAndStateAfterDoStop() const { | 171 void VerifyFileAndStateAfterDoStop() const { |
170 VerifyFileAndStateAfterDoStop(NetLogTempFile::LOG_TYPE_NORMAL, "NORMAL"); | 172 VerifyFileAndStateAfterDoStop(NetLogTempFile::LOG_TYPE_NORMAL, "NORMAL"); |
171 } | 173 } |
172 | 174 |
173 void VerifyFileAndStateAfterDoStopWithStripPrivateData() const { | 175 void VerifyFileAndStateAfterDoStopWithStripPrivateData() const { |
(...skipping 10 matching lines...) Expand all Loading... |
184 // |net_log_temp_file_| is initialized after |net_log_| so that it can stop | 186 // |net_log_temp_file_| is initialized after |net_log_| so that it can stop |
185 // obvserving on destruction. | 187 // obvserving on destruction. |
186 scoped_ptr<TestNetLogTempFile> net_log_temp_file_; | 188 scoped_ptr<TestNetLogTempFile> net_log_temp_file_; |
187 base::FilePath net_export_log_; | 189 base::FilePath net_export_log_; |
188 | 190 |
189 private: | 191 private: |
190 // Checks state after one of the DO_START* commands. | 192 // Checks state after one of the DO_START* commands. |
191 void VerifyFileAndStateAfterStart( | 193 void VerifyFileAndStateAfterStart( |
192 NetLogTempFile::LogType expected_log_type, | 194 NetLogTempFile::LogType expected_log_type, |
193 const std::string& expected_log_type_string, | 195 const std::string& expected_log_type_string, |
194 net::NetLog::LogLevel expected_log_level) const { | 196 net::NetLogCaptureMode expected_capture_mode) const { |
195 EXPECT_EQ(NetLogTempFile::STATE_LOGGING, net_log_temp_file_->state()); | 197 EXPECT_EQ(NetLogTempFile::STATE_LOGGING, net_log_temp_file_->state()); |
196 EXPECT_EQ("LOGGING", GetStateString()); | 198 EXPECT_EQ("LOGGING", GetStateString()); |
197 EXPECT_EQ(expected_log_type, net_log_temp_file_->log_type()); | 199 EXPECT_EQ(expected_log_type, net_log_temp_file_->log_type()); |
198 EXPECT_EQ(expected_log_type_string, GetLogTypeString()); | 200 EXPECT_EQ(expected_log_type_string, GetLogTypeString()); |
199 | 201 |
200 EXPECT_EQ(expected_log_level, net_log_->GetLogLevel()); | 202 EXPECT_EQ(expected_capture_mode, net_log_->GetCaptureMode()); |
201 | 203 |
202 // Check GetFilePath returns false when still writing to the file. | 204 // Check GetFilePath returns false when still writing to the file. |
203 base::FilePath net_export_file_path; | 205 base::FilePath net_export_file_path; |
204 EXPECT_FALSE(net_log_temp_file_->GetFilePath(&net_export_file_path)); | 206 EXPECT_FALSE(net_log_temp_file_->GetFilePath(&net_export_file_path)); |
205 | 207 |
206 VerifyNetExportLogExists(); | 208 VerifyNetExportLogExists(); |
207 } | 209 } |
208 | 210 |
209 void VerifyFileAndStateAfterDoStop( | 211 void VerifyFileAndStateAfterDoStop( |
210 NetLogTempFile::LogType expected_log_type, | 212 NetLogTempFile::LogType expected_log_type, |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 // Log an event. | 391 // Log an event. |
390 net_log_->AddGlobalEntry(net::NetLog::TYPE_CANCELLED); | 392 net_log_->AddGlobalEntry(net::NetLog::TYPE_CANCELLED); |
391 | 393 |
392 net_log_temp_file_->ProcessCommand(NetLogTempFile::DO_STOP); | 394 net_log_temp_file_->ProcessCommand(NetLogTempFile::DO_STOP); |
393 VerifyFileAndStateAfterDoStop(); | 395 VerifyFileAndStateAfterDoStop(); |
394 | 396 |
395 int64 new_stop_file_size; | 397 int64 new_stop_file_size; |
396 EXPECT_TRUE(base::GetFileSize(net_export_log_, &new_stop_file_size)); | 398 EXPECT_TRUE(base::GetFileSize(net_export_log_, &new_stop_file_size)); |
397 EXPECT_GE(new_stop_file_size, stop_file_size); | 399 EXPECT_GE(new_stop_file_size, stop_file_size); |
398 } | 400 } |
OLD | NEW |