Skip to content

Commit

Permalink
CapturingNetLog - remove maximum entries constructor argument.
Browse files Browse the repository at this point in the history
Also replace with a NULL NetLog in a couple callsites where it
wasn't being used.

R=eroman@chromium.org
BUG=none

Review URL: https://chromiumcodereview.appspot.com/10546071

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141315 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mmenke@chromium.org committed Jun 8, 2012
1 parent 32219e2 commit 333bdf6
Show file tree
Hide file tree
Showing 24 changed files with 141 additions and 161 deletions.
16 changes: 8 additions & 8 deletions net/base/capturing_net_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ bool CapturingNetLog::CapturedEntry::GetNetErrorCode(int* value) const {
return GetIntegerValue("net_error", value);
}

CapturingNetLog::CapturingNetLog(size_t max_num_entries)
CapturingNetLog::CapturingNetLog()
: last_id_(0),
max_num_entries_(max_num_entries),
log_level_(LOG_ALL_BUT_BYTES) {
}

Expand All @@ -86,10 +85,9 @@ void CapturingNetLog::AddEntry(
const Source& source,
EventPhase phase,
const scoped_refptr<EventParameters>& extra_parameters) {
// Only BoundNetLogs without a NetLog should have an invalid source.
DCHECK(source.is_valid());
base::AutoLock lock(lock_);
if (captured_entries_.size() >= max_num_entries_)
return;

// Using Dictionaries instead of Values makes checking values a little
// simpler.
DictionaryValue* param_dict = NULL;
Expand All @@ -98,6 +96,9 @@ void CapturingNetLog::AddEntry(
if (param_value && !param_value->GetAsDictionary(&param_dict))
delete param_value;
}

// Only need to acquire the lock when accessing class variables.
base::AutoLock lock(lock_);
captured_entries_.push_back(
CapturedEntry(type,
base::TimeTicks::Now(),
Expand Down Expand Up @@ -131,9 +132,8 @@ void CapturingNetLog::RemoveThreadSafeObserver(
NOTIMPLEMENTED() << "Not currently used by net unit tests.";
}

CapturingBoundNetLog::CapturingBoundNetLog(size_t max_num_entries)
: capturing_net_log_(max_num_entries),
net_log_(BoundNetLog::Make(&capturing_net_log_,
CapturingBoundNetLog::CapturingBoundNetLog()
: net_log_(BoundNetLog::Make(&capturing_net_log_,
net::NetLog::SOURCE_NONE)) {
}

Expand Down
10 changes: 2 additions & 8 deletions net/base/capturing_net_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ class CapturingNetLog : public NetLog {
// Ordered set of entries that were logged.
typedef std::vector<CapturedEntry> CapturedEntryList;

enum { kUnbounded = -1 };

// Creates a CapturingNetLog that logs a maximum of |max_num_entries|
// messages.
explicit CapturingNetLog(size_t max_num_entries);
CapturingNetLog();
virtual ~CapturingNetLog();

// Returns the list of all entries in the log.
Expand Down Expand Up @@ -100,7 +96,6 @@ class CapturingNetLog : public NetLog {
// Last assigned source ID. Incremented to get the next one.
base::subtle::Atomic32 last_id_;

size_t max_num_entries_;
CapturedEntryList captured_entries_;

NetLog::LogLevel log_level_;
Expand All @@ -115,8 +110,7 @@ class CapturingNetLog : public NetLog {
// bound() method.
class CapturingBoundNetLog {
public:
explicit CapturingBoundNetLog(size_t max_num_entries);

CapturingBoundNetLog();
~CapturingBoundNetLog();

// The returned BoundNetLog is only valid while |this| is alive.
Expand Down
2 changes: 1 addition & 1 deletion net/base/net_log_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace net {
namespace {

TEST(NetLog, ScopedNetLogEventTest) {
CapturingNetLog log(CapturingNetLog::kUnbounded);
CapturingNetLog log;
BoundNetLog net_log(BoundNetLog::Make(&log, NetLog::SOURCE_URL_REQUEST));

scoped_ptr<ScopedNetLogEvent> net_log_event(
Expand Down
4 changes: 2 additions & 2 deletions net/http/http_auth_handler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST(HttpAuthHandlerTest, NetLog) {
HttpAuth::ChallengeTokenizer tokenizer(
challenge.begin(), challenge.end());
HttpAuthHandlerMock mock_handler;
CapturingNetLog capturing_net_log(CapturingNetLog::kUnbounded);
CapturingNetLog capturing_net_log;
BoundNetLog bound_net_log(BoundNetLog::Make(&capturing_net_log,
net::NetLog::SOURCE_NONE));

Expand All @@ -48,7 +48,7 @@ TEST(HttpAuthHandlerTest, NetLog) {
if (async)
test_callback.WaitForResult();

net::CapturingNetLog::CapturedEntryList entries;
CapturingNetLog::CapturedEntryList entries;
capturing_net_log.GetEntries(&entries);

EXPECT_EQ(2u, entries.size());
Expand Down
6 changes: 3 additions & 3 deletions net/http/http_cache_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ TEST(HttpCache, SimpleGETNoDiskCache) {

cache.disk_cache()->set_fail_requests();

net::CapturingBoundNetLog log(net::CapturingNetLog::kUnbounded);
net::CapturingBoundNetLog log;
log.SetLogLevel(net::NetLog::LOG_BASIC);

// Read from the network, and don't use the cache.
Expand Down Expand Up @@ -569,7 +569,7 @@ TEST(HttpCache, SimpleGETWithDiskFailures3) {
TEST(HttpCache, SimpleGET_LoadOnlyFromCache_Hit) {
MockHttpCache cache;

net::CapturingBoundNetLog log(net::CapturingNetLog::kUnbounded);
net::CapturingBoundNetLog log;

// This prevents a number of write events from being logged.
log.SetLogLevel(net::NetLog::LOG_BASIC);
Expand Down Expand Up @@ -702,7 +702,7 @@ TEST(HttpCache, SimpleGET_LoadBypassCache) {
MockTransaction transaction(kSimpleGET_Transaction);
transaction.load_flags |= net::LOAD_BYPASS_CACHE;

net::CapturingBoundNetLog log(net::CapturingNetLog::kUnbounded);
net::CapturingBoundNetLog log;

// This prevents a number of write events from being logged.
log.SetLogLevel(net::NetLog::LOG_BASIC);
Expand Down
38 changes: 19 additions & 19 deletions net/http/http_network_transaction_spdy2_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class HttpNetworkTransactionSpdy2Test : public PlatformTest {

TestCompletionCallback callback;

CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
EXPECT_TRUE(log.bound().IsLoggingAllEvents());
int rv = trans->Start(&request, callback.callback(), log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
Expand Down Expand Up @@ -1741,7 +1741,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyNoKeepAlive) {

// Configure against proxy server "myproxy:70".
SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));

Expand Down Expand Up @@ -1847,7 +1847,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyKeepAlive) {

// Configure against proxy server "myproxy:70".
SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));

Expand Down Expand Up @@ -2050,7 +2050,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test,
request.url = GURL("https://www.google.com/");

SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));

Expand Down Expand Up @@ -2109,7 +2109,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxyGet) {
// Configure against https proxy server "proxy:70".
SessionDependencies session_deps(ProxyService::CreateFixed(
"https://proxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));

Expand Down Expand Up @@ -2165,7 +2165,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyGet) {
// Configure against https proxy server "proxy:70".
SessionDependencies session_deps(ProxyService::CreateFixed(
"https://proxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));

Expand Down Expand Up @@ -2223,7 +2223,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyGetWithProxyAuth) {
// Configure against https proxy server "myproxy:70".
SessionDependencies session_deps(
ProxyService::CreateFixed("https://myproxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));

Expand Down Expand Up @@ -2323,7 +2323,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectHttps) {
// Configure against https proxy server "proxy:70".
SessionDependencies session_deps(ProxyService::CreateFixed(
"https://proxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));

Expand Down Expand Up @@ -2404,7 +2404,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectSpdy) {
// Configure against https proxy server "proxy:70".
SessionDependencies session_deps(ProxyService::CreateFixed(
"https://proxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));

Expand Down Expand Up @@ -2483,7 +2483,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectFailure) {
// Configure against https proxy server "proxy:70".
SessionDependencies session_deps(ProxyService::CreateFixed(
"https://proxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));

Expand Down Expand Up @@ -2542,7 +2542,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxyAuthRetry) {
// Configure against https proxy server "myproxy:70".
SessionDependencies session_deps(
ProxyService::CreateFixed("https://myproxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));

Expand Down Expand Up @@ -4918,7 +4918,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthSpdyProxy) {
// Configure against https proxy server "myproxy:70".
SessionDependencies session_deps(
ProxyService::CreateFixed("https://myproxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));

Expand Down Expand Up @@ -5066,7 +5066,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, CrossOriginProxyPush) {
// Configure against https proxy server "myproxy:70".
SessionDependencies session_deps(
ProxyService::CreateFixed("https://myproxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();

// Enable cross-origin push.
Expand Down Expand Up @@ -5164,7 +5164,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, CrossOriginProxyPushCorrectness) {
// Configure against https proxy server "myproxy:70".
SessionDependencies session_deps(
ProxyService::CreateFixed("https://myproxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();

// Enable cross-origin push.
Expand Down Expand Up @@ -8793,7 +8793,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, SimpleCancel) {

TestCompletionCallback callback;

CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
int rv = trans->Start(&request, callback.callback(), log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
trans.reset(); // Cancel the transaction here.
Expand All @@ -8804,7 +8804,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, SimpleCancel) {
// Test a basic GET request through a proxy.
TEST_F(HttpNetworkTransactionSpdy2Test, ProxyGet) {
SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));

Expand Down Expand Up @@ -8852,7 +8852,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, ProxyGet) {
// Test a basic HTTPS GET request through a proxy.
TEST_F(HttpNetworkTransactionSpdy2Test, ProxyTunnelGet) {
SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));

Expand Down Expand Up @@ -8919,7 +8919,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, ProxyTunnelGet) {
// while establishing the tunnel.
TEST_F(HttpNetworkTransactionSpdy2Test, ProxyTunnelGetHangup) {
SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));

Expand Down Expand Up @@ -9307,7 +9307,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test,
TEST_F(HttpNetworkTransactionSpdy2Test, ClientAuthCertCache_Proxy_Fail) {
SessionDependencies session_deps(
ProxyService::CreateFixed("https://proxy:70"));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log;
session_deps.net_log = log.bound().net_log();

scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo());
Expand Down
Loading

0 comments on commit 333bdf6

Please sign in to comment.