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

Side by Side Diff: components/rappor/test_rappor_service.cc

Issue 1921923002: Convert //components/[o-t]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/rappor/test_rappor_service.h" 5 #include "components/rappor/test_rappor_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h"
10 #include "components/rappor/byte_vector_utils.h" 11 #include "components/rappor/byte_vector_utils.h"
11 #include "components/rappor/proto/rappor_metric.pb.h" 12 #include "components/rappor/proto/rappor_metric.pb.h"
12 #include "components/rappor/rappor_parameters.h" 13 #include "components/rappor/rappor_parameters.h"
13 #include "components/rappor/rappor_prefs.h" 14 #include "components/rappor/rappor_prefs.h"
14 #include "components/rappor/test_log_uploader.h" 15 #include "components/rappor/test_log_uploader.h"
15 16
16 namespace rappor { 17 namespace rappor {
17 18
18 namespace { 19 namespace {
19 20
(...skipping 30 matching lines...) Expand all
50 } 51 }
51 52
52 TestSample::Shadow::~Shadow() {} 53 TestSample::Shadow::~Shadow() {}
53 54
54 TestRapporService::TestRapporService() 55 TestRapporService::TestRapporService()
55 : RapporService(&test_prefs_, base::Bind(&MockIsIncognito, &is_incognito_)), 56 : RapporService(&test_prefs_, base::Bind(&MockIsIncognito, &is_incognito_)),
56 next_rotation_(base::TimeDelta()), 57 next_rotation_(base::TimeDelta()),
57 is_incognito_(false) { 58 is_incognito_(false) {
58 RegisterPrefs(test_prefs_.registry()); 59 RegisterPrefs(test_prefs_.registry());
59 test_uploader_ = new TestLogUploader(); 60 test_uploader_ = new TestLogUploader();
60 InitializeInternal(make_scoped_ptr(test_uploader_), 61 InitializeInternal(base::WrapUnique(test_uploader_), 0,
61 0,
62 HmacByteVectorGenerator::GenerateEntropyInput()); 62 HmacByteVectorGenerator::GenerateEntropyInput());
63 Update(UMA_RAPPOR_GROUP | SAFEBROWSING_RAPPOR_GROUP, true); 63 Update(UMA_RAPPOR_GROUP | SAFEBROWSING_RAPPOR_GROUP, true);
64 } 64 }
65 65
66 TestRapporService::~TestRapporService() {} 66 TestRapporService::~TestRapporService() {}
67 67
68 scoped_ptr<Sample> TestRapporService::CreateSample(RapporType type) { 68 std::unique_ptr<Sample> TestRapporService::CreateSample(RapporType type) {
69 scoped_ptr<TestSample> test_sample(new TestSample(type)); 69 std::unique_ptr<TestSample> test_sample(new TestSample(type));
70 return std::move(test_sample); 70 return std::move(test_sample);
71 } 71 }
72 72
73 // Intercepts the sample being recorded and saves it in a test structure. 73 // Intercepts the sample being recorded and saves it in a test structure.
74 void TestRapporService::RecordSampleObj(const std::string& metric_name, 74 void TestRapporService::RecordSampleObj(const std::string& metric_name,
75 scoped_ptr<Sample> sample) { 75 std::unique_ptr<Sample> sample) {
76 TestSample* test_sample = static_cast<TestSample*>(sample.get()); 76 TestSample* test_sample = static_cast<TestSample*>(sample.get());
77 // Erase the previous sample if we logged one. 77 // Erase the previous sample if we logged one.
78 shadows_.erase(metric_name); 78 shadows_.erase(metric_name);
79 shadows_.insert(std::pair<std::string, TestSample::Shadow>( 79 shadows_.insert(std::pair<std::string, TestSample::Shadow>(
80 metric_name, test_sample->GetShadow())); 80 metric_name, test_sample->GetShadow()));
81 // Original version is still called. 81 // Original version is still called.
82 RapporService::RecordSampleObj(metric_name, std::move(sample)); 82 RapporService::RecordSampleObj(metric_name, std::move(sample));
83 } 83 }
84 84
85 void TestRapporService::RecordSample(const std::string& metric_name, 85 void TestRapporService::RecordSample(const std::string& metric_name,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 void TestRapporService::CancelNextLogRotation() { 128 void TestRapporService::CancelNextLogRotation() {
129 next_rotation_ = base::TimeDelta(); 129 next_rotation_ = base::TimeDelta();
130 } 130 }
131 131
132 // Schedule the next call to OnLogInterval. 132 // Schedule the next call to OnLogInterval.
133 void TestRapporService::ScheduleNextLogRotation(base::TimeDelta interval) { 133 void TestRapporService::ScheduleNextLogRotation(base::TimeDelta interval) {
134 next_rotation_ = interval; 134 next_rotation_ = interval;
135 } 135 }
136 136
137 } // namespace rappor 137 } // namespace rappor
OLDNEW
« no previous file with comments | « components/rappor/test_rappor_service.h ('k') | components/renderer_context_menu/context_menu_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698