summaryrefslogtreecommitdiffstats
path: root/net/url_request
diff options
context:
space:
mode:
Diffstat (limited to 'net/url_request')
-rw-r--r--net/url_request/url_request.cc8
-rw-r--r--net/url_request/url_request.h4
-rw-r--r--net/url_request/url_request_file_job.cc18
-rw-r--r--net/url_request/url_request_file_job.h3
-rw-r--r--net/url_request/url_request_ftp_job.cc2
-rw-r--r--net/url_request/url_request_job.cc4
-rw-r--r--net/url_request/url_request_unittest.cc50
-rw-r--r--net/url_request/url_request_unittest.h4
-rw-r--r--net/url_request/view_cache_helper_unittest.cc4
9 files changed, 60 insertions, 37 deletions
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index c8dd874..c4f20c4 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -315,8 +315,8 @@ void URLRequest::StartJob(URLRequestJob* job) {
net_log_.BeginEvent(
net::NetLog::TYPE_URL_REQUEST_START_JOB,
- new URLRequestStartEventParameters(
- url_, method_, load_flags_, priority_));
+ make_scoped_refptr(new URLRequestStartEventParameters(
+ url_, method_, load_flags_, priority_)));
job_ = job;
job_->SetExtraRequestHeaders(extra_request_headers_);
@@ -493,8 +493,8 @@ int URLRequest::Redirect(const GURL& location, int http_status_code) {
if (net_log_.IsLoggingAllEvents()) {
net_log_.AddEvent(
net::NetLog::TYPE_URL_REQUEST_REDIRECTED,
- new net::NetLogStringParameter(
- "location", location.possibly_invalid_spec()));
+ make_scoped_refptr(new net::NetLogStringParameter(
+ "location", location.possibly_invalid_spec())));
}
if (redirect_limit_ <= 0) {
DVLOG(1) << "disallowing redirect: exceeds limit";
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h
index 31b732e..f573111 100644
--- a/net/url_request/url_request.h
+++ b/net/url_request/url_request.h
@@ -10,7 +10,7 @@
#include <string>
#include <vector>
-#include "base/leak_tracker.h"
+#include "base/debug/leak_tracker.h"
#include "base/linked_ptr.h"
#include "base/logging.h"
#include "base/non_thread_safe.h"
@@ -634,7 +634,7 @@ class URLRequest : public NonThreadSafe {
// this to determine which URLRequest to allocate sockets to first.
net::RequestPriority priority_;
- base::LeakTracker<URLRequest> leak_tracker_;
+ base::debug::LeakTracker<URLRequest> leak_tracker_;
DISALLOW_COPY_AND_ASSIGN(URLRequest);
};
diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc
index 8c282ff..fff85c3 100644
--- a/net/url_request/url_request_file_job.cc
+++ b/net/url_request/url_request_file_job.cc
@@ -23,6 +23,7 @@
#include "base/message_loop.h"
#include "base/platform_file.h"
#include "base/string_util.h"
+#include "base/thread_restrictions.h"
#include "build/build_config.h"
#include "googleurl/src/gurl.h"
#include "net/base/io_buffer.h"
@@ -128,8 +129,15 @@ void URLRequestFileJob::Start() {
return;
}
#endif
+
+ // URL requests should not block on the disk!
+ // http://code.google.com/p/chromium/issues/detail?id=59849
+ bool exists;
base::PlatformFileInfo file_info;
- bool exists = file_util::GetFileInfo(file_path_, &file_info);
+ {
+ base::ThreadRestrictions::ScopedAllowIO allow_io;
+ exists = file_util::GetFileInfo(file_path_, &file_info);
+ }
// Continue asynchronously.
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
@@ -195,6 +203,10 @@ bool URLRequestFileJob::GetContentEncodings(
}
bool URLRequestFileJob::GetMimeType(std::string* mime_type) const {
+ // URL requests should not block on the disk! On Windows this goes to the
+ // registry.
+ // http://code.google.com/p/chromium/issues/detail?id=59849
+ base::ThreadRestrictions::ScopedAllowIO allow_io;
DCHECK(request_);
return net::GetMimeTypeFromFile(file_path_, mime_type);
}
@@ -244,6 +256,10 @@ void URLRequestFileJob::DidResolve(
if (!exists) {
rv = net::ERR_FILE_NOT_FOUND;
} else if (!is_directory_) {
+ // URL requests should not block on the disk!
+ // http://code.google.com/p/chromium/issues/detail?id=59849
+ base::ThreadRestrictions::ScopedAllowIO allow_io;
+
int flags = base::PLATFORM_FILE_OPEN |
base::PLATFORM_FILE_READ |
base::PLATFORM_FILE_ASYNC;
diff --git a/net/url_request/url_request_file_job.h b/net/url_request/url_request_file_job.h
index adf9d24..c5e1d2f 100644
--- a/net/url_request/url_request_file_job.h
+++ b/net/url_request/url_request_file_job.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,6 +7,7 @@
#pragma once
#include <string>
+#include <vector>
#include "base/file_path.h"
#include "net/base/completion_callback.h"
diff --git a/net/url_request/url_request_ftp_job.cc b/net/url_request/url_request_ftp_job.cc
index 37d6ab0..aec8248 100644
--- a/net/url_request/url_request_ftp_job.cc
+++ b/net/url_request/url_request_ftp_job.cc
@@ -82,7 +82,7 @@ void URLRequestFtpJob::GetAuthChallengeInfo(
scoped_refptr<net::AuthChallengeInfo>* result) {
DCHECK((server_auth_ != NULL) &&
(server_auth_->state == net::AUTH_STATE_NEED_AUTH));
- scoped_refptr<net::AuthChallengeInfo> auth_info = new net::AuthChallengeInfo;
+ scoped_refptr<net::AuthChallengeInfo> auth_info(new net::AuthChallengeInfo);
auth_info->is_proxy = false;
auth_info->host_and_port = ASCIIToWide(
net::GetHostAndPort(request_->url()));
diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc
index 2a4d036..a059a00 100644
--- a/net/url_request/url_request_job.cc
+++ b/net/url_request/url_request_job.cc
@@ -452,7 +452,7 @@ void URLRequestJob::NotifyHeadersComplete() {
// check the request pointer to see if it still exists, and return
// immediately if it has been destroyed. self_preservation ensures our
// survival until we can get out of this method.
- scoped_refptr<URLRequestJob> self_preservation = this;
+ scoped_refptr<URLRequestJob> self_preservation(this);
GURL new_location;
int http_status_code;
@@ -558,7 +558,7 @@ void URLRequestJob::NotifyReadComplete(int bytes_read) {
// check the request pointer to see if it still exists, and return
// immediately if it has been destroyed. self_preservation ensures our
// survival until we can get out of this method.
- scoped_refptr<URLRequestJob> self_preservation = this;
+ scoped_refptr<URLRequestJob> self_preservation(this);
prefilter_bytes_read_ += bytes_read;
if (filter_.get()) {
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 3c5d05f..d0f488d 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -69,7 +69,7 @@ bool ContainsString(const std::string& haystack, const char* needle) {
haystack.end(),
needle,
needle + strlen(needle),
- CaseInsensitiveCompare<char>());
+ base::CaseInsensitiveCompare<char>());
return it != haystack.end();
}
@@ -89,7 +89,7 @@ void FillBuffer(char* buffer, size_t len) {
}
scoped_refptr<net::UploadData> CreateSimpleUploadData(const char* data) {
- scoped_refptr<net::UploadData> upload = new net::UploadData;
+ scoped_refptr<net::UploadData> upload(new net::UploadData);
upload->AppendBytes(data, strlen(data));
return upload;
}
@@ -146,7 +146,7 @@ class URLRequestTestHTTP : public URLRequestTest {
}
uploadBytes[kMsgSize] = '\0';
- scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<URLRequestContext> context(new TestURLRequestContext());
for (int i = 0; i < kIterations; ++i) {
TestDelegate d;
@@ -310,7 +310,9 @@ TEST_F(HTTPSRequestTest, HTTPSGetTest) {
}
TEST_F(HTTPSRequestTest, HTTPSMismatchedTest) {
- net::TestServer test_server(net::TestServer::TYPE_HTTPS_MISMATCHED_HOSTNAME,
+ net::TestServer::HTTPSOptions https_options(
+ net::TestServer::HTTPSOptions::CERT_MISMATCHED_NAME);
+ net::TestServer test_server(https_options,
FilePath(FILE_PATH_LITERAL("net/data/ssl")));
ASSERT_TRUE(test_server.Start());
@@ -340,7 +342,9 @@ TEST_F(HTTPSRequestTest, HTTPSMismatchedTest) {
}
TEST_F(HTTPSRequestTest, HTTPSExpiredTest) {
- net::TestServer test_server(net::TestServer::TYPE_HTTPS_EXPIRED_CERTIFICATE,
+ net::TestServer::HTTPSOptions https_options(
+ net::TestServer::HTTPSOptions::CERT_EXPIRED);
+ net::TestServer test_server(https_options,
FilePath(FILE_PATH_LITERAL("net/data/ssl")));
ASSERT_TRUE(test_server.Start());
@@ -398,7 +402,9 @@ class SSLClientAuthTestDelegate : public TestDelegate {
// - Getting a certificate request in an SSL renegotiation sending the
// HTTP request.
TEST_F(HTTPSRequestTest, ClientAuthTest) {
- net::TestServer test_server(net::TestServer::TYPE_HTTPS_CLIENT_AUTH,
+ net::TestServer::HTTPSOptions https_options;
+ https_options.request_client_certificate = true;
+ net::TestServer test_server(https_options,
FilePath(FILE_PATH_LITERAL("net/data/ssl")));
ASSERT_TRUE(test_server.Start());
@@ -521,7 +527,7 @@ TEST_F(URLRequestTestHTTP, CancelTest4) {
TEST_F(URLRequestTestHTTP, CancelTest5) {
ASSERT_TRUE(test_server_.Start());
- scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<URLRequestContext> context(new TestURLRequestContext());
// populate cache
{
@@ -1128,7 +1134,7 @@ TEST_F(URLRequestTestHTTP, CancelDeferredRedirect) {
TEST_F(URLRequestTestHTTP, VaryHeader) {
ASSERT_TRUE(test_server_.Start());
- scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<URLRequestContext> context(new TestURLRequestContext());
// populate the cache
{
@@ -1174,7 +1180,7 @@ TEST_F(URLRequestTestHTTP, VaryHeader) {
TEST_F(URLRequestTestHTTP, BasicAuth) {
ASSERT_TRUE(test_server_.Start());
- scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<URLRequestContext> context(new TestURLRequestContext());
// populate the cache
{
@@ -1224,7 +1230,7 @@ TEST_F(URLRequestTestHTTP, BasicAuthWithCookies) {
// Request a page that will give a 401 containing a Set-Cookie header.
// Verify that when the transaction is restarted, it includes the new cookie.
{
- scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<URLRequestContext> context(new TestURLRequestContext());
TestDelegate d;
d.set_username(kUser);
d.set_password(kSecret);
@@ -1245,7 +1251,7 @@ TEST_F(URLRequestTestHTTP, BasicAuthWithCookies) {
// Same test as above, except this time the restart is initiated earlier
// (without user intervention since identity is embedded in the URL).
{
- scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<URLRequestContext> context(new TestURLRequestContext());
TestDelegate d;
GURL::Replacements replacements;
@@ -1273,7 +1279,7 @@ TEST_F(URLRequestTest, DoNotSendCookies) {
net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath());
ASSERT_TRUE(test_server.Start());
- scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<URLRequestContext> context(new TestURLRequestContext());
// Set up a cookie.
{
@@ -1322,7 +1328,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies) {
net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath());
ASSERT_TRUE(test_server.Start());
- scoped_refptr<URLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<URLRequestContext> context(new TestURLRequestContext());
// Set up a cookie.
{
@@ -1378,7 +1384,7 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) {
net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath());
ASSERT_TRUE(test_server.Start());
- scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
// Set up a cookie.
{
@@ -1432,7 +1438,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) {
net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath());
ASSERT_TRUE(test_server.Start());
- scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
// Set up a cookie.
{
@@ -1489,7 +1495,7 @@ TEST_F(URLRequestTest, DoNotSaveEmptyCookies) {
net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath());
ASSERT_TRUE(test_server.Start());
- scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
// Set up an empty cookie.
{
@@ -1509,7 +1515,7 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) {
net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath());
ASSERT_TRUE(test_server.Start());
- scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
// Set up a cookie.
{
@@ -1564,7 +1570,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) {
net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath());
ASSERT_TRUE(test_server.Start());
- scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
// Set up a cookie.
{
@@ -1621,7 +1627,7 @@ TEST_F(URLRequestTest, CancelTest_During_CookiePolicy) {
net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath());
ASSERT_TRUE(test_server.Start());
- scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
TestCookiePolicy cookie_policy(TestCookiePolicy::ASYNC);
context->set_cookie_policy(&cookie_policy);
@@ -1652,7 +1658,7 @@ TEST_F(URLRequestTest, CancelTest_During_OnGetCookies) {
net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath());
ASSERT_TRUE(test_server.Start());
- scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
TestCookiePolicy cookie_policy(TestCookiePolicy::NO_GET_COOKIES);
context->set_cookie_policy(&cookie_policy);
@@ -1681,7 +1687,7 @@ TEST_F(URLRequestTest, CancelTest_During_OnSetCookie) {
net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath());
ASSERT_TRUE(test_server.Start());
- scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
TestCookiePolicy cookie_policy(TestCookiePolicy::NO_SET_COOKIE);
context->set_cookie_policy(&cookie_policy);
@@ -1715,7 +1721,7 @@ TEST_F(URLRequestTest, CookiePolicy_ForceSession) {
net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath());
ASSERT_TRUE(test_server.Start());
- scoped_refptr<TestURLRequestContext> context = new TestURLRequestContext();
+ scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
TestCookiePolicy cookie_policy(TestCookiePolicy::FORCE_SESSION);
context->set_cookie_policy(&cookie_policy);
diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h
index 2a3ae41..abb6ab5 100644
--- a/net/url_request/url_request_unittest.h
+++ b/net/url_request/url_request_unittest.h
@@ -126,7 +126,7 @@ class TestURLRequestContext : public URLRequestContext {
TestURLRequestContext() {
host_resolver_ =
net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism,
- NULL);
+ NULL, NULL);
proxy_service_ = net::ProxyService::CreateDirect();
Init();
}
@@ -134,7 +134,7 @@ class TestURLRequestContext : public URLRequestContext {
explicit TestURLRequestContext(const std::string& proxy) {
host_resolver_ =
net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism,
- NULL);
+ NULL, NULL);
net::ProxyConfig proxy_config;
proxy_config.proxy_rules().ParseFromString(proxy);
proxy_service_ = net::ProxyService::CreateFixed(proxy_config);
diff --git a/net/url_request/view_cache_helper_unittest.cc b/net/url_request/view_cache_helper_unittest.cc
index e82ff15..5338ee5 100644
--- a/net/url_request/view_cache_helper_unittest.cc
+++ b/net/url_request/view_cache_helper_unittest.cc
@@ -40,8 +40,8 @@ void WriteHeaders(disk_cache::Entry* entry, int flags, const std::string data) {
pickle.WriteInt64(0);
pickle.WriteString(data);
- scoped_refptr<net::WrappedIOBuffer> buf = new net::WrappedIOBuffer(
- reinterpret_cast<const char*>(pickle.data()));
+ scoped_refptr<net::WrappedIOBuffer> buf(new net::WrappedIOBuffer(
+ reinterpret_cast<const char*>(pickle.data())));
int len = static_cast<int>(pickle.size());
TestCompletionCallback cb;