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

Side by Side Diff: components/sync_sessions/sync_sessions_metrics_unittest.cc

Issue 2257793002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/sync_sessions/sync_sessions_metrics.h" 5 #include "components/sync_sessions/sync_sessions_metrics.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/test/histogram_tester.h" 10 #include "base/test/histogram_tester.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 class SyncSessionsMetricsTest : public ::testing::Test { 58 class SyncSessionsMetricsTest : public ::testing::Test {
59 protected: 59 protected:
60 SyncSessionsMetricsTest() : fake_manager_(&fake_client_, &sessions_) {} 60 SyncSessionsMetricsTest() : fake_manager_(&fake_client_, &sessions_) {}
61 61
62 // Sets the tab/window/session timestamps and creates anything needed. The new 62 // Sets the tab/window/session timestamps and creates anything needed. The new
63 // calls in here are safe because the session/window objects are going to 63 // calls in here are safe because the session/window objects are going to
64 // delete all their children when their destructors are invoked. 64 // delete all their children when their destructors are invoked.
65 void PushTab(size_t tabIndex, int windowIndex, Time timestamp) { 65 void PushTab(size_t tabIndex, int windowIndex, Time timestamp) {
66 // First add sessions/windows as necessary. 66 // First add sessions/windows as necessary.
67 while (tabIndex >= sessions_.size()) { 67 while (tabIndex >= sessions_.size()) {
68 sessions_.push_back(base::WrapUnique(new SyncedSession())); 68 sessions_.push_back(base::MakeUnique<SyncedSession>());
69 } 69 }
70 if (sessions_[tabIndex]->windows.find(windowIndex) == 70 if (sessions_[tabIndex]->windows.find(windowIndex) ==
71 sessions_[tabIndex]->windows.end()) { 71 sessions_[tabIndex]->windows.end()) {
72 sessions_[tabIndex]->windows[windowIndex] = new SessionWindow(); 72 sessions_[tabIndex]->windows[windowIndex] = new SessionWindow();
73 } 73 }
74 74
75 sessions_[tabIndex]->modified_time = 75 sessions_[tabIndex]->modified_time =
76 std::max(sessions_[tabIndex]->modified_time, timestamp); 76 std::max(sessions_[tabIndex]->modified_time, timestamp);
77 sessions_[tabIndex]->windows[windowIndex]->timestamp = std::max( 77 sessions_[tabIndex]->windows[windowIndex]->timestamp = std::max(
78 sessions_[tabIndex]->windows[windowIndex]->timestamp, timestamp); 78 sessions_[tabIndex]->windows[windowIndex]->timestamp, timestamp);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 TEST_F(SyncSessionsMetricsTest, EmitNormalCase) { 197 TEST_F(SyncSessionsMetricsTest, EmitNormalCase) {
198 base::HistogramTester histogram_tester; 198 base::HistogramTester histogram_tester;
199 PushTab(0, 0, Time::Now() - TimeDelta::FromHours(1)); 199 PushTab(0, 0, Time::Now() - TimeDelta::FromHours(1));
200 SyncSessionsMetrics::RecordYoungestForeignTabAgeOnNTP( 200 SyncSessionsMetrics::RecordYoungestForeignTabAgeOnNTP(
201 get_sessions_sync_manager()); 201 get_sessions_sync_manager());
202 histogram_tester.ExpectTotalCount("Sync.YoungestForeignTabAgeOnNTP", 1); 202 histogram_tester.ExpectTotalCount("Sync.YoungestForeignTabAgeOnNTP", 1);
203 } 203 }
204 204
205 } // namespace sync_sessions 205 } // namespace sync_sessions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698