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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_database_unittest.cc

Issue 2034393004: Allow multiple logging::LogMessage{Handler,Listener}s Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix installation_validator_unittest Created 4 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/safe_browsing/safe_browsing_database.h" 7 #include "chrome/browser/safe_browsing/safe_browsing_database.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 return BuildChunk(chunk_number, ChunkData::ADD, ChunkData::FULL_32B, 208 return BuildChunk(chunk_number, ChunkData::ADD, ChunkData::FULL_32B,
209 &full_hash, sizeof(full_hash), std::vector<int>()); 209 &full_hash, sizeof(full_hash), std::vector<int>());
210 } 210 }
211 211
212 // Prevent DCHECK from killing tests. 212 // Prevent DCHECK from killing tests.
213 // TODO(shess): Pawel disputes the use of this, so the test which uses 213 // TODO(shess): Pawel disputes the use of this, so the test which uses
214 // it is DISABLED. http://crbug.com/56448 214 // it is DISABLED. http://crbug.com/56448
215 class ScopedLogMessageIgnorer { 215 class ScopedLogMessageIgnorer {
216 public: 216 public:
217 ScopedLogMessageIgnorer() { 217 ScopedLogMessageIgnorer() {
218 logging::SetLogMessageHandler(&LogMessageIgnorer); 218 logging::PushLogMessageHandler(&LogMessageIgnorer);
219 } 219 }
220 ~ScopedLogMessageIgnorer() { 220 ~ScopedLogMessageIgnorer() {
221 // TODO(shess): Would be better to verify whether anyone else 221 // TODO(shess): Would be better to verify whether anyone else
222 // changed it, and then restore it to the previous value. 222 // changed it, and then restore it to the previous value.
223 logging::SetLogMessageHandler(NULL); 223 logging::PopLogMessageHandler();
224 } 224 }
225 225
226 private: 226 private:
227 static bool LogMessageIgnorer(int severity, const char* file, int line, 227 static bool LogMessageIgnorer(int severity, const char* file, int line,
228 size_t message_start, const std::string& str) { 228 size_t message_start, const std::string& str) {
229 // Intercept FATAL, strip the stack backtrace, and log it without 229 // Intercept FATAL, strip the stack backtrace, and log it without
230 // the crash part. 230 // the crash part.
231 if (severity == logging::LOG_FATAL) { 231 if (severity == logging::LOG_FATAL) {
232 size_t newline = str.find('\n'); 232 size_t newline = str.find('\n');
233 if (newline != std::string::npos) { 233 if (newline != std::string::npos) {
(...skipping 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 ASSERT_EQ(1U, prefix_hits.size()); 2367 ASSERT_EQ(1U, prefix_hits.size());
2368 EXPECT_EQ(SBPrefixForString(kExampleCollision), prefix_hits[0]); 2368 EXPECT_EQ(SBPrefixForString(kExampleCollision), prefix_hits[0]);
2369 EXPECT_TRUE(cache_hits.empty()); 2369 EXPECT_TRUE(cache_hits.empty());
2370 2370
2371 // This prefix collides, but no full hash match. 2371 // This prefix collides, but no full hash match.
2372 EXPECT_FALSE(database_->ContainsBrowseUrl( 2372 EXPECT_FALSE(database_->ContainsBrowseUrl(
2373 GURL(std::string("http://") + kExampleFine), &prefix_hits, &cache_hits)); 2373 GURL(std::string("http://") + kExampleFine), &prefix_hits, &cache_hits));
2374 } 2374 }
2375 2375
2376 } // namespace safe_browsing 2376 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698