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

Side by Side Diff: chrome/browser/net/passive_log_collector_unittest.cc

Issue 1560025: Initialize the new net internals page using the passively collected log entri... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Add missing unittest file Created 10 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/net/passive_log_collector.h" 5 #include "chrome/browser/net/passive_log_collector.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace { 12 namespace {
13 13
14 typedef PassiveLogCollector::RequestTracker RequestTracker; 14 typedef PassiveLogCollector::RequestTracker RequestTracker;
15 typedef PassiveLogCollector::RequestInfoList RequestInfoList; 15 typedef PassiveLogCollector::RequestInfoList RequestInfoList;
16 16
17 const net::NetLog::SourceType kSourceType = net::NetLog::SOURCE_NONE; 17 const net::NetLog::SourceType kSourceType = net::NetLog::SOURCE_NONE;
18 18
19 net::CapturingNetLog::Entry MakeStartLogEntryWithURL(int source_id, 19 PassiveLogCollector::Entry MakeStartLogEntryWithURL(int source_id,
20 const std::string& url) { 20 const std::string& url) {
21 return net::CapturingNetLog::Entry( 21 return PassiveLogCollector::Entry(
22 0,
22 net::NetLog::TYPE_URL_REQUEST_START, 23 net::NetLog::TYPE_URL_REQUEST_START,
23 base::TimeTicks(), 24 base::TimeTicks(),
24 net::NetLog::Source(kSourceType, source_id), 25 net::NetLog::Source(kSourceType, source_id),
25 net::NetLog::PHASE_BEGIN, 26 net::NetLog::PHASE_BEGIN,
26 new net::NetLogStringParameter(url)); 27 new net::NetLogStringParameter(url));
27 } 28 }
28 29
29 net::CapturingNetLog::Entry MakeStartLogEntry(int source_id) { 30 PassiveLogCollector::Entry MakeStartLogEntry(int source_id) {
30 return MakeStartLogEntryWithURL(source_id, 31 return MakeStartLogEntryWithURL(source_id,
31 StringPrintf("http://req%d", source_id)); 32 StringPrintf("http://req%d", source_id));
32 } 33 }
33 34
34 net::CapturingNetLog::Entry MakeEndLogEntry(int source_id) { 35 PassiveLogCollector::Entry MakeEndLogEntry(int source_id) {
35 return net::CapturingNetLog::Entry( 36 return PassiveLogCollector::Entry(
37 0,
36 net::NetLog::TYPE_REQUEST_ALIVE, 38 net::NetLog::TYPE_REQUEST_ALIVE,
37 base::TimeTicks(), 39 base::TimeTicks(),
38 net::NetLog::Source(kSourceType, source_id), 40 net::NetLog::Source(kSourceType, source_id),
39 net::NetLog::PHASE_END, 41 net::NetLog::PHASE_END,
40 NULL); 42 NULL);
41 } 43 }
42 44
43 static const int kMaxNumLoadLogEntries = 1; 45 static const int kMaxNumLoadLogEntries = 1;
44 46
45 TEST(RequestTrackerTest, BasicBounded) { 47 TEST(RequestTrackerTest, BasicBounded) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 for (size_t i = kMaxSize; i < 2 * kMaxSize; ++i) { 187 for (size_t i = kMaxSize; i < 2 * kMaxSize; ++i) {
186 tracker.OnAddEntry(MakeStartLogEntry(i)); 188 tracker.OnAddEntry(MakeStartLogEntry(i));
187 tracker.OnAddEntry(MakeEndLogEntry(i)); 189 tracker.OnAddEntry(MakeEndLogEntry(i));
188 } 190 }
189 191
190 // We should only have kMaxGraveyardSize entries now. 192 // We should only have kMaxGraveyardSize entries now.
191 ASSERT_EQ(kMaxSize, tracker.GetRecentlyDeceased().size()); 193 ASSERT_EQ(kMaxSize, tracker.GetRecentlyDeceased().size());
192 } 194 }
193 195
194 } // namespace 196 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/net/passive_log_collector.cc ('k') | chrome/browser/net/view_net_internals_job_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698