| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Unit tests for the SafeBrowsing storage system. | 5 // Unit tests for the SafeBrowsing storage system. |
| 6 | 6 |
| 7 #include "app/sql/connection.h" | 7 #include "app/sql/connection.h" |
| 8 #include "app/sql/statement.h" | 8 #include "app/sql/statement.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 ScopedLogMessageIgnorer() { | 44 ScopedLogMessageIgnorer() { |
| 45 logging::SetLogMessageHandler(&LogMessageIgnorer); | 45 logging::SetLogMessageHandler(&LogMessageIgnorer); |
| 46 } | 46 } |
| 47 ~ScopedLogMessageIgnorer() { | 47 ~ScopedLogMessageIgnorer() { |
| 48 // TODO(shess): Would be better to verify whether anyone else | 48 // TODO(shess): Would be better to verify whether anyone else |
| 49 // changed it, and then restore it to the previous value. | 49 // changed it, and then restore it to the previous value. |
| 50 logging::SetLogMessageHandler(NULL); | 50 logging::SetLogMessageHandler(NULL); |
| 51 } | 51 } |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 static bool LogMessageIgnorer(int severity, const std::string& str) { | 54 static bool LogMessageIgnorer(int severity, const char* file, int line, |
| 55 size_t message_start, const std::string& str) { |
| 55 // Intercept FATAL, strip the stack backtrace, and log it without | 56 // Intercept FATAL, strip the stack backtrace, and log it without |
| 56 // the crash part. | 57 // the crash part. |
| 57 if (severity == logging::LOG_FATAL) { | 58 if (severity == logging::LOG_FATAL) { |
| 58 size_t newline = str.find('\n'); | 59 size_t newline = str.find('\n'); |
| 59 if (newline != std::string::npos) { | 60 if (newline != std::string::npos) { |
| 60 const std::string msg = str.substr(0, newline + 1); | 61 const std::string msg = str.substr(0, newline + 1); |
| 61 fprintf(stderr, "%s", msg.c_str()); | 62 fprintf(stderr, "%s", msg.c_str()); |
| 62 fflush(stderr); | 63 fflush(stderr); |
| 63 } | 64 } |
| 64 return true; | 65 return true; |
| (...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 EXPECT_FALSE(file_util::PathExists(database_filename_)); | 1152 EXPECT_FALSE(file_util::PathExists(database_filename_)); |
| 1152 | 1153 |
| 1153 // Run the update again successfully. | 1154 // Run the update again successfully. |
| 1154 EXPECT_TRUE(database_->UpdateStarted(&lists)); | 1155 EXPECT_TRUE(database_->UpdateStarted(&lists)); |
| 1155 database_->InsertChunks(safe_browsing_util::kMalwareList, chunks); | 1156 database_->InsertChunks(safe_browsing_util::kMalwareList, chunks); |
| 1156 database_->UpdateFinished(true); | 1157 database_->UpdateFinished(true); |
| 1157 EXPECT_TRUE(file_util::PathExists(database_filename_)); | 1158 EXPECT_TRUE(file_util::PathExists(database_filename_)); |
| 1158 | 1159 |
| 1159 database_.reset(); | 1160 database_.reset(); |
| 1160 } | 1161 } |
| OLD | NEW |