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

Unified Diff: net/http/http_cache_unittest.cc

Issue 10834313: Add histograms for network activity, and total/cumulative (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: net/http/http_cache_unittest.cc
===================================================================
--- net/http/http_cache_unittest.cc (revision 150909)
+++ net/http/http_cache_unittest.cc (working copy)
@@ -62,28 +62,48 @@
class TestHttpTransactionDelegate : public net::HttpTransactionDelegate {
public:
- explicit TestHttpTransactionDelegate(int num_actions_to_observe)
- : num_remaining_actions_to_observe_(num_actions_to_observe),
- action_in_progress_(false) {
+ explicit TestHttpTransactionDelegate(int num_cache_actions_to_observe,
+ int num_network_actions_to_observe)
+ : num_remaining_cache_actions_to_observe_(num_cache_actions_to_observe),
+ num_remaining_network_actions_to_observe_(
+ num_network_actions_to_observe),
+ cache_action_in_progress_(false),
+ network_action_in_progress_(false) {
}
virtual ~TestHttpTransactionDelegate() {
- EXPECT_EQ(0, num_remaining_actions_to_observe_);
- EXPECT_FALSE(action_in_progress_);
+ EXPECT_EQ(0, num_remaining_cache_actions_to_observe_);
+ EXPECT_EQ(0, num_remaining_network_actions_to_observe_);
+ EXPECT_FALSE(cache_action_in_progress_);
+ EXPECT_FALSE(network_action_in_progress_);
}
virtual void OnCacheActionStart() {
- EXPECT_FALSE(action_in_progress_);
- EXPECT_GT(num_remaining_actions_to_observe_, 0);
- num_remaining_actions_to_observe_--;
- action_in_progress_ = true;
+ EXPECT_FALSE(cache_action_in_progress_);
+ EXPECT_FALSE(network_action_in_progress_);
+ EXPECT_GT(num_remaining_cache_actions_to_observe_, 0);
+ num_remaining_cache_actions_to_observe_--;
+ cache_action_in_progress_ = true;
}
virtual void OnCacheActionFinish() {
- EXPECT_TRUE(action_in_progress_);
- action_in_progress_ = false;
+ EXPECT_TRUE(cache_action_in_progress_);
+ cache_action_in_progress_ = false;
}
+ virtual void OnNetworkActionStart() {
+ EXPECT_FALSE(cache_action_in_progress_);
+ EXPECT_FALSE(network_action_in_progress_);
+ EXPECT_GT(num_remaining_network_actions_to_observe_, 0);
+ num_remaining_network_actions_to_observe_--;
+ network_action_in_progress_ = true;
+ }
+ virtual void OnNetworkActionFinish() {
+ EXPECT_TRUE(network_action_in_progress_);
+ network_action_in_progress_ = false;
+ }
private:
- int num_remaining_actions_to_observe_;
- bool action_in_progress_;
+ int num_remaining_cache_actions_to_observe_;
+ int num_remaining_network_actions_to_observe_;
+ bool cache_action_in_progress_;
+ bool network_action_in_progress_;
};
void ReadAndVerifyTransaction(net::HttpTransaction* trans,
@@ -104,14 +124,18 @@
const MockHttpRequest& request,
net::HttpResponseInfo* response_info,
const net::BoundNetLog& net_log,
- int num_delegate_actions) {
+ int num_cache_delegate_actions,
+ int num_network_delegate_actions) {
net::TestCompletionCallback callback;
// write to the cache
scoped_ptr<TestHttpTransactionDelegate> delegate;
- if (num_delegate_actions != kNoDelegateTransactionCheck) {
- delegate.reset(new TestHttpTransactionDelegate(num_delegate_actions));
+ if (num_cache_delegate_actions != kNoDelegateTransactionCheck &&
+ num_network_delegate_actions != kNoDelegateTransactionCheck) {
+ delegate.reset(
+ new TestHttpTransactionDelegate(num_cache_delegate_actions,
+ num_network_delegate_actions));
}
scoped_ptr<net::HttpTransaction> trans;
int rv = cache->CreateTransaction(&trans, delegate.get());
@@ -138,7 +162,7 @@
net::HttpResponseInfo* response_info) {
RunTransactionTestWithRequestAndLogAndDelegate(
cache, trans_info, request, response_info, net::BoundNetLog(),
- kNoDelegateTransactionCheck);
+ kNoDelegateTransactionCheck, kNoDelegateTransactionCheck);
}
void RunTransactionTestWithLog(net::HttpCache* cache,
@@ -146,15 +170,16 @@
const net::BoundNetLog& log) {
RunTransactionTestWithRequestAndLogAndDelegate(
cache, trans_info, MockHttpRequest(trans_info), NULL, log,
- kNoDelegateTransactionCheck);
+ kNoDelegateTransactionCheck, kNoDelegateTransactionCheck);
}
void RunTransactionTestWithDelegate(net::HttpCache* cache,
const MockTransaction& trans_info,
- int num_delegate_actions) {
+ int num_cache_delegate_actions,
+ int num_network_delegate_actions) {
RunTransactionTestWithRequestAndLogAndDelegate(
cache, trans_info, MockHttpRequest(trans_info), NULL, net::BoundNetLog(),
- num_delegate_actions);
+ num_cache_delegate_actions, num_network_delegate_actions);
}
void RunTransactionTest(net::HttpCache* cache,
@@ -5023,7 +5048,8 @@
// Write to the cache.
RunTransactionTestWithDelegate(cache.http_cache(),
kSimpleGET_Transaction,
- 8);
+ 8,
+ 3);
// Force this transaction to read from the cache.
MockTransaction transaction(kSimpleGET_Transaction);
@@ -5031,5 +5057,6 @@
RunTransactionTestWithDelegate(cache.http_cache(),
kSimpleGET_Transaction,
- 5);
+ 5,
+ 0);
}

Powered by Google App Engine
This is Rietveld 408576698