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

Side by Side Diff: sql/connection_unittest.cc

Issue 1393393007: [sql] Track uploads of diagnostic data to prevent duplication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another comment tweak Created 5 years, 2 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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "base/files/memory_mapped_file.h" 7 #include "base/files/memory_mapped_file.h"
8 #include "base/files/scoped_file.h" 8 #include "base/files/scoped_file.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 #endif 1380 #endif
1381 1381
1382 TEST_F(SQLConnectionTest, OnMemoryDump) { 1382 TEST_F(SQLConnectionTest, OnMemoryDump) {
1383 base::trace_event::ProcessMemoryDump pmd(nullptr); 1383 base::trace_event::ProcessMemoryDump pmd(nullptr);
1384 base::trace_event::MemoryDumpArgs args = { 1384 base::trace_event::MemoryDumpArgs args = {
1385 base::trace_event::MemoryDumpLevelOfDetail::DETAILED}; 1385 base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
1386 ASSERT_TRUE(db().OnMemoryDump(args, &pmd)); 1386 ASSERT_TRUE(db().OnMemoryDump(args, &pmd));
1387 EXPECT_GE(pmd.allocator_dumps().size(), 1u); 1387 EXPECT_GE(pmd.allocator_dumps().size(), 1u);
1388 } 1388 }
1389 1389
1390 TEST_F(SQLConnectionTest, RegisterIntentToUpload) {
1391 base::FilePath breadcrumb_path(
1392 db_path().DirName().Append(FILE_PATH_LITERAL("sqlite-diag")));
1393
1394 // No stale diagnostic store.
1395 ASSERT_TRUE(!base::PathExists(breadcrumb_path));
1396
1397 // The histogram tag is required to enable diagnostic features.
1398 EXPECT_FALSE(db().RegisterIntentToUpload());
1399 EXPECT_TRUE(!base::PathExists(breadcrumb_path));
1400
1401 db().Close();
1402 db().set_histogram_tag("Test");
1403 ASSERT_TRUE(db().Open(db_path()));
1404
1405 // Should signal upload only once.
1406 EXPECT_TRUE(db().RegisterIntentToUpload());
1407 EXPECT_TRUE(base::PathExists(breadcrumb_path));
1408 EXPECT_FALSE(db().RegisterIntentToUpload());
1409
1410 // Changing the histogram tag should allow new upload to succeed.
1411 db().Close();
1412 db().set_histogram_tag("NewTest");
1413 ASSERT_TRUE(db().Open(db_path()));
1414 EXPECT_TRUE(db().RegisterIntentToUpload());
1415 EXPECT_FALSE(db().RegisterIntentToUpload());
1416
1417 // Old tag is still prevented.
1418 db().Close();
1419 db().set_histogram_tag("Test");
1420 ASSERT_TRUE(db().Open(db_path()));
1421 EXPECT_FALSE(db().RegisterIntentToUpload());
1422 }
1423
1390 } // namespace 1424 } // namespace
OLDNEW
« components/history/core/browser/thumbnail_database.cc ('K') | « sql/connection.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698