summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/socket_stream/socket_stream_unittest.cc110
-rw-r--r--net/url_request/url_request_job_unittest.cc12
-rw-r--r--net/url_request/url_request_test_util.cc159
-rw-r--r--net/url_request/url_request_test_util.h129
4 files changed, 202 insertions, 208 deletions
diff --git a/net/socket_stream/socket_stream_unittest.cc b/net/socket_stream/socket_stream_unittest.cc
index 8007767..594b3a6 100644
--- a/net/socket_stream/socket_stream_unittest.cc
+++ b/net/socket_stream/socket_stream_unittest.cc
@@ -23,8 +23,6 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
-namespace net {
-
namespace {
struct SocketStreamEvent {
@@ -34,25 +32,25 @@ struct SocketStreamEvent {
};
SocketStreamEvent(EventType type,
- SocketStream* socket_stream,
+ net::SocketStream* socket_stream,
int num,
const std::string& str,
- AuthChallengeInfo* auth_challenge_info,
+ net::AuthChallengeInfo* auth_challenge_info,
int error)
: event_type(type), socket(socket_stream), number(num), data(str),
auth_info(auth_challenge_info), error_code(error) {}
EventType event_type;
- SocketStream* socket;
+ net::SocketStream* socket;
int number;
std::string data;
- scoped_refptr<AuthChallengeInfo> auth_info;
+ scoped_refptr<net::AuthChallengeInfo> auth_info;
int error_code;
};
-class SocketStreamEventRecorder : public SocketStream::Delegate {
+class SocketStreamEventRecorder : public net::SocketStream::Delegate {
public:
- explicit SocketStreamEventRecorder(const CompletionCallback& callback)
+ explicit SocketStreamEventRecorder(const net::CompletionCallback& callback)
: callback_(callback) {}
virtual ~SocketStreamEventRecorder() {}
@@ -84,59 +82,59 @@ class SocketStreamEventRecorder : public SocketStream::Delegate {
}
virtual int OnStartOpenConnection(
- SocketStream* socket,
- const CompletionCallback& callback) OVERRIDE {
+ net::SocketStream* socket,
+ const net::CompletionCallback& callback) OVERRIDE {
connection_callback_ = callback;
events_.push_back(
SocketStreamEvent(SocketStreamEvent::EVENT_START_OPEN_CONNECTION,
- socket, 0, std::string(), NULL, OK));
+ socket, 0, std::string(), NULL, net::OK));
if (!on_start_open_connection_.is_null())
return on_start_open_connection_.Run(&events_.back());
- return OK;
+ return net::OK;
}
- virtual void OnConnected(SocketStream* socket,
+ virtual void OnConnected(net::SocketStream* socket,
int num_pending_send_allowed) OVERRIDE {
events_.push_back(
SocketStreamEvent(SocketStreamEvent::EVENT_CONNECTED,
socket, num_pending_send_allowed, std::string(),
- NULL, OK));
+ NULL, net::OK));
if (!on_connected_.is_null())
on_connected_.Run(&events_.back());
}
- virtual void OnSentData(SocketStream* socket,
+ virtual void OnSentData(net::SocketStream* socket,
int amount_sent) OVERRIDE {
events_.push_back(
SocketStreamEvent(SocketStreamEvent::EVENT_SENT_DATA, socket,
- amount_sent, std::string(), NULL, OK));
+ amount_sent, std::string(), NULL, net::OK));
if (!on_sent_data_.is_null())
on_sent_data_.Run(&events_.back());
}
- virtual void OnReceivedData(SocketStream* socket,
+ virtual void OnReceivedData(net::SocketStream* socket,
const char* data, int len) OVERRIDE {
events_.push_back(
SocketStreamEvent(SocketStreamEvent::EVENT_RECEIVED_DATA, socket, len,
- std::string(data, len), NULL, OK));
+ std::string(data, len), NULL, net::OK));
if (!on_received_data_.is_null())
on_received_data_.Run(&events_.back());
}
- virtual void OnClose(SocketStream* socket) OVERRIDE {
+ virtual void OnClose(net::SocketStream* socket) OVERRIDE {
events_.push_back(
SocketStreamEvent(SocketStreamEvent::EVENT_CLOSE, socket, 0,
- std::string(), NULL, OK));
+ std::string(), NULL, net::OK));
if (!on_close_.is_null())
on_close_.Run(&events_.back());
if (!callback_.is_null())
- callback_.Run(OK);
+ callback_.Run(net::OK);
}
- virtual void OnAuthRequired(SocketStream* socket,
- AuthChallengeInfo* auth_info) OVERRIDE {
+ virtual void OnAuthRequired(net::SocketStream* socket,
+ net::AuthChallengeInfo* auth_info) OVERRIDE {
events_.push_back(
SocketStreamEvent(SocketStreamEvent::EVENT_AUTH_REQUIRED, socket, 0,
- std::string(), auth_info, OK));
+ std::string(), auth_info, net::OK));
if (!on_auth_required_.is_null())
on_auth_required_.Run(&events_.back());
}
- virtual void OnError(const SocketStream* socket, int error) OVERRIDE {
+ virtual void OnError(const net::SocketStream* socket, int error) OVERRIDE {
events_.push_back(
SocketStreamEvent(SocketStreamEvent::EVENT_ERROR, NULL, 0,
std::string(), NULL, error));
@@ -154,7 +152,7 @@ class SocketStreamEventRecorder : public SocketStream::Delegate {
<< " password=" << credentials_.password();
event->socket->RestartWithAuth(credentials_);
}
- void SetAuthInfo(const AuthCredentials& credentials) {
+ void SetAuthInfo(const net::AuthCredentials& credentials) {
credentials_ = credentials;
}
void CompleteConnection(int result) {
@@ -174,9 +172,9 @@ class SocketStreamEventRecorder : public SocketStream::Delegate {
base::Callback<void(SocketStreamEvent*)> on_close_;
base::Callback<void(SocketStreamEvent*)> on_auth_required_;
base::Callback<void(SocketStreamEvent*)> on_error_;
- const CompletionCallback callback_;
- CompletionCallback connection_callback_;
- AuthCredentials credentials_;
+ const net::CompletionCallback callback_;
+ net::CompletionCallback connection_callback_;
+ net::AuthCredentials credentials_;
DISALLOW_COPY_AND_ASSIGN(SocketStreamEventRecorder);
};
@@ -185,7 +183,7 @@ class TestURLRequestContextWithProxy : public TestURLRequestContext {
public:
explicit TestURLRequestContextWithProxy(const std::string& proxy)
: TestURLRequestContext(true) {
- context_storage_.set_proxy_service(ProxyService::CreateFixed(proxy));
+ context_storage_.set_proxy_service(net::ProxyService::CreateFixed(proxy));
Init();
}
virtual ~TestURLRequestContextWithProxy() {}
@@ -194,12 +192,12 @@ class TestURLRequestContextWithProxy : public TestURLRequestContext {
class TestSocketStreamNetworkDelegate : public TestNetworkDelegate {
public:
TestSocketStreamNetworkDelegate()
- : before_connect_result_(OK) {}
+ : before_connect_result_(net::OK) {}
virtual ~TestSocketStreamNetworkDelegate() {}
virtual int OnBeforeSocketStreamConnect(
- SocketStream* stream,
- const CompletionCallback& callback) OVERRIDE {
+ net::SocketStream* stream,
+ const net::CompletionCallback& callback) OVERRIDE {
return before_connect_result_;
}
@@ -213,6 +211,8 @@ class TestSocketStreamNetworkDelegate : public TestNetworkDelegate {
} // namespace
+namespace net {
+
class SocketStreamTest : public PlatformTest {
public:
virtual ~SocketStreamTest() {}
@@ -259,12 +259,12 @@ class SocketStreamTest : public PlatformTest {
}
virtual int DoSwitchToSpdyTest(SocketStreamEvent* event) {
- return ERR_PROTOCOL_SWITCHED;
+ return net::ERR_PROTOCOL_SWITCHED;
}
virtual int DoIOPending(SocketStreamEvent* event) {
- io_test_callback_.callback().Run(OK);
- return ERR_IO_PENDING;
+ io_test_callback_.callback().Run(net::OK);
+ return net::ERR_IO_PENDING;
}
static const char kWebSocketHandshakeRequest[];
@@ -359,7 +359,7 @@ TEST_F(SocketStreamTest, CloseFlushPendingWrite) {
EXPECT_EQ(SocketStreamEvent::EVENT_SENT_DATA, events[4].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_SENT_DATA, events[5].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[6].event_type);
- EXPECT_EQ(ERR_CONNECTION_CLOSED, events[6].error_code);
+ EXPECT_EQ(net::ERR_CONNECTION_CLOSED, events[6].error_code);
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[7].event_type);
}
@@ -404,8 +404,8 @@ TEST_F(SocketStreamTest, BasicAuthProxy) {
new SocketStreamEventRecorder(test_callback.callback()));
delegate->SetOnConnected(base::Bind(&SocketStreamEventRecorder::DoClose,
base::Unretained(delegate.get())));
- delegate->SetAuthInfo(AuthCredentials(ASCIIToUTF16("foo"),
- ASCIIToUTF16("bar")));
+ delegate->SetAuthInfo(net::AuthCredentials(ASCIIToUTF16("foo"),
+ ASCIIToUTF16("bar")));
delegate->SetOnAuthRequired(base::Bind(
&SocketStreamEventRecorder::DoRestartWithAuth,
base::Unretained(delegate.get())));
@@ -430,7 +430,7 @@ TEST_F(SocketStreamTest, BasicAuthProxy) {
EXPECT_EQ(SocketStreamEvent::EVENT_AUTH_REQUIRED, events[1].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_CONNECTED, events[2].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[3].event_type);
- EXPECT_EQ(ERR_ABORTED, events[3].error_code);
+ EXPECT_EQ(net::ERR_ABORTED, events[3].error_code);
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[4].event_type);
// TODO(eroman): Add back NetLogTest here...
@@ -488,7 +488,7 @@ TEST_F(SocketStreamTest, BasicAuthProxyWithAuthCache) {
EXPECT_EQ(SocketStreamEvent::EVENT_START_OPEN_CONNECTION,
events[0].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_CONNECTED, events[1].event_type);
- EXPECT_EQ(ERR_ABORTED, events[2].error_code);
+ EXPECT_EQ(net::ERR_ABORTED, events[2].error_code);
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[3].event_type);
}
@@ -545,7 +545,7 @@ TEST_F(SocketStreamTest, WSSBasicAuthProxyWithAuthCache) {
EXPECT_EQ(SocketStreamEvent::EVENT_START_OPEN_CONNECTION,
events[0].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_CONNECTED, events[1].event_type);
- EXPECT_EQ(ERR_ABORTED, events[2].error_code);
+ EXPECT_EQ(net::ERR_ABORTED, events[2].error_code);
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[3].event_type);
}
@@ -594,11 +594,11 @@ TEST_F(SocketStreamTest, IOPending) {
socket_stream->Connect();
io_test_callback_.WaitForResult();
- EXPECT_EQ(SocketStream::STATE_RESOLVE_PROTOCOL_COMPLETE,
+ EXPECT_EQ(net::SocketStream::STATE_RESOLVE_PROTOCOL_COMPLETE,
socket_stream->next_state_);
- delegate->CompleteConnection(OK);
+ delegate->CompleteConnection(net::OK);
- EXPECT_EQ(OK, test_callback.WaitForResult());
+ EXPECT_EQ(net::OK, test_callback.WaitForResult());
const std::vector<SocketStreamEvent>& events = delegate->GetSeenEvents();
ASSERT_EQ(8U, events.size());
@@ -611,7 +611,7 @@ TEST_F(SocketStreamTest, IOPending) {
EXPECT_EQ(SocketStreamEvent::EVENT_SENT_DATA, events[4].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_SENT_DATA, events[5].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[6].event_type);
- EXPECT_EQ(ERR_CONNECTION_CLOSED, events[6].error_code);
+ EXPECT_EQ(net::ERR_CONNECTION_CLOSED, events[6].error_code);
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[7].event_type);
}
@@ -632,7 +632,7 @@ TEST_F(SocketStreamTest, SwitchToSpdy) {
socket_stream->Connect();
- EXPECT_EQ(ERR_PROTOCOL_SWITCHED, test_callback.WaitForResult());
+ EXPECT_EQ(net::ERR_PROTOCOL_SWITCHED, test_callback.WaitForResult());
const std::vector<SocketStreamEvent>& events = delegate->GetSeenEvents();
ASSERT_EQ(2U, events.size());
@@ -640,7 +640,7 @@ TEST_F(SocketStreamTest, SwitchToSpdy) {
EXPECT_EQ(SocketStreamEvent::EVENT_START_OPEN_CONNECTION,
events[0].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[1].event_type);
- EXPECT_EQ(ERR_PROTOCOL_SWITCHED, events[1].error_code);
+ EXPECT_EQ(net::ERR_PROTOCOL_SWITCHED, events[1].error_code);
}
TEST_F(SocketStreamTest, SwitchAfterPending) {
@@ -660,11 +660,11 @@ TEST_F(SocketStreamTest, SwitchAfterPending) {
socket_stream->Connect();
io_test_callback_.WaitForResult();
- EXPECT_EQ(SocketStream::STATE_RESOLVE_PROTOCOL_COMPLETE,
+ EXPECT_EQ(net::SocketStream::STATE_RESOLVE_PROTOCOL_COMPLETE,
socket_stream->next_state_);
- delegate->CompleteConnection(ERR_PROTOCOL_SWITCHED);
+ delegate->CompleteConnection(net::ERR_PROTOCOL_SWITCHED);
- EXPECT_EQ(ERR_PROTOCOL_SWITCHED, test_callback.WaitForResult());
+ EXPECT_EQ(net::ERR_PROTOCOL_SWITCHED, test_callback.WaitForResult());
const std::vector<SocketStreamEvent>& events = delegate->GetSeenEvents();
ASSERT_EQ(2U, events.size());
@@ -672,7 +672,7 @@ TEST_F(SocketStreamTest, SwitchAfterPending) {
EXPECT_EQ(SocketStreamEvent::EVENT_START_OPEN_CONNECTION,
events[0].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[1].event_type);
- EXPECT_EQ(ERR_PROTOCOL_SWITCHED, events[1].error_code);
+ EXPECT_EQ(net::ERR_PROTOCOL_SWITCHED, events[1].error_code);
}
// Test a connection though a secure proxy.
@@ -722,7 +722,7 @@ TEST_F(SocketStreamTest, SecureProxyConnectError) {
EXPECT_EQ(SocketStreamEvent::EVENT_START_OPEN_CONNECTION,
events[0].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[1].event_type);
- EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, events[1].error_code);
+ EXPECT_EQ(net::ERR_SSL_PROTOCOL_ERROR, events[1].error_code);
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[2].event_type);
}
@@ -774,7 +774,7 @@ TEST_F(SocketStreamTest, SecureProxyConnect) {
events[0].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_CONNECTED, events[1].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[2].event_type);
- EXPECT_EQ(ERR_ABORTED, events[2].error_code);
+ EXPECT_EQ(net::ERR_ABORTED, events[2].error_code);
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[3].event_type);
}
@@ -802,7 +802,7 @@ TEST_F(SocketStreamTest, BeforeConnectFailed) {
ASSERT_EQ(2U, events.size());
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[0].event_type);
- EXPECT_EQ(ERR_ACCESS_DENIED, events[0].error_code);
+ EXPECT_EQ(net::ERR_ACCESS_DENIED, events[0].error_code);
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[1].event_type);
}
diff --git a/net/url_request/url_request_job_unittest.cc b/net/url_request/url_request_job_unittest.cc
index 19c2395..b815a0c 100644
--- a/net/url_request/url_request_job_unittest.cc
+++ b/net/url_request/url_request_job_unittest.cc
@@ -40,11 +40,11 @@ const MockTransaction kGZip_Transaction = {
TEST(URLRequestJob, TransactionNotifiedWhenDone) {
MockNetworkLayer network_layer;
- net::TestURLRequestContext context;
+ TestURLRequestContext context;
context.set_http_transaction_factory(&network_layer);
- net::TestDelegate d;
- net::TestURLRequest req(GURL(kGZip_Transaction.url), &d, &context);
+ TestDelegate d;
+ TestURLRequest req(GURL(kGZip_Transaction.url), &d, &context);
AddMockTransaction(&kGZip_Transaction);
req.set_method("GET");
@@ -59,11 +59,11 @@ TEST(URLRequestJob, TransactionNotifiedWhenDone) {
TEST(URLRequestJob, SyncTransactionNotifiedWhenDone) {
MockNetworkLayer network_layer;
- net::TestURLRequestContext context;
+ TestURLRequestContext context;
context.set_http_transaction_factory(&network_layer);
- net::TestDelegate d;
- net::TestURLRequest req(GURL(kGZip_Transaction.url), &d, &context);
+ TestDelegate d;
+ TestURLRequest req(GURL(kGZip_Transaction.url), &d, &context);
MockTransaction transaction(kGZip_Transaction);
transaction.test_mode = TEST_MODE_SYNC_ALL;
AddMockTransaction(&transaction);
diff --git a/net/url_request/url_request_test_util.cc b/net/url_request/url_request_test_util.cc
index 9648b78..34335ae 100644
--- a/net/url_request/url_request_test_util.cc
+++ b/net/url_request/url_request_test_util.cc
@@ -20,11 +20,9 @@
#include "net/url_request/url_request_job_factory_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace net {
-
namespace {
-// These constants put the NetworkDelegate events of TestNetworkDelegate
+// These constants put the net::NetworkDelegate events of TestNetworkDelegate
// into an order. They are used in conjunction with
// |TestNetworkDelegate::next_states_| to check that we do not send
// events in the wrong order.
@@ -65,34 +63,34 @@ void TestURLRequestContext::Init() {
if (!host_resolver())
context_storage_.set_host_resolver(
- scoped_ptr<HostResolver>(new MockCachingHostResolver()));
+ scoped_ptr<net::HostResolver>(new net::MockCachingHostResolver()));
if (!proxy_service())
- context_storage_.set_proxy_service(ProxyService::CreateDirect());
+ context_storage_.set_proxy_service(net::ProxyService::CreateDirect());
if (!cert_verifier())
- context_storage_.set_cert_verifier(CertVerifier::CreateDefault());
+ context_storage_.set_cert_verifier(net::CertVerifier::CreateDefault());
if (!ftp_transaction_factory()) {
#if !defined(DISABLE_FTP_SUPPORT)
context_storage_.set_ftp_transaction_factory(
- new FtpNetworkLayer(host_resolver()));
+ new net::FtpNetworkLayer(host_resolver()));
#else
context_storage_.set_ftp_transaction_factory(NULL);
#endif // !defined(DISABLE_FTP_SUPPORT)
}
if (!ssl_config_service())
- context_storage_.set_ssl_config_service(new SSLConfigServiceDefaults);
+ context_storage_.set_ssl_config_service(new net::SSLConfigServiceDefaults);
if (!http_auth_handler_factory()) {
context_storage_.set_http_auth_handler_factory(
- HttpAuthHandlerFactory::CreateDefault(host_resolver()));
+ net::HttpAuthHandlerFactory::CreateDefault(host_resolver()));
}
if (!http_server_properties()) {
context_storage_.set_http_server_properties(
- new HttpServerPropertiesImpl);
+ new net::HttpServerPropertiesImpl);
}
if (!transport_security_state()) {
context_storage_.set_transport_security_state(
- new TransportSecurityState());
+ new net::TransportSecurityState());
}
- HttpNetworkSession::Params params;
+ net::HttpNetworkSession::Params params;
params.host_resolver = host_resolver();
params.cert_verifier = cert_verifier();
params.proxy_service = proxy_service();
@@ -102,33 +100,33 @@ void TestURLRequestContext::Init() {
params.http_server_properties = http_server_properties();
if (!http_transaction_factory()) {
- context_storage_.set_http_transaction_factory(new HttpCache(
- new HttpNetworkSession(params),
- HttpCache::DefaultBackend::InMemory(0)));
+ context_storage_.set_http_transaction_factory(new net::HttpCache(
+ new net::HttpNetworkSession(params),
+ net::HttpCache::DefaultBackend::InMemory(0)));
}
// In-memory cookie store.
if (!cookie_store())
- context_storage_.set_cookie_store(new CookieMonster(NULL, NULL));
+ context_storage_.set_cookie_store(new net::CookieMonster(NULL, NULL));
// In-memory origin bound cert service.
if (!server_bound_cert_service()) {
context_storage_.set_server_bound_cert_service(
- new ServerBoundCertService(
- new DefaultServerBoundCertStore(NULL),
+ new net::ServerBoundCertService(
+ new net::DefaultServerBoundCertStore(NULL),
base::WorkerPool::GetTaskRunner(true)));
}
if (!http_user_agent_settings()) {
context_storage_.set_http_user_agent_settings(
- new StaticHttpUserAgentSettings(
+ new net::StaticHttpUserAgentSettings(
"en-us,fr", "iso-8859-1,*,utf-8", EmptyString()));
}
if (!job_factory())
- context_storage_.set_job_factory(new URLRequestJobFactoryImpl);
+ context_storage_.set_job_factory(new net::URLRequestJobFactoryImpl);
}
TestURLRequest::TestURLRequest(const GURL& url,
Delegate* delegate,
TestURLRequestContext* context)
- : URLRequest(url, delegate, context) {
+ : net::URLRequest(url, delegate, context) {
}
TestURLRequest::~TestURLRequest() {
@@ -176,12 +174,12 @@ TestDelegate::TestDelegate()
have_certificate_errors_(false),
certificate_errors_are_fatal_(false),
auth_required_(false),
- buf_(new IOBuffer(kBufferSize)) {
+ buf_(new net::IOBuffer(kBufferSize)) {
}
TestDelegate::~TestDelegate() {}
-void TestDelegate::OnReceivedRedirect(URLRequest* request,
+void TestDelegate::OnReceivedRedirect(net::URLRequest* request,
const GURL& new_url,
bool* defer_redirect) {
EXPECT_TRUE(request->is_redirecting());
@@ -194,8 +192,8 @@ void TestDelegate::OnReceivedRedirect(URLRequest* request,
}
}
-void TestDelegate::OnAuthRequired(URLRequest* request,
- AuthChallengeInfo* auth_info) {
+void TestDelegate::OnAuthRequired(net::URLRequest* request,
+ net::AuthChallengeInfo* auth_info) {
auth_required_ = true;
if (!credentials_.Empty()) {
request->SetAuth(credentials_);
@@ -204,8 +202,8 @@ void TestDelegate::OnAuthRequired(URLRequest* request,
}
}
-void TestDelegate::OnSSLCertificateError(URLRequest* request,
- const SSLInfo& ssl_info,
+void TestDelegate::OnSSLCertificateError(net::URLRequest* request,
+ const net::SSLInfo& ssl_info,
bool fatal) {
// The caller can control whether it needs all SSL requests to go through,
// independent of any possible errors, or whether it wants SSL errors to
@@ -218,7 +216,7 @@ void TestDelegate::OnSSLCertificateError(URLRequest* request,
request->Cancel();
}
-void TestDelegate::OnResponseStarted(URLRequest* request) {
+void TestDelegate::OnResponseStarted(net::URLRequest* request) {
// It doesn't make sense for the request to have IO pending at this point.
DCHECK(!request->status().is_io_pending());
EXPECT_FALSE(request->is_redirecting());
@@ -228,8 +226,8 @@ void TestDelegate::OnResponseStarted(URLRequest* request) {
request->Cancel();
OnResponseCompleted(request);
} else if (!request->status().is_success()) {
- DCHECK(request->status().status() == URLRequestStatus::FAILED ||
- request->status().status() == URLRequestStatus::CANCELED);
+ DCHECK(request->status().status() == net::URLRequestStatus::FAILED ||
+ request->status().status() == net::URLRequestStatus::CANCELED);
request_failed_ = true;
OnResponseCompleted(request);
} else {
@@ -242,7 +240,7 @@ void TestDelegate::OnResponseStarted(URLRequest* request) {
}
}
-void TestDelegate::OnReadCompleted(URLRequest* request, int bytes_read) {
+void TestDelegate::OnReadCompleted(net::URLRequest* request, int bytes_read) {
// It doesn't make sense for the request to have IO pending at this point.
DCHECK(!request->status().is_io_pending());
@@ -278,7 +276,7 @@ void TestDelegate::OnReadCompleted(URLRequest* request, int bytes_read) {
request->Cancel();
}
-void TestDelegate::OnResponseCompleted(URLRequest* request) {
+void TestDelegate::OnResponseCompleted(net::URLRequest* request) {
if (quit_on_complete_)
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
}
@@ -311,8 +309,8 @@ void TestNetworkDelegate::InitRequestStatesIfNew(int request_id) {
}
int TestNetworkDelegate::OnBeforeURLRequest(
- URLRequest* request,
- const CompletionCallback& callback,
+ net::URLRequest* request,
+ const net::CompletionCallback& callback,
GURL* new_url ) {
int req_id = request->identifier();
InitRequestStatesIfNew(req_id);
@@ -326,13 +324,13 @@ int TestNetworkDelegate::OnBeforeURLRequest(
kStageCompletedError | // request canceled by delegate
kStageAuthRequired; // Auth can come next for FTP requests
created_requests_++;
- return OK;
+ return net::OK;
}
int TestNetworkDelegate::OnBeforeSendHeaders(
- URLRequest* request,
- const CompletionCallback& callback,
- HttpRequestHeaders* headers) {
+ net::URLRequest* request,
+ const net::CompletionCallback& callback,
+ net::HttpRequestHeaders* headers) {
int req_id = request->identifier();
InitRequestStatesIfNew(req_id);
event_order_[req_id] += "OnBeforeSendHeaders\n";
@@ -342,12 +340,12 @@ int TestNetworkDelegate::OnBeforeSendHeaders(
kStageSendHeaders |
kStageCompletedError; // request canceled by delegate
- return OK;
+ return net::OK;
}
void TestNetworkDelegate::OnSendHeaders(
- URLRequest* request,
- const HttpRequestHeaders& headers) {
+ net::URLRequest* request,
+ const net::HttpRequestHeaders& headers) {
int req_id = request->identifier();
InitRequestStatesIfNew(req_id);
event_order_[req_id] += "OnSendHeaders\n";
@@ -359,10 +357,10 @@ void TestNetworkDelegate::OnSendHeaders(
}
int TestNetworkDelegate::OnHeadersReceived(
- URLRequest* request,
- const CompletionCallback& callback,
- const HttpResponseHeaders* original_response_headers,
- scoped_refptr<HttpResponseHeaders>* override_response_headers) {
+ net::URLRequest* request,
+ const net::CompletionCallback& callback,
+ const net::HttpResponseHeaders* original_response_headers,
+ scoped_refptr<net::HttpResponseHeaders>* override_response_headers) {
int req_id = request->identifier();
event_order_[req_id] += "OnHeadersReceived\n";
InitRequestStatesIfNew(req_id);
@@ -378,10 +376,10 @@ int TestNetworkDelegate::OnHeadersReceived(
// layer before the URLRequest reports that a response has started.
next_states_[req_id] |= kStageBeforeSendHeaders;
- return OK;
+ return net::OK;
}
-void TestNetworkDelegate::OnBeforeRedirect(URLRequest* request,
+void TestNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
const GURL& new_location) {
int req_id = request->identifier();
InitRequestStatesIfNew(req_id);
@@ -399,24 +397,24 @@ void TestNetworkDelegate::OnBeforeRedirect(URLRequest* request,
next_states_[req_id] |= kStageResponseStarted;
}
-void TestNetworkDelegate::OnResponseStarted(URLRequest* request) {
+void TestNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
int req_id = request->identifier();
InitRequestStatesIfNew(req_id);
event_order_[req_id] += "OnResponseStarted\n";
EXPECT_TRUE(next_states_[req_id] & kStageResponseStarted) <<
event_order_[req_id];
next_states_[req_id] = kStageCompletedSuccess | kStageCompletedError;
- if (request->status().status() == URLRequestStatus::FAILED) {
+ if (request->status().status() == net::URLRequestStatus::FAILED) {
error_count_++;
last_error_ = request->status().error();
}
}
-void TestNetworkDelegate::OnRawBytesRead(const URLRequest& request,
+void TestNetworkDelegate::OnRawBytesRead(const net::URLRequest& request,
int bytes_read) {
}
-void TestNetworkDelegate::OnCompleted(URLRequest* request, bool started) {
+void TestNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) {
int req_id = request->identifier();
InitRequestStatesIfNew(req_id);
event_order_[req_id] += "OnCompleted\n";
@@ -431,13 +429,14 @@ void TestNetworkDelegate::OnCompleted(URLRequest* request, bool started) {
event_order_[req_id];
next_states_[req_id] = kStageURLRequestDestroyed;
completed_requests_++;
- if (request->status().status() == URLRequestStatus::FAILED) {
+ if (request->status().status() == net::URLRequestStatus::FAILED) {
error_count_++;
last_error_ = request->status().error();
}
}
-void TestNetworkDelegate::OnURLRequestDestroyed(URLRequest* request) {
+void TestNetworkDelegate::OnURLRequestDestroyed(
+ net::URLRequest* request) {
int req_id = request->identifier();
InitRequestStatesIfNew(req_id);
event_order_[req_id] += "OnURLRequestDestroyed\n";
@@ -451,11 +450,11 @@ void TestNetworkDelegate::OnPACScriptError(int line_number,
const string16& error) {
}
-NetworkDelegate::AuthRequiredResponse TestNetworkDelegate::OnAuthRequired(
- URLRequest* request,
- const AuthChallengeInfo& auth_info,
+net::NetworkDelegate::AuthRequiredResponse TestNetworkDelegate::OnAuthRequired(
+ net::URLRequest* request,
+ const net::AuthChallengeInfo& auth_info,
const AuthCallback& callback,
- AuthCredentials* credentials) {
+ net::AuthCredentials* credentials) {
int req_id = request->identifier();
InitRequestStatesIfNew(req_id);
event_order_[req_id] += "OnAuthRequired\n";
@@ -467,11 +466,11 @@ NetworkDelegate::AuthRequiredResponse TestNetworkDelegate::OnAuthRequired(
kStageResponseStarted | // data: URLs do not trigger sending headers
kStageBeforeRedirect | // a delegate can trigger a redirection
kStageCompletedError; // request cancelled before callback
- return NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION;
+ return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION;
}
-bool TestNetworkDelegate::OnCanGetCookies(const URLRequest& request,
- const CookieList& cookie_list) {
+bool TestNetworkDelegate::OnCanGetCookies(const net::URLRequest& request,
+ const net::CookieList& cookie_list) {
bool allow = true;
if (cookie_options_bit_mask_ & NO_GET_COOKIES)
allow = false;
@@ -483,9 +482,9 @@ bool TestNetworkDelegate::OnCanGetCookies(const URLRequest& request,
return allow;
}
-bool TestNetworkDelegate::OnCanSetCookie(const URLRequest& request,
+bool TestNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
const std::string& cookie_line,
- CookieOptions* options) {
+ net::CookieOptions* options) {
bool allow = true;
if (cookie_options_bit_mask_ & NO_SET_COOKIE)
allow = false;
@@ -499,24 +498,24 @@ bool TestNetworkDelegate::OnCanSetCookie(const URLRequest& request,
return allow;
}
-bool TestNetworkDelegate::OnCanAccessFile(const URLRequest& request,
+bool TestNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
const FilePath& path) const {
return true;
}
bool TestNetworkDelegate::OnCanThrottleRequest(
- const URLRequest& request) const {
+ const net::URLRequest& request) const {
return true;
}
int TestNetworkDelegate::OnBeforeSocketStreamConnect(
- SocketStream* socket,
- const CompletionCallback& callback) {
- return OK;
+ net::SocketStream* socket,
+ const net::CompletionCallback& callback) {
+ return net::OK;
}
void TestNetworkDelegate::OnRequestWaitStateChange(
- const URLRequest& request,
+ const net::URLRequest& request,
RequestWaitState state) {
}
@@ -543,29 +542,27 @@ const std::string& ScopedCustomUrlRequestTestHttpHost::value() {
TestJobInterceptor::TestJobInterceptor() : main_intercept_job_(NULL) {
}
-URLRequestJob* TestJobInterceptor::MaybeIntercept(
- URLRequest* request,
- NetworkDelegate* network_delegate) const {
- URLRequestJob* job = main_intercept_job_;
+net::URLRequestJob* TestJobInterceptor::MaybeIntercept(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const {
+ net::URLRequestJob* job = main_intercept_job_;
main_intercept_job_ = NULL;
return job;
}
-URLRequestJob* TestJobInterceptor::MaybeInterceptRedirect(
+net::URLRequestJob* TestJobInterceptor::MaybeInterceptRedirect(
const GURL& location,
- URLRequest* request,
- NetworkDelegate* network_delegate) const {
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const {
return NULL;
}
-URLRequestJob* TestJobInterceptor::MaybeInterceptResponse(
- URLRequest* request,
- NetworkDelegate* network_delegate) const {
+net::URLRequestJob* TestJobInterceptor::MaybeInterceptResponse(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const {
return NULL;
}
-void TestJobInterceptor::set_main_intercept_job(URLRequestJob* job) {
+void TestJobInterceptor::set_main_intercept_job(net::URLRequestJob* job) {
main_intercept_job_ = job;
}
-
-} // namespace net
diff --git a/net/url_request/url_request_test_util.h b/net/url_request/url_request_test_util.h
index 323efb2..41be008 100644
--- a/net/url_request/url_request_test_util.h
+++ b/net/url_request/url_request_test_util.h
@@ -41,11 +41,9 @@
using base::TimeDelta;
-namespace net {
-
//-----------------------------------------------------------------------------
-class TestURLRequestContext : public URLRequestContext {
+class TestURLRequestContext : public net::URLRequestContext {
public:
TestURLRequestContext();
// Default constructor like TestURLRequestContext() but does not call
@@ -61,14 +59,14 @@ class TestURLRequestContext : public URLRequestContext {
bool initialized_;
protected:
- URLRequestContextStorage context_storage_;
+ net::URLRequestContextStorage context_storage_;
};
//-----------------------------------------------------------------------------
// Used to return a dummy context, which lives on the message loop
// given in the constructor.
-class TestURLRequestContextGetter : public URLRequestContextGetter {
+class TestURLRequestContextGetter : public net::URLRequestContextGetter {
public:
// |network_task_runner| must not be NULL.
explicit TestURLRequestContextGetter(
@@ -79,7 +77,7 @@ class TestURLRequestContextGetter : public URLRequestContextGetter {
const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner,
scoped_ptr<TestURLRequestContext> context);
- // URLRequestContextGetter implementation.
+ // net::URLRequestContextGetter implementation.
virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE;
virtual scoped_refptr<base::SingleThreadTaskRunner>
GetNetworkTaskRunner() const OVERRIDE;
@@ -94,7 +92,7 @@ class TestURLRequestContextGetter : public URLRequestContextGetter {
//-----------------------------------------------------------------------------
-class TestURLRequest : public URLRequest {
+class TestURLRequest : public net::URLRequest {
public:
TestURLRequest(
const GURL& url, Delegate* delegate, TestURLRequestContext* context);
@@ -103,7 +101,7 @@ class TestURLRequest : public URLRequest {
//-----------------------------------------------------------------------------
-class TestDelegate : public URLRequest::Delegate {
+class TestDelegate : public net::URLRequest::Delegate {
public:
TestDelegate();
virtual ~TestDelegate();
@@ -119,7 +117,7 @@ class TestDelegate : public URLRequest::Delegate {
void set_allow_certificate_errors(bool val) {
allow_certificate_errors_ = val;
}
- void set_credentials(const AuthCredentials& credentials) {
+ void set_credentials(const net::AuthCredentials& credentials) {
credentials_ = credentials;
}
@@ -138,25 +136,25 @@ class TestDelegate : public URLRequest::Delegate {
}
bool auth_required_called() const { return auth_required_; }
- // URLRequest::Delegate:
- virtual void OnReceivedRedirect(URLRequest* request, const GURL& new_url,
+ // net::URLRequest::Delegate:
+ virtual void OnReceivedRedirect(net::URLRequest* request, const GURL& new_url,
bool* defer_redirect) OVERRIDE;
- virtual void OnAuthRequired(URLRequest* request,
- AuthChallengeInfo* auth_info) OVERRIDE;
+ virtual void OnAuthRequired(net::URLRequest* request,
+ net::AuthChallengeInfo* auth_info) OVERRIDE;
// NOTE: |fatal| causes |certificate_errors_are_fatal_| to be set to true.
// (Unit tests use this as a post-condition.) But for policy, this method
// consults |allow_certificate_errors_|.
- virtual void OnSSLCertificateError(URLRequest* request,
- const SSLInfo& ssl_info,
+ virtual void OnSSLCertificateError(net::URLRequest* request,
+ const net::SSLInfo& ssl_info,
bool fatal) OVERRIDE;
- virtual void OnResponseStarted(URLRequest* request) OVERRIDE;
- virtual void OnReadCompleted(URLRequest* request,
+ virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE;
+ virtual void OnReadCompleted(net::URLRequest* request,
int bytes_read) OVERRIDE;
private:
static const int kBufferSize = 4096;
- virtual void OnResponseCompleted(URLRequest* request);
+ virtual void OnResponseCompleted(net::URLRequest* request);
// options for controlling behavior
bool cancel_in_rr_;
@@ -166,7 +164,7 @@ class TestDelegate : public URLRequest::Delegate {
bool quit_on_complete_;
bool quit_on_redirect_;
bool allow_certificate_errors_;
- AuthCredentials credentials_;
+ net::AuthCredentials credentials_;
// tracks status of callbacks
int response_started_count_;
@@ -180,12 +178,12 @@ class TestDelegate : public URLRequest::Delegate {
std::string data_received_;
// our read buffer
- scoped_refptr<IOBuffer> buf_;
+ scoped_refptr<net::IOBuffer> buf_;
};
//-----------------------------------------------------------------------------
-class TestNetworkDelegate : public NetworkDelegate {
+class TestNetworkDelegate : public net::NetworkDelegate {
public:
enum Options {
NO_GET_COOKIES = 1 << 0,
@@ -207,47 +205,48 @@ class TestNetworkDelegate : public NetworkDelegate {
int set_cookie_count() const { return set_cookie_count_; }
protected:
- // NetworkDelegate:
- virtual int OnBeforeURLRequest(URLRequest* request,
- const CompletionCallback& callback,
+ // net::NetworkDelegate:
+ virtual int OnBeforeURLRequest(net::URLRequest* request,
+ const net::CompletionCallback& callback,
GURL* new_url) OVERRIDE;
- virtual int OnBeforeSendHeaders(URLRequest* request,
- const CompletionCallback& callback,
- HttpRequestHeaders* headers) OVERRIDE;
- virtual void OnSendHeaders(URLRequest* request,
- const HttpRequestHeaders& headers) OVERRIDE;
+ virtual int OnBeforeSendHeaders(net::URLRequest* request,
+ const net::CompletionCallback& callback,
+ net::HttpRequestHeaders* headers) OVERRIDE;
+ virtual void OnSendHeaders(net::URLRequest* request,
+ const net::HttpRequestHeaders& headers) OVERRIDE;
virtual int OnHeadersReceived(
- URLRequest* request,
- const CompletionCallback& callback,
- const HttpResponseHeaders* original_response_headers,
- scoped_refptr<HttpResponseHeaders>* override_response_headers) OVERRIDE;
- virtual void OnBeforeRedirect(URLRequest* request,
+ net::URLRequest* request,
+ const net::CompletionCallback& callback,
+ const net::HttpResponseHeaders* original_response_headers,
+ scoped_refptr<net::HttpResponseHeaders>* override_response_headers)
+ OVERRIDE;
+ virtual void OnBeforeRedirect(net::URLRequest* request,
const GURL& new_location) OVERRIDE;
- virtual void OnResponseStarted(URLRequest* request) OVERRIDE;
- virtual void OnRawBytesRead(const URLRequest& request,
+ virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE;
+ virtual void OnRawBytesRead(const net::URLRequest& request,
int bytes_read) OVERRIDE;
- virtual void OnCompleted(URLRequest* request, bool started) OVERRIDE;
- virtual void OnURLRequestDestroyed(URLRequest* request) OVERRIDE;
+ virtual void OnCompleted(net::URLRequest* request, bool started) OVERRIDE;
+ virtual void OnURLRequestDestroyed(net::URLRequest* request) OVERRIDE;
virtual void OnPACScriptError(int line_number,
const string16& error) OVERRIDE;
- virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired(
- URLRequest* request,
- const AuthChallengeInfo& auth_info,
+ virtual net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(
+ net::URLRequest* request,
+ const net::AuthChallengeInfo& auth_info,
const AuthCallback& callback,
- AuthCredentials* credentials) OVERRIDE;
- virtual bool OnCanGetCookies(const URLRequest& request,
- const CookieList& cookie_list) OVERRIDE;
- virtual bool OnCanSetCookie(const URLRequest& request,
+ net::AuthCredentials* credentials) OVERRIDE;
+ virtual bool OnCanGetCookies(const net::URLRequest& request,
+ const net::CookieList& cookie_list) OVERRIDE;
+ virtual bool OnCanSetCookie(const net::URLRequest& request,
const std::string& cookie_line,
- CookieOptions* options) OVERRIDE;
- virtual bool OnCanAccessFile(const URLRequest& request,
+ net::CookieOptions* options) OVERRIDE;
+ virtual bool OnCanAccessFile(const net::URLRequest& request,
const FilePath& path) const OVERRIDE;
virtual bool OnCanThrottleRequest(
- const URLRequest& request) const OVERRIDE;
+ const net::URLRequest& request) const OVERRIDE;
virtual int OnBeforeSocketStreamConnect(
- SocketStream* stream,
- const CompletionCallback& callback) OVERRIDE;
- virtual void OnRequestWaitStateChange(const URLRequest& request,
+ net::SocketStream* stream,
+ const net::CompletionCallback& callback) OVERRIDE;
+ virtual void OnRequestWaitStateChange(const net::URLRequest& request,
RequestWaitState state) OVERRIDE;
void InitRequestStatesIfNew(int request_id);
@@ -262,7 +261,7 @@ class TestNetworkDelegate : public NetworkDelegate {
int blocked_set_cookie_count_;
int set_cookie_count_;
- // NetworkDelegate callbacks happen in a particular order (e.g.
+ // net::NetworkDelegate callbacks happen in a particular order (e.g.
// OnBeforeURLRequest is always called before OnBeforeSendHeaders).
// This bit-set indicates for each request id (key) what events may be sent
// next.
@@ -301,26 +300,24 @@ class ScopedCustomUrlRequestTestHttpHost {
//-----------------------------------------------------------------------------
// A simple Interceptor that returns a pre-built URLRequestJob only once.
-class TestJobInterceptor : public URLRequestJobFactory::Interceptor {
+class TestJobInterceptor : public net::URLRequestJobFactory::Interceptor {
public:
TestJobInterceptor();
- virtual URLRequestJob* MaybeIntercept(
- URLRequest* request,
- NetworkDelegate* network_delegate) const OVERRIDE;
- virtual URLRequestJob* MaybeInterceptRedirect(
+ virtual net::URLRequestJob* MaybeIntercept(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const OVERRIDE;
+ virtual net::URLRequestJob* MaybeInterceptRedirect(
const GURL& location,
- URLRequest* request,
- NetworkDelegate* network_delegate) const OVERRIDE;
- virtual URLRequestJob* MaybeInterceptResponse(
- URLRequest* request,
- NetworkDelegate* network_delegate) const OVERRIDE;
- void set_main_intercept_job(URLRequestJob* job);
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const OVERRIDE;
+ virtual net::URLRequestJob* MaybeInterceptResponse(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const OVERRIDE;
+ void set_main_intercept_job(net::URLRequestJob* job);
private:
- mutable URLRequestJob* main_intercept_job_;
+ mutable net::URLRequestJob* main_intercept_job_;
};
-} // namespace net
-
#endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_