summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
authormbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-02 04:31:31 +0000
committermbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-02 04:31:31 +0000
commitac790b4ed41d0bfdf3636c7744618af01bcaa4d5 (patch)
tree9bf2d8fed0e83ef1c615972303cb93217c721a43 /net/socket
parent7753c3f48f5d3fea1ac91575de75d78f8085be83 (diff)
downloadchromium_src-ac790b4ed41d0bfdf3636c7744618af01bcaa4d5.zip
chromium_src-ac790b4ed41d0bfdf3636c7744618af01bcaa4d5.tar.gz
chromium_src-ac790b4ed41d0bfdf3636c7744618af01bcaa4d5.tar.bz2
Update network priorities to support better granularity
of resource loading from WebKit into the network stack. In order to fully make these work, webkit changes are needed as well. BUG=none TEST=none Review URL: http://codereview.chromium.org/452033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33546 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/client_socket_handle.h5
-rw-r--r--net/socket/client_socket_pool.h3
-rw-r--r--net/socket/client_socket_pool_base.cc4
-rw-r--r--net/socket/client_socket_pool_base.h13
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc130
-rw-r--r--net/socket/socket_test_util.h2
-rw-r--r--net/socket/tcp_client_socket_pool.cc2
-rw-r--r--net/socket/tcp_client_socket_pool.h2
-rw-r--r--net/socket/tcp_client_socket_pool_unittest.cc82
9 files changed, 125 insertions, 118 deletions
diff --git a/net/socket/client_socket_handle.h b/net/socket/client_socket_handle.h
index 25a2f35..bf7bf8a 100644
--- a/net/socket/client_socket_handle.h
+++ b/net/socket/client_socket_handle.h
@@ -14,6 +14,7 @@
#include "net/base/completion_callback.h"
#include "net/base/load_states.h"
#include "net/base/net_errors.h"
+#include "net/base/request_priority.h"
#include "net/socket/client_socket.h"
#include "net/socket/client_socket_pool.h"
@@ -59,7 +60,7 @@ class ClientSocketHandle {
template <typename SocketParams, typename PoolType>
int Init(const std::string& group_name,
const SocketParams& socket_params,
- int priority,
+ RequestPriority priority,
CompletionCallback* callback,
PoolType* pool,
LoadLog* load_log);
@@ -146,7 +147,7 @@ class ClientSocketHandle {
template <typename SocketParams, typename PoolType>
int ClientSocketHandle::Init(const std::string& group_name,
const SocketParams& socket_params,
- int priority,
+ RequestPriority priority,
CompletionCallback* callback,
PoolType* pool,
LoadLog* load_log) {
diff --git a/net/socket/client_socket_pool.h b/net/socket/client_socket_pool.h
index 2c55e91..4bd1a58 100644
--- a/net/socket/client_socket_pool.h
+++ b/net/socket/client_socket_pool.h
@@ -13,6 +13,7 @@
#include "net/base/completion_callback.h"
#include "net/base/host_resolver.h"
#include "net/base/load_states.h"
+#include "net/base/request_priority.h"
namespace net {
@@ -49,7 +50,7 @@ class ClientSocketPool : public base::RefCounted<ClientSocketPool> {
// Profiling information for the request is saved to |load_log| if non-NULL.
virtual int RequestSocket(const std::string& group_name,
const void* params,
- int priority,
+ RequestPriority priority,
ClientSocketHandle* handle,
CompletionCallback* callback,
LoadLog* load_log) = 0;
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index 9413005..9701937 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -136,7 +136,7 @@ void ClientSocketPoolBaseHelper::InsertRequestIntoQueue(
LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE);
RequestQueue::iterator it = pending_requests->begin();
- while (it != pending_requests->end() && r->priority() <= (*it)->priority())
+ while (it != pending_requests->end() && r->priority() >= (*it)->priority())
++it;
pending_requests->insert(it, r);
}
@@ -437,7 +437,7 @@ int ClientSocketPoolBaseHelper::FindTopStalledGroup(Group** group,
if (has_slot)
stalled_group_count++;
bool has_higher_priority = !top_group ||
- group.TopPendingPriority() > top_group->TopPendingPriority();
+ group.TopPendingPriority() < top_group->TopPendingPriority();
if (has_slot && has_higher_priority) {
top_group = &group;
top_group_name = &i->first;
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index b9c28e9..cfad0a0 100644
--- a/net/socket/client_socket_pool_base.h
+++ b/net/socket/client_socket_pool_base.h
@@ -36,6 +36,7 @@
#include "net/base/load_log.h"
#include "net/base/load_states.h"
#include "net/base/net_errors.h"
+#include "net/base/request_priority.h"
#include "net/socket/client_socket.h"
#include "net/socket/client_socket_pool.h"
@@ -126,7 +127,7 @@ class ClientSocketPoolBaseHelper
public:
Request(ClientSocketHandle* handle,
CompletionCallback* callback,
- int priority,
+ RequestPriority priority,
LoadLog* load_log)
: handle_(handle), callback_(callback), priority_(priority),
load_log_(load_log) {}
@@ -135,13 +136,13 @@ class ClientSocketPoolBaseHelper
ClientSocketHandle* handle() const { return handle_; }
CompletionCallback* callback() const { return callback_; }
- int priority() const { return priority_; }
+ RequestPriority priority() const { return priority_; }
LoadLog* load_log() const { return load_log_.get(); }
private:
ClientSocketHandle* const handle_;
CompletionCallback* const callback_;
- const int priority_;
+ const RequestPriority priority_;
const scoped_refptr<LoadLog> load_log_;
DISALLOW_COPY_AND_ASSIGN(Request);
@@ -260,7 +261,7 @@ class ClientSocketPoolBaseHelper
max_sockets_per_group;
}
- int TopPendingPriority() const {
+ RequestPriority TopPendingPriority() const {
return pending_requests.front()->priority();
}
@@ -406,7 +407,7 @@ class ClientSocketPoolBase {
public:
Request(ClientSocketHandle* handle,
CompletionCallback* callback,
- int priority,
+ RequestPriority priority,
const SocketParams& params,
LoadLog* load_log)
: internal::ClientSocketPoolBaseHelper::Request(
@@ -459,7 +460,7 @@ class ClientSocketPoolBase {
// ownership is transferred in the asynchronous (ERR_IO_PENDING) case.
int RequestSocket(const std::string& group_name,
const SocketParams& params,
- int priority,
+ RequestPriority priority,
ClientSocketHandle* handle,
CompletionCallback* callback,
LoadLog* load_log) {
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 1aa25c2..1799e09 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -11,6 +11,7 @@
#include "net/base/load_log.h"
#include "net/base/load_log_unittest.h"
#include "net/base/net_errors.h"
+#include "net/base/request_priority.h"
#include "net/base/test_completion_callback.h"
#include "net/socket/client_socket.h"
#include "net/socket/client_socket_factory.h"
@@ -24,7 +25,7 @@ namespace {
const int kDefaultMaxSockets = 4;
const int kDefaultMaxSocketsPerGroup = 2;
-const int kDefaultPriority = 5;
+const net::RequestPriority kDefaultPriority = MEDIUM;
typedef ClientSocketPoolBase<const void*> TestClientSocketPoolBase;
@@ -283,7 +284,7 @@ class TestClientSocketPool : public ClientSocketPool {
virtual int RequestSocket(
const std::string& group_name,
const void* params,
- int priority,
+ net::RequestPriority priority,
ClientSocketHandle* handle,
CompletionCallback* callback,
LoadLog* load_log) {
@@ -407,7 +408,8 @@ class ClientSocketPoolBaseTest : public ClientSocketPoolTest {
connect_job_factory_);
}
- int StartRequest(const std::string& group_name, int priority) {
+ int StartRequest(const std::string& group_name,
+ net::RequestPriority priority) {
return StartRequestUsingPool<TestClientSocketPool, const void*>(
pool_.get(), group_name, priority, NULL);
}
@@ -441,7 +443,7 @@ class ClientSocketPoolBaseTest : public ClientSocketPoolTest {
// the compiler will infer (in this case, incorrectly) that NULL is of type int.
int InitHandle(ClientSocketHandle* handle,
const std::string& group_name,
- int priority,
+ net::RequestPriority priority,
CompletionCallback* callback,
TestClientSocketPool* pool,
LoadLog* load_log) {
@@ -522,7 +524,7 @@ TEST_F(ClientSocketPoolBaseTest, BasicAsynchronous) {
connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob);
scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
TestSocketRequest req(&request_order_, &completion_count_);
- int rv = InitHandle(req.handle(), "a", 0, &req, pool_.get(), log);
+ int rv = InitHandle(req.handle(), "a", LOW, &req, pool_.get(), log);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", req.handle()));
EXPECT_EQ(OK, req.WaitForResult());
@@ -652,17 +654,17 @@ TEST_F(ClientSocketPoolBaseTest, TotalLimitReachedNewGroup) {
TEST_F(ClientSocketPoolBaseTest, TotalLimitRespectsPriority) {
CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup);
- EXPECT_EQ(OK, StartRequest("b", 3));
- EXPECT_EQ(OK, StartRequest("a", 3));
- EXPECT_EQ(OK, StartRequest("b", 6));
- EXPECT_EQ(OK, StartRequest("a", 6));
+ EXPECT_EQ(OK, StartRequest("b", LOWEST));
+ EXPECT_EQ(OK, StartRequest("a", MEDIUM));
+ EXPECT_EQ(OK, StartRequest("b", HIGHEST));
+ EXPECT_EQ(OK, StartRequest("a", LOWEST));
EXPECT_EQ(static_cast<int>(requests_.size()),
client_socket_factory_.allocation_count());
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("c", 4));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 5));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("b", 7));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("c", LOWEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", MEDIUM));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("b", HIGHEST));
ReleaseAllConnections(KEEP_ALIVE);
@@ -677,8 +679,8 @@ TEST_F(ClientSocketPoolBaseTest, TotalLimitRespectsPriority) {
EXPECT_EQ(3, GetOrderOfRequest(3));
EXPECT_EQ(4, GetOrderOfRequest(4));
- // Request ("b", 7) has the highest priority, then ("a", 5),
- // and then ("c", 4).
+ // Request ("b", HIGHEST) has the highest priority, then ("a", MEDIUM),
+ // and then ("c", LOWEST).
EXPECT_EQ(7, GetOrderOfRequest(5));
EXPECT_EQ(6, GetOrderOfRequest(6));
EXPECT_EQ(5, GetOrderOfRequest(7));
@@ -690,17 +692,17 @@ TEST_F(ClientSocketPoolBaseTest, TotalLimitRespectsPriority) {
TEST_F(ClientSocketPoolBaseTest, TotalLimitRespectsGroupLimit) {
CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup);
- EXPECT_EQ(OK, StartRequest("a", 3));
- EXPECT_EQ(OK, StartRequest("a", 6));
- EXPECT_EQ(OK, StartRequest("b", 3));
- EXPECT_EQ(OK, StartRequest("b", 6));
+ EXPECT_EQ(OK, StartRequest("a", LOWEST));
+ EXPECT_EQ(OK, StartRequest("a", LOW));
+ EXPECT_EQ(OK, StartRequest("b", HIGHEST));
+ EXPECT_EQ(OK, StartRequest("b", MEDIUM));
EXPECT_EQ(static_cast<int>(requests_.size()),
client_socket_factory_.allocation_count());
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("c", 6));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 4));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("b", 7));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("c", MEDIUM));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOW));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("b", HIGHEST));
ReleaseAllConnections(KEEP_ALIVE);
@@ -822,11 +824,11 @@ TEST_F(ClientSocketPoolBaseTest, PendingRequests) {
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 3));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 4));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 2));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", MEDIUM));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", HIGHEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOW));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
ReleaseAllConnections(KEEP_ALIVE);
@@ -851,11 +853,11 @@ TEST_F(ClientSocketPoolBaseTest, PendingRequests_NoKeepAlive) {
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 3));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 4));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 2));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", MEDIUM));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", HIGHEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOW));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
ReleaseAllConnections(NO_KEEP_ALIVE);
@@ -931,11 +933,11 @@ TEST_F(ClientSocketPoolBaseTest, CancelRequest) {
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 3));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 4));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 2));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", MEDIUM));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", HIGHEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOW));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
// Cancel a request.
size_t index_to_cancel = kDefaultMaxSocketsPerGroup + 2;
@@ -1218,7 +1220,7 @@ TEST_F(ClientSocketPoolBaseTest, GroupWithPendingRequestsIsNotEmpty) {
const int kMaxSocketsPerGroup = 2;
CreatePool(kMaxSockets, kMaxSocketsPerGroup);
- const int kHighPriority = kDefaultPriority + 100;
+ const RequestPriority kHighPriority = HIGHEST;
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
@@ -1261,7 +1263,8 @@ TEST_F(ClientSocketPoolBaseTest_LateBinding,
ConnectJob_NoTimeoutOnSynchronousCompletion) {
TestConnectJobDelegate delegate;
ClientSocketHandle ignored;
- TestClientSocketPoolBase::Request request(&ignored, NULL, 0, NULL, NULL);
+ TestClientSocketPoolBase::Request request(&ignored, NULL, LOWEST, NULL,
+ NULL);
scoped_ptr<TestConnectJob> job(
new TestConnectJob(TestConnectJob::kMockJob,
"a",
@@ -1276,7 +1279,8 @@ TEST_F(ClientSocketPoolBaseTest_LateBinding,
TEST_F(ClientSocketPoolBaseTest_LateBinding, ConnectJob_TimedOut) {
TestConnectJobDelegate delegate;
ClientSocketHandle ignored;
- TestClientSocketPoolBase::Request request(&ignored, NULL, 0, NULL, NULL);
+ TestClientSocketPoolBase::Request request(&ignored, NULL, LOWEST, NULL,
+ NULL);
// Deleted by TestConnectJobDelegate.
TestConnectJob* job =
new TestConnectJob(TestConnectJob::kMockPendingJob,
@@ -1318,7 +1322,7 @@ TEST_F(ClientSocketPoolBaseTest_LateBinding, BasicAsynchronous) {
connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob);
TestSocketRequest req(&request_order_, &completion_count_);
scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- int rv = InitHandle(req.handle(), "a", 0, &req, pool_.get(), log);
+ int rv = InitHandle(req.handle(), "a", LOWEST, &req, pool_.get(), log);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", req.handle()));
EXPECT_EQ(OK, req.WaitForResult());
@@ -1389,11 +1393,11 @@ TEST_F(ClientSocketPoolBaseTest_LateBinding, PendingRequests) {
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 3));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 4));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 2));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", MEDIUM));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", HIGHEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOW));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
ReleaseAllConnections(KEEP_ALIVE);
@@ -1418,11 +1422,11 @@ TEST_F(ClientSocketPoolBaseTest_LateBinding, PendingRequests_NoKeepAlive) {
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 3));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 4));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 2));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", MEDIUM));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", HIGHEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOW));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
ReleaseAllConnections(NO_KEEP_ALIVE);
@@ -1529,11 +1533,11 @@ TEST_F(ClientSocketPoolBaseTest_LateBinding, CancelRequest) {
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 3));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 4));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 2));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", MEDIUM));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", HIGHEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOW));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
// Cancel a request.
size_t index_to_cancel = kDefaultMaxSocketsPerGroup + 2;
@@ -1564,10 +1568,10 @@ TEST_F(ClientSocketPoolBaseTest_LateBinding, CancelRequestLimitsJobs) {
connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob);
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 2));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 3));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 4));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOW));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", MEDIUM));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", HIGHEST));
EXPECT_EQ(kDefaultMaxSocketsPerGroup, pool_->NumConnectJobsInGroup("a"));
requests_[2]->handle()->Reset();
@@ -1798,7 +1802,7 @@ TEST_F(ClientSocketPoolBaseTest_LateBinding,
const int kMaxSocketsPerGroup = 2;
CreatePool(kMaxSockets, kMaxSocketsPerGroup);
- const int kHighPriority = kDefaultPriority + 100;
+ const RequestPriority kHighPriority = HIGHEST;
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
@@ -1838,12 +1842,12 @@ TEST_F(ClientSocketPoolBaseTest_LateBinding, CleanupTimedOutIdleSockets) {
// Startup two mock pending connect jobs, which will sit in the MessageLoop.
TestSocketRequest req(&request_order_, &completion_count_);
- int rv = InitHandle(req.handle(), "a", 0, &req, pool_.get(), NULL);
+ int rv = InitHandle(req.handle(), "a", LOWEST, &req, pool_.get(), NULL);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", req.handle()));
TestSocketRequest req2(&request_order_, &completion_count_);
- rv = InitHandle(req2.handle(), "a", 0, &req2, pool_.get(), NULL);
+ rv = InitHandle(req2.handle(), "a", LOWEST, &req2, pool_.get(), NULL);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", req2.handle()));
@@ -1869,7 +1873,7 @@ TEST_F(ClientSocketPoolBaseTest_LateBinding, CleanupTimedOutIdleSockets) {
// used socket. Request it to make sure that it's used.
pool_->CleanupTimedOutIdleSockets();
- rv = InitHandle(req.handle(), "a", 0, &req, pool_.get(), NULL);
+ rv = InitHandle(req.handle(), "a", LOWEST, &req, pool_.get(), NULL);
EXPECT_EQ(OK, rv);
EXPECT_TRUE(req.handle()->is_reused());
}
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h
index 2813fe4..5f17f71 100644
--- a/net/socket/socket_test_util.h
+++ b/net/socket/socket_test_util.h
@@ -414,7 +414,7 @@ class ClientSocketPoolTest : public testing::Test {
template <typename PoolType, typename SocketParams>
int StartRequestUsingPool(PoolType* socket_pool,
const std::string& group_name,
- int priority,
+ RequestPriority priority,
const SocketParams& socket_params) {
DCHECK(socket_pool);
TestSocketRequest* request = new TestSocketRequest(&request_order_,
diff --git a/net/socket/tcp_client_socket_pool.cc b/net/socket/tcp_client_socket_pool.cc
index 37d2d8c..84899da 100644
--- a/net/socket/tcp_client_socket_pool.cc
+++ b/net/socket/tcp_client_socket_pool.cc
@@ -172,7 +172,7 @@ TCPClientSocketPool::~TCPClientSocketPool() {}
int TCPClientSocketPool::RequestSocket(
const std::string& group_name,
const void* resolve_info,
- int priority,
+ RequestPriority priority,
ClientSocketHandle* handle,
CompletionCallback* callback,
LoadLog* load_log) {
diff --git a/net/socket/tcp_client_socket_pool.h b/net/socket/tcp_client_socket_pool.h
index 8a3d1f7..49c0aa7 100644
--- a/net/socket/tcp_client_socket_pool.h
+++ b/net/socket/tcp_client_socket_pool.h
@@ -85,7 +85,7 @@ class TCPClientSocketPool : public ClientSocketPool {
virtual int RequestSocket(const std::string& group_name,
const void* resolve_info,
- int priority,
+ RequestPriority priority,
ClientSocketHandle* handle,
CompletionCallback* callback,
LoadLog* load_log);
diff --git a/net/socket/tcp_client_socket_pool_unittest.cc b/net/socket/tcp_client_socket_pool_unittest.cc
index e73b7d3..b3560be 100644
--- a/net/socket/tcp_client_socket_pool_unittest.cc
+++ b/net/socket/tcp_client_socket_pool_unittest.cc
@@ -21,7 +21,7 @@ namespace {
const int kMaxSockets = 32;
const int kMaxSocketsPerGroup = 6;
-const int kDefaultPriority = 5;
+const net::RequestPriority kDefaultPriority = LOW;
class MockClientSocket : public ClientSocket {
public:
@@ -203,7 +203,7 @@ class TCPClientSocketPoolTest : public ClientSocketPoolTest {
&client_socket_factory_)) {
}
- int StartRequest(const std::string& group_name, int priority) {
+ int StartRequest(const std::string& group_name, RequestPriority priority) {
return StartRequestUsingPool(
pool_.get(), group_name, priority, ignored_request_info_);
}
@@ -218,7 +218,7 @@ TEST_F(TCPClientSocketPoolTest, Basic) {
TestCompletionCallback callback;
ClientSocketHandle handle;
HostResolver::RequestInfo info("www.google.com", 80);
- int rv = handle.Init("a", info, 0, &callback, pool_.get(), NULL);
+ int rv = handle.Init("a", info, LOW, &callback, pool_.get(), NULL);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
EXPECT_FALSE(handle.socket());
@@ -273,16 +273,16 @@ TEST_F(TCPClientSocketPoolTest, PendingRequests) {
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
// The rest are pending since we've used all active sockets.
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 7));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 9));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 5));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 6));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 2));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 8));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 3));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 4));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", HIGHEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", MEDIUM));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOW));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", HIGHEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", MEDIUM));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", MEDIUM));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", HIGHEST));
ReleaseAllConnections(KEEP_ALIVE);
@@ -299,17 +299,17 @@ TEST_F(TCPClientSocketPoolTest, PendingRequests) {
EXPECT_EQ(5, GetOrderOfRequest(5));
EXPECT_EQ(6, GetOrderOfRequest(6));
- // Make sure that rest o the requests complete in the order of priority.
- EXPECT_EQ(15, GetOrderOfRequest(7));
- EXPECT_EQ(9, GetOrderOfRequest(8));
- EXPECT_EQ(7, GetOrderOfRequest(9));
- EXPECT_EQ(11, GetOrderOfRequest(10));
- EXPECT_EQ(10, GetOrderOfRequest(11));
- EXPECT_EQ(14, GetOrderOfRequest(12));
- EXPECT_EQ(8, GetOrderOfRequest(13));
- EXPECT_EQ(13, GetOrderOfRequest(14));
+ // Make sure that rest of the requests complete in the order of priority.
+ EXPECT_EQ(7, GetOrderOfRequest(7));
+ EXPECT_EQ(14, GetOrderOfRequest(8));
+ EXPECT_EQ(15, GetOrderOfRequest(9));
+ EXPECT_EQ(10, GetOrderOfRequest(10));
+ EXPECT_EQ(13, GetOrderOfRequest(11));
+ EXPECT_EQ(8, GetOrderOfRequest(12));
+ EXPECT_EQ(16, GetOrderOfRequest(13));
+ EXPECT_EQ(11, GetOrderOfRequest(14));
EXPECT_EQ(12, GetOrderOfRequest(15));
- EXPECT_EQ(16, GetOrderOfRequest(16));
+ EXPECT_EQ(9, GetOrderOfRequest(16));
// Make sure we test order of all requests made.
EXPECT_EQ(kIndexOutOfBounds, GetOrderOfRequest(17));
@@ -441,16 +441,16 @@ TEST_F(TCPClientSocketPoolTest, CancelRequest) {
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
// Reached per-group limit, queue up requests.
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 7));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 9));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 5));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 6));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 2));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 8));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 3));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 4));
- EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", 1));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", HIGHEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", HIGHEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", MEDIUM));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", MEDIUM));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOW));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", HIGHEST));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOW));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOW));
+ EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST));
// Cancel a request.
size_t index_to_cancel = kMaxSocketsPerGroup + 2;
@@ -470,14 +470,14 @@ TEST_F(TCPClientSocketPoolTest, CancelRequest) {
EXPECT_EQ(5, GetOrderOfRequest(5));
EXPECT_EQ(6, GetOrderOfRequest(6));
EXPECT_EQ(14, GetOrderOfRequest(7));
- EXPECT_EQ(8, GetOrderOfRequest(8));
+ EXPECT_EQ(7, GetOrderOfRequest(8));
EXPECT_EQ(kRequestNotFound, GetOrderOfRequest(9)); // Canceled request.
- EXPECT_EQ(10, GetOrderOfRequest(10));
- EXPECT_EQ(9, GetOrderOfRequest(11));
- EXPECT_EQ(13, GetOrderOfRequest(12));
- EXPECT_EQ(7, GetOrderOfRequest(13));
+ EXPECT_EQ(9, GetOrderOfRequest(10));
+ EXPECT_EQ(10, GetOrderOfRequest(11));
+ EXPECT_EQ(11, GetOrderOfRequest(12));
+ EXPECT_EQ(8, GetOrderOfRequest(13));
EXPECT_EQ(12, GetOrderOfRequest(14));
- EXPECT_EQ(11, GetOrderOfRequest(15));
+ EXPECT_EQ(13, GetOrderOfRequest(15));
EXPECT_EQ(15, GetOrderOfRequest(16));
// Make sure we test order of all requests made.
@@ -499,7 +499,7 @@ class RequestSocketCallback : public CallbackRunner< Tuple1<int> > {
handle_->Reset();
within_callback_ = true;
int rv = handle_->Init(
- "a", HostResolver::RequestInfo("www.google.com", 80), 0,
+ "a", HostResolver::RequestInfo("www.google.com", 80), LOWEST,
this, pool_.get(), NULL);
EXPECT_EQ(OK, rv);
}
@@ -520,7 +520,7 @@ TEST_F(TCPClientSocketPoolTest, RequestTwice) {
ClientSocketHandle handle;
RequestSocketCallback callback(&handle, pool_.get());
int rv = handle.Init(
- "a", HostResolver::RequestInfo("www.google.com", 80), 0,
+ "a", HostResolver::RequestInfo("www.google.com", 80), LOWEST,
&callback, pool_.get(), NULL);
ASSERT_EQ(ERR_IO_PENDING, rv);