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

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

Issue 7004007: iwyu: Include stringprintf.h where appropriate, part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix 2. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/net/load_timing_observer_unittest.cc ('k') | chrome/browser/net/predictor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/stringprintf.h"
10 #include "net/url_request/url_request_netlog_params.h" 10 #include "net/url_request/url_request_netlog_params.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace { 13 namespace {
14 14
15 typedef PassiveLogCollector::RequestTracker RequestTracker; 15 typedef PassiveLogCollector::RequestTracker RequestTracker;
16 typedef PassiveLogCollector::SourceInfoList SourceInfoList; 16 typedef PassiveLogCollector::SourceInfoList SourceInfoList;
17 typedef PassiveLogCollector::SocketTracker SocketTracker; 17 typedef PassiveLogCollector::SocketTracker SocketTracker;
18 typedef PassiveLogCollector::HttpStreamJobTracker HttpStreamJobTracker; 18 typedef PassiveLogCollector::HttpStreamJobTracker HttpStreamJobTracker;
19 using net::NetLog; 19 using net::NetLog;
20 20
21 const NetLog::SourceType kSourceType = NetLog::SOURCE_NONE; 21 const NetLog::SourceType kSourceType = NetLog::SOURCE_NONE;
22 22
23 ChromeNetLog::Entry MakeStartLogEntryWithURL(int source_id, 23 ChromeNetLog::Entry MakeStartLogEntryWithURL(int source_id,
24 const std::string& url) { 24 const std::string& url) {
25 return ChromeNetLog::Entry( 25 return ChromeNetLog::Entry(
26 0, 26 0,
27 NetLog::TYPE_URL_REQUEST_START_JOB, 27 NetLog::TYPE_URL_REQUEST_START_JOB,
28 base::TimeTicks(), 28 base::TimeTicks(),
29 NetLog::Source(kSourceType, source_id), 29 NetLog::Source(kSourceType, source_id),
30 NetLog::PHASE_BEGIN, 30 NetLog::PHASE_BEGIN,
31 new net::URLRequestStartEventParameters(GURL(url), "GET", 0, net::LOW)); 31 new net::URLRequestStartEventParameters(GURL(url), "GET", 0, net::LOW));
32 } 32 }
33 33
34 ChromeNetLog::Entry MakeStartLogEntry(int source_id) { 34 ChromeNetLog::Entry MakeStartLogEntry(int source_id) {
35 return MakeStartLogEntryWithURL(source_id, 35 return MakeStartLogEntryWithURL(
36 StringPrintf("http://req%d", source_id)); 36 source_id, base::StringPrintf("http://req%d", source_id));
37 } 37 }
38 38
39 ChromeNetLog::Entry MakeEndLogEntry(int source_id) { 39 ChromeNetLog::Entry MakeEndLogEntry(int source_id) {
40 return ChromeNetLog::Entry( 40 return ChromeNetLog::Entry(
41 0, 41 0,
42 NetLog::TYPE_REQUEST_ALIVE, 42 NetLog::TYPE_REQUEST_ALIVE,
43 base::TimeTicks(), 43 base::TimeTicks(),
44 NetLog::Source(kSourceType, source_id), 44 NetLog::Source(kSourceType, source_id),
45 NetLog::PHASE_END, 45 NetLog::PHASE_END,
46 NULL); 46 NULL);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 EXPECT_EQ(0u, GetLiveSources(tracker).size()); 135 EXPECT_EQ(0u, GetLiveSources(tracker).size());
136 136
137 // Check that only the last |kMaxGraveyardSize| requests are in-memory. 137 // Check that only the last |kMaxGraveyardSize| requests are in-memory.
138 138
139 SourceInfoList recent = GetDeadSources(tracker); 139 SourceInfoList recent = GetDeadSources(tracker);
140 140
141 ASSERT_EQ(RequestTracker::kMaxGraveyardSize, recent.size()); 141 ASSERT_EQ(RequestTracker::kMaxGraveyardSize, recent.size());
142 142
143 for (size_t i = 0; i < RequestTracker::kMaxGraveyardSize; ++i) { 143 for (size_t i = 0; i < RequestTracker::kMaxGraveyardSize; ++i) {
144 size_t req_number = i + RequestTracker::kMaxGraveyardSize; 144 size_t req_number = i + RequestTracker::kMaxGraveyardSize;
145 std::string url = StringPrintf("http://req%" PRIuS "/", req_number); 145 std::string url = base::StringPrintf("http://req%" PRIuS "/", req_number);
146 EXPECT_EQ(url, recent[i].GetURL()); 146 EXPECT_EQ(url, recent[i].GetURL());
147 } 147 }
148 } 148 }
149 149
150 // Check that we exclude "chrome://" URLs from being saved into the recent 150 // Check that we exclude "chrome://" URLs from being saved into the recent
151 // requests list (graveyard). 151 // requests list (graveyard).
152 TEST(RequestTrackerTest, GraveyardIsFiltered) { 152 TEST(RequestTrackerTest, GraveyardIsFiltered) {
153 RequestTracker tracker(NULL); 153 RequestTracker tracker(NULL);
154 154
155 // This will be excluded. 155 // This will be excluded.
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 i < PassiveLogCollector::HttpStreamJobTracker::kMaxGraveyardSize; ++i) { 485 i < PassiveLogCollector::HttpStreamJobTracker::kMaxGraveyardSize; ++i) {
486 log.OnAddEntry(net::NetLog::TYPE_HTTP_STREAM_JOB, 486 log.OnAddEntry(net::NetLog::TYPE_HTTP_STREAM_JOB,
487 base::TimeTicks(), 487 base::TimeTicks(),
488 net::NetLog::Source(net::NetLog::SOURCE_HTTP_STREAM_JOB, i), 488 net::NetLog::Source(net::NetLog::SOURCE_HTTP_STREAM_JOB, i),
489 net::NetLog::PHASE_END, 489 net::NetLog::PHASE_END,
490 NULL); 490 NULL);
491 } 491 }
492 492
493 // To pass, this should simply not have DCHECK-ed above. 493 // To pass, this should simply not have DCHECK-ed above.
494 } 494 }
OLDNEW
« no previous file with comments | « chrome/browser/net/load_timing_observer_unittest.cc ('k') | chrome/browser/net/predictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698