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

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

Issue 2905007: Add the URLRequest's priority to the net-log.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: address cbentzel comments Created 10 years, 5 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 | « no previous file | net/url_request/url_request.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/string_util.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 using net::NetLog; 18 using net::NetLog;
19 19
20 const NetLog::SourceType kSourceType = NetLog::SOURCE_NONE; 20 const NetLog::SourceType kSourceType = NetLog::SOURCE_NONE;
21 21
22 PassiveLogCollector::Entry MakeStartLogEntryWithURL(int source_id, 22 PassiveLogCollector::Entry MakeStartLogEntryWithURL(int source_id,
23 const std::string& url) { 23 const std::string& url) {
24 return PassiveLogCollector::Entry( 24 return PassiveLogCollector::Entry(
25 0, 25 0,
26 NetLog::TYPE_URL_REQUEST_START_JOB, 26 NetLog::TYPE_URL_REQUEST_START_JOB,
27 base::TimeTicks(), 27 base::TimeTicks(),
28 NetLog::Source(kSourceType, source_id), 28 NetLog::Source(kSourceType, source_id),
29 NetLog::PHASE_BEGIN, 29 NetLog::PHASE_BEGIN,
30 new URLRequestStartEventParameters(GURL(url), "GET", 0)); 30 new URLRequestStartEventParameters(GURL(url), "GET", 0, net::LOW));
31 } 31 }
32 32
33 PassiveLogCollector::Entry MakeStartLogEntry(int source_id) { 33 PassiveLogCollector::Entry MakeStartLogEntry(int source_id) {
34 return MakeStartLogEntryWithURL(source_id, 34 return MakeStartLogEntryWithURL(source_id,
35 StringPrintf("http://req%d", source_id)); 35 StringPrintf("http://req%d", source_id));
36 } 36 }
37 37
38 PassiveLogCollector::Entry MakeEndLogEntry(int source_id) { 38 PassiveLogCollector::Entry MakeEndLogEntry(int source_id) {
39 return PassiveLogCollector::Entry( 39 return PassiveLogCollector::Entry(
40 0, 40 0,
41 NetLog::TYPE_REQUEST_ALIVE, 41 NetLog::TYPE_REQUEST_ALIVE,
42 base::TimeTicks(), 42 base::TimeTicks(),
43 NetLog::Source(kSourceType, source_id), 43 NetLog::Source(kSourceType, source_id),
44 NetLog::PHASE_END, 44 NetLog::PHASE_END,
45 NULL); 45 NULL);
46 } 46 }
47 47
48 void AddStartURLRequestEntries(PassiveLogCollector* collector, uint32 id) { 48 void AddStartURLRequestEntries(PassiveLogCollector* collector, uint32 id) {
49 collector->OnAddEntry(NetLog::TYPE_REQUEST_ALIVE, base::TimeTicks(), 49 collector->OnAddEntry(NetLog::TYPE_REQUEST_ALIVE, base::TimeTicks(),
50 NetLog::Source(NetLog::SOURCE_URL_REQUEST, id), 50 NetLog::Source(NetLog::SOURCE_URL_REQUEST, id),
51 NetLog::PHASE_BEGIN, NULL); 51 NetLog::PHASE_BEGIN, NULL);
52 collector->OnAddEntry(NetLog::TYPE_URL_REQUEST_START_JOB, base::TimeTicks(), 52 collector->OnAddEntry(NetLog::TYPE_URL_REQUEST_START_JOB, base::TimeTicks(),
53 NetLog::Source(NetLog::SOURCE_URL_REQUEST, id), 53 NetLog::Source(NetLog::SOURCE_URL_REQUEST, id),
54 NetLog::PHASE_BEGIN, new URLRequestStartEventParameters( 54 NetLog::PHASE_BEGIN, new URLRequestStartEventParameters(
55 GURL(StringPrintf("http://req%d", id)), "GET", 0)); 55 GURL(StringPrintf("http://req%d", id)), "GET", 0,
56 net::LOW));
56 } 57 }
57 58
58 void AddEndURLRequestEntries(PassiveLogCollector* collector, uint32 id) { 59 void AddEndURLRequestEntries(PassiveLogCollector* collector, uint32 id) {
59 collector->OnAddEntry(NetLog::TYPE_REQUEST_ALIVE, base::TimeTicks(), 60 collector->OnAddEntry(NetLog::TYPE_REQUEST_ALIVE, base::TimeTicks(),
60 NetLog::Source(NetLog::SOURCE_URL_REQUEST, id), 61 NetLog::Source(NetLog::SOURCE_URL_REQUEST, id),
61 NetLog::PHASE_END, NULL); 62 NetLog::PHASE_END, NULL);
62 } 63 }
63 64
64 std::string GetStringParam(const PassiveLogCollector::Entry& entry) { 65 std::string GetStringParam(const PassiveLogCollector::Entry& entry) {
65 return static_cast<net::NetLogStringParameter*>( 66 return static_cast<net::NetLogStringParameter*>(
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 log.OnAddEntry(NetLog::TYPE_REQUEST_ALIVE, 453 log.OnAddEntry(NetLog::TYPE_REQUEST_ALIVE,
453 base::TimeTicks(), 454 base::TimeTicks(),
454 NetLog::Source(NetLog::SOURCE_URL_REQUEST, next_id++), 455 NetLog::Source(NetLog::SOURCE_URL_REQUEST, next_id++),
455 NetLog::PHASE_END, 456 NetLog::PHASE_END,
456 NULL); 457 NULL);
457 } 458 }
458 EXPECT_EQ(RequestTracker::kMaxGraveyardSize, 459 EXPECT_EQ(RequestTracker::kMaxGraveyardSize,
459 GetDeadSources(log.url_request_tracker_).size()); 460 GetDeadSources(log.url_request_tracker_).size());
460 } 461 }
461 462
OLDNEW
« no previous file with comments | « no previous file | net/url_request/url_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698