OLD | NEW |
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 "net/url_request/url_request_throttler_manager.h" | 5 #include "net/url_request/url_request_throttler_manager.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/metrics/statistics_recorder.h" | 9 #include "base/metrics/statistics_recorder.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 Histogram::SampleSet& original = original_samples_[name]; | 221 Histogram::SampleSet& original = original_samples_[name]; |
222 Histogram::SampleSet& sample = samples_[name]; | 222 Histogram::SampleSet& sample = samples_[name]; |
223 | 223 |
224 Histogram* histogram = StatisticsRecorder::FindHistogram(name); | 224 Histogram* histogram = StatisticsRecorder::FindHistogram(name); |
225 if (histogram) { | 225 if (histogram) { |
226 ASSERT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags()); | 226 ASSERT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags()); |
227 | 227 |
228 histogram->SnapshotSample(&sample); | 228 histogram->SnapshotSample(&sample); |
229 // Ensure |original| size is same as |sample|, then subtract original | 229 // Ensure |original| size is same as |sample|, then subtract original |
230 // values. | 230 // values. |
231 original.Resize(*histogram); | 231 original.Resize(histogram->bucket_count()); |
232 sample.Subtract(original); | 232 sample.Subtract(original); |
233 } | 233 } |
234 } | 234 } |
235 | 235 |
236 // Ensure we don't accidentally use the originals in our tests. | 236 // Ensure we don't accidentally use the originals in our tests. |
237 original_samples_.clear(); | 237 original_samples_.clear(); |
238 } | 238 } |
239 | 239 |
240 std::ostream& operator<<(std::ostream& out, const base::TimeTicks& time) { | 240 std::ostream& operator<<(std::ostream& out, const base::TimeTicks& time) { |
241 return out << time.ToInternalValue(); | 241 return out << time.ToInternalValue(); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 FAIL(); | 545 FAIL(); |
546 } | 546 } |
547 | 547 |
548 scoped_refptr<net::URLRequestThrottlerEntryInterface> entry_after = | 548 scoped_refptr<net::URLRequestThrottlerEntryInterface> entry_after = |
549 manager.RegisterRequestUrl(GURL("http://www.example.com/")); | 549 manager.RegisterRequestUrl(GURL("http://www.example.com/")); |
550 EXPECT_FALSE(entry_after->ShouldRejectRequest(request_)); | 550 EXPECT_FALSE(entry_after->ShouldRejectRequest(request_)); |
551 } | 551 } |
552 } | 552 } |
553 | 553 |
554 } // namespace net | 554 } // namespace net |
OLD | NEW |