diff options
author | Kristian Monsen <kristianm@google.com> | 2011-05-24 16:24:13 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2011-05-25 14:13:32 +0100 |
commit | 3f50c38dc070f4bb515c1b64450dae14f316474e (patch) | |
tree | 29f309f9534e05c47244eedb438fc612578d133b /net/url_request | |
parent | e23bef148f7be2bdf9c3cb2cd3aa5ceebf1190fb (diff) | |
download | external_chromium-3f50c38dc070f4bb515c1b64450dae14f316474e.zip external_chromium-3f50c38dc070f4bb515c1b64450dae14f316474e.tar.gz external_chromium-3f50c38dc070f4bb515c1b64450dae14f316474e.tar.bz2 |
Merge Chromium at r10.0.634.0: Initial merge by git.
Change-Id: Iac2af492818d119bcc2562eb5fdabf5ab0b6df9c
Diffstat (limited to 'net/url_request')
21 files changed, 206 insertions, 165 deletions
diff --git a/net/url_request/https_prober.h b/net/url_request/https_prober.h index 5d1a622..6540224 100644 --- a/net/url_request/https_prober.h +++ b/net/url_request/https_prober.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -14,10 +14,11 @@ #include "net/url_request/url_request.h" template <typename T> struct DefaultSingletonTraits; -class URLRequestContext; namespace net { +class URLRequestContext; + // This should be scoped inside HTTPSProber, but VC cannot compile // HTTPProber::Delegate when HTTPSProber also inherits from // net::URLRequest::Delegate. @@ -77,4 +78,5 @@ class HTTPSProber : public net::URLRequest::Delegate { }; } // namespace net -#endif + +#endif // NET_BASE_HTTPS_PROBER_H_ diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h index ffd4f88..3561a29 100644 --- a/net/url_request/url_request.h +++ b/net/url_request/url_request.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -13,9 +13,9 @@ #include "base/debug/leak_tracker.h" #include "base/linked_ptr.h" #include "base/logging.h" -#include "base/non_thread_safe.h" #include "base/ref_counted.h" #include "base/string16.h" +#include "base/threading/non_thread_safe.h" #include "googleurl/src/gurl.h" #include "net/base/load_states.h" #include "net/base/net_log.h" @@ -28,17 +28,7 @@ namespace base { class Time; } // namespace base -namespace net { -class CookieOptions; -class IOBuffer; -class SSLCertRequestInfo; -class UploadData; -class URLRequestJob; -class X509Certificate; -} // namespace net - class FilePath; -class URLRequestContext; // This stores the values of the Set-Cookie headers received during the request. // Each item in the vector corresponds to a Set-Cookie: line received, @@ -46,6 +36,15 @@ class URLRequestContext; typedef std::vector<std::string> ResponseCookies; namespace net { + +class CookieOptions; +class IOBuffer; +class SSLCertRequestInfo; +class UploadData; +class URLRequestContext; +class URLRequestJob; +class X509Certificate; + //----------------------------------------------------------------------------- // A class representing the asynchronous load of a data stream from an URL. // @@ -57,7 +56,7 @@ namespace net { // // NOTE: All usage of all instances of this class should be on the same thread. // -class URLRequest : public NonThreadSafe { +class URLRequest : public base::NonThreadSafe { public: // Derive from this class and add your own data members to associate extra // information with a URLRequest. Use GetUserData(key) and SetUserData() @@ -435,7 +434,7 @@ class URLRequest : public NonThreadSafe { bool is_pending() const { return is_pending_; } // Returns the error status of the request. - const URLRequestStatus& status() const { return status_; } + const net::URLRequestStatus& status() const { return status_; } // This method is called to start the request. The delegate will receive // a OnResponseStarted callback when the request is started. @@ -550,7 +549,7 @@ class URLRequest : public NonThreadSafe { void set_is_pending(bool value) { is_pending_ = value; } // Allow the URLRequestJob class to set our status too - void set_status(const URLRequestStatus& value) { status_ = value; } + void set_status(const net::URLRequestStatus& value) { status_ = value; } // Allow the URLRequestJob to redirect this request. Returns net::OK if // successful, otherwise an error code is returned. @@ -610,7 +609,7 @@ class URLRequest : public NonThreadSafe { // Current error status of the job. When no error has been encountered, this // will be SUCCESS. If multiple errors have been encountered, this will be // the first non-SUCCESS status seen. - URLRequestStatus status_; + net::URLRequestStatus status_; // The HTTP response info, lazily initialized. net::HttpResponseInfo response_info_; diff --git a/net/url_request/url_request_context.cc b/net/url_request/url_request_context.cc index 3bc7da6..8e0f3bd 100644 --- a/net/url_request/url_request_context.cc +++ b/net/url_request/url_request_context.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -8,6 +8,8 @@ #include "net/base/cookie_store.h" #include "net/base/host_resolver.h" +namespace net { + URLRequestContext::URLRequestContext() : net_log_(NULL), host_resolver_(NULL), @@ -30,6 +32,8 @@ const std::string& URLRequestContext::GetUserAgent(const GURL& url) const { URLRequestContext::~URLRequestContext() { } -void URLRequestContext::set_cookie_store(net::CookieStore* cookie_store) { +void URLRequestContext::set_cookie_store(CookieStore* cookie_store) { cookie_store_ = cookie_store; } + +} // namespace net diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h index d929696..d7e360d 100644 --- a/net/url_request/url_request_context.h +++ b/net/url_request/url_request_context.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -11,8 +11,8 @@ #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ #pragma once -#include "base/non_thread_safe.h" #include "base/ref_counted.h" +#include "base/threading/non_thread_safe.h" #include "net/base/net_log.h" #include "net/base/ssl_config_service.h" #include "net/base/transport_security_state.h" @@ -33,104 +33,103 @@ class HttpNetworkDelegate; class HttpTransactionFactory; class SSLConfigService; class URLRequest; -} // namespace net -// Subclass to provide application-specific context for net::URLRequest +// Subclass to provide application-specific context for URLRequest // instances. class URLRequestContext : public base::RefCountedThreadSafe<URLRequestContext>, - public NonThreadSafe { + public base::NonThreadSafe { public: URLRequestContext(); - net::NetLog* net_log() const { + NetLog* net_log() const { return net_log_; } - void set_net_log(net::NetLog* net_log) { + void set_net_log(NetLog* net_log) { net_log_ = net_log; } - net::HostResolver* host_resolver() const { + HostResolver* host_resolver() const { return host_resolver_; } - void set_host_resolver(net::HostResolver* host_resolver) { + void set_host_resolver(HostResolver* host_resolver) { host_resolver_ = host_resolver; } - net::CertVerifier* cert_verifier() const { + CertVerifier* cert_verifier() const { return cert_verifier_; } - void set_cert_verifier(net::CertVerifier* cert_verifier) { + void set_cert_verifier(CertVerifier* cert_verifier) { cert_verifier_ = cert_verifier; } - net::DnsRRResolver* dnsrr_resolver() const { + DnsRRResolver* dnsrr_resolver() const { return dnsrr_resolver_; } - void set_dnsrr_resolver(net::DnsRRResolver* dnsrr_resolver) { + void set_dnsrr_resolver(DnsRRResolver* dnsrr_resolver) { dnsrr_resolver_ = dnsrr_resolver; } - net::DnsCertProvenanceChecker* dns_cert_checker() const { + DnsCertProvenanceChecker* dns_cert_checker() const { return dns_cert_checker_.get(); } // Get the proxy service for this context. - net::ProxyService* proxy_service() const { + ProxyService* proxy_service() const { return proxy_service_; } - void set_proxy_service(net::ProxyService* proxy_service) { + void set_proxy_service(ProxyService* proxy_service) { proxy_service_ = proxy_service; } // Get the ssl config service for this context. - net::SSLConfigService* ssl_config_service() const { + SSLConfigService* ssl_config_service() const { return ssl_config_service_; } // Gets the HTTP Authentication Handler Factory for this context. // The factory is only valid for the lifetime of this URLRequestContext - net::HttpAuthHandlerFactory* http_auth_handler_factory() { + HttpAuthHandlerFactory* http_auth_handler_factory() { return http_auth_handler_factory_; } - void set_http_auth_handler_factory(net::HttpAuthHandlerFactory* factory) { + void set_http_auth_handler_factory(HttpAuthHandlerFactory* factory) { http_auth_handler_factory_ = factory; } // Gets the http transaction factory for this context. - net::HttpTransactionFactory* http_transaction_factory() const { + HttpTransactionFactory* http_transaction_factory() const { return http_transaction_factory_; } - void set_http_transaction_factory(net::HttpTransactionFactory* factory) { + void set_http_transaction_factory(HttpTransactionFactory* factory) { http_transaction_factory_ = factory; } // Gets the ftp transaction factory for this context. - net::FtpTransactionFactory* ftp_transaction_factory() { + FtpTransactionFactory* ftp_transaction_factory() { return ftp_transaction_factory_; } // Gets the cookie store for this context (may be null, in which case // cookies are not stored). - net::CookieStore* cookie_store() { return cookie_store_.get(); } + CookieStore* cookie_store() { return cookie_store_.get(); } - void set_cookie_store(net::CookieStore* cookie_store); + void set_cookie_store(CookieStore* cookie_store); // Gets the cookie policy for this context (may be null, in which case // cookies are allowed). - net::CookiePolicy* cookie_policy() { return cookie_policy_; } + CookiePolicy* cookie_policy() { return cookie_policy_; } - net::TransportSecurityState* transport_security_state() { + TransportSecurityState* transport_security_state() { return transport_security_state_; } // Gets the FTP authentication cache for this context. - net::FtpAuthCache* ftp_auth_cache() { return &ftp_auth_cache_; } + FtpAuthCache* ftp_auth_cache() { return &ftp_auth_cache_; } // Gets the value of 'Accept-Charset' header field. const std::string& accept_charset() const { return accept_charset_; } @@ -167,21 +166,21 @@ class URLRequestContext // The following members are expected to be initialized and owned by // subclasses. - net::NetLog* net_log_; - net::HostResolver* host_resolver_; - net::CertVerifier* cert_verifier_; - net::DnsRRResolver* dnsrr_resolver_; - scoped_ptr<net::DnsCertProvenanceChecker> dns_cert_checker_; - scoped_refptr<net::ProxyService> proxy_service_; - scoped_refptr<net::SSLConfigService> ssl_config_service_; - net::HttpTransactionFactory* http_transaction_factory_; - net::FtpTransactionFactory* ftp_transaction_factory_; - net::HttpAuthHandlerFactory* http_auth_handler_factory_; - net::HttpNetworkDelegate* network_delegate_; - scoped_refptr<net::CookieStore> cookie_store_; - net::CookiePolicy* cookie_policy_; - scoped_refptr<net::TransportSecurityState> transport_security_state_; - net::FtpAuthCache ftp_auth_cache_; + NetLog* net_log_; + HostResolver* host_resolver_; + CertVerifier* cert_verifier_; + DnsRRResolver* dnsrr_resolver_; + scoped_ptr<DnsCertProvenanceChecker> dns_cert_checker_; + scoped_refptr<ProxyService> proxy_service_; + scoped_refptr<SSLConfigService> ssl_config_service_; + HttpTransactionFactory* http_transaction_factory_; + FtpTransactionFactory* ftp_transaction_factory_; + HttpAuthHandlerFactory* http_auth_handler_factory_; + HttpNetworkDelegate* network_delegate_; + scoped_refptr<CookieStore> cookie_store_; + CookiePolicy* cookie_policy_; + scoped_refptr<TransportSecurityState> transport_security_state_; + FtpAuthCache ftp_auth_cache_; std::string accept_language_; std::string accept_charset_; // The charset of the referrer where this request comes from. It's not @@ -196,4 +195,9 @@ class URLRequestContext DISALLOW_COPY_AND_ASSIGN(URLRequestContext); }; +} // namespace net + +// TODO(tfarina): Fix the callers and remove this! +typedef net::URLRequestContext URLRequestContext; + #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ diff --git a/net/url_request/url_request_file_dir_job.cc b/net/url_request/url_request_file_dir_job.cc index 553add8..badb6b8 100644 --- a/net/url_request/url_request_file_dir_job.cc +++ b/net/url_request/url_request_file_dir_job.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 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. @@ -19,11 +19,11 @@ #include <sys/stat.h> #endif -using std::string; +namespace net { -URLRequestFileDirJob::URLRequestFileDirJob(net::URLRequest* request, +URLRequestFileDirJob::URLRequestFileDirJob(URLRequest* request, const FilePath& dir_path) - : net::URLRequestJob(request), + : URLRequestJob(request), dir_path_(dir_path), canceled_(false), list_complete_(false), @@ -57,7 +57,7 @@ void URLRequestFileDirJob::StartAsync() { // is trying to feed us data. AddRef(); - lister_ = new net::DirectoryLister(dir_path_, this); + lister_ = new DirectoryLister(dir_path_, this); lister_->Start(); NotifyHeadersComplete(); @@ -69,18 +69,18 @@ void URLRequestFileDirJob::Kill() { canceled_ = true; - // Don't call CloseLister or dispatch an error to the net::URLRequest because + // Don't call CloseLister or dispatch an error to the URLRequest because // we want OnListDone to be called to also write the error to the output - // stream. OnListDone will notify the net::URLRequest at this time. + // stream. OnListDone will notify the URLRequest at this time. if (lister_) lister_->Cancel(); - net::URLRequestJob::Kill(); + URLRequestJob::Kill(); method_factory_.RevokeAll(); } -bool URLRequestFileDirJob::ReadRawData(net::IOBuffer* buf, int buf_size, +bool URLRequestFileDirJob::ReadRawData(IOBuffer* buf, int buf_size, int *bytes_read) { DCHECK(bytes_read); *bytes_read = 0; @@ -99,19 +99,19 @@ bool URLRequestFileDirJob::ReadRawData(net::IOBuffer* buf, int buf_size, return false; } -bool URLRequestFileDirJob::GetMimeType(string* mime_type) const { +bool URLRequestFileDirJob::GetMimeType(std::string* mime_type) const { *mime_type = "text/html"; return true; } -bool URLRequestFileDirJob::GetCharset(string* charset) { +bool URLRequestFileDirJob::GetCharset(std::string* charset) { // All the filenames are converted to UTF-8 before being added. *charset = "utf-8"; return true; } void URLRequestFileDirJob::OnListFile( - const net::DirectoryLister::DirectoryListerData& data) { + const DirectoryLister::DirectoryListerData& data) { // We wait to write out the header until we get the first file, so that we // can catch errors from DirectoryLister and show an error page. if (!wrote_header_) { @@ -126,7 +126,7 @@ void URLRequestFileDirJob::OnListFile( const string16& title = WideToUTF16( base::SysNativeMBToWide(dir_path_.value())); #endif - data_.append(net::GetDirectoryListingHeader(title)); + data_.append(GetDirectoryListingHeader(title)); wrote_header_ = true; } @@ -137,7 +137,7 @@ void URLRequestFileDirJob::OnListFile( // Note that we should not convert ftLastWriteTime to the local time because // ICU's datetime formatting APIs expect time in UTC and take into account // the timezone before formatting. - data_.append(net::GetDirectoryListingEntry( + data_.append(GetDirectoryListingEntry( data.info.cFileName, std::string(), (data.info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? true : false, size, @@ -145,7 +145,7 @@ void URLRequestFileDirJob::OnListFile( #elif defined(OS_POSIX) // TOOD(jungshik): The same issue as for the directory name. - data_.append(net::GetDirectoryListingEntry( + data_.append(GetDirectoryListingEntry( WideToUTF16(base::SysNativeMBToWide(data.info.filename)), data.info.filename, S_ISDIR(data.info.stat.st_mode), @@ -220,3 +220,5 @@ void URLRequestFileDirJob::CompleteRead() { } } } + +} // namespace net diff --git a/net/url_request/url_request_file_dir_job.h b/net/url_request/url_request_file_dir_job.h index bdb9b37..2b40a98 100644 --- a/net/url_request/url_request_file_dir_job.h +++ b/net/url_request/url_request_file_dir_job.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H__ -#define NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H__ +#ifndef NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H_ +#define NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H_ #pragma once #include <string> @@ -14,23 +14,25 @@ #include "net/base/directory_lister.h" #include "net/url_request/url_request_job.h" +namespace net { + class URLRequestFileDirJob - : public net::URLRequestJob, - public net::DirectoryLister::DirectoryListerDelegate { + : public URLRequestJob, + public DirectoryLister::DirectoryListerDelegate { public: - URLRequestFileDirJob(net::URLRequest* request, const FilePath& dir_path); + URLRequestFileDirJob(URLRequest* request, const FilePath& dir_path); - // net::URLRequestJob methods: + // Overridden from URLRequestJob: virtual void Start(); virtual void StartAsync(); virtual void Kill(); - virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); + virtual bool ReadRawData(IOBuffer* buf, int buf_size, int *bytes_read); virtual bool GetMimeType(std::string* mime_type) const; virtual bool GetCharset(std::string* charset); - // DirectoryLister::DirectoryListerDelegate methods: + // Overridden from DirectoryLister::DirectoryListerDelegate: virtual void OnListFile( - const net::DirectoryLister::DirectoryListerData& data); + const DirectoryLister::DirectoryListerData& data); virtual void OnListDone(int error); bool list_complete() const { return list_complete_; } @@ -47,7 +49,7 @@ class URLRequestFileDirJob // Fills a buffer with the output. bool FillReadBuffer(char *buf, int buf_size, int *bytes_read); - scoped_refptr<net::DirectoryLister> lister_; + scoped_refptr<DirectoryLister> lister_; FilePath dir_path_; std::string data_; bool canceled_; @@ -62,11 +64,13 @@ class URLRequestFileDirJob // we wait for IO to complete. When done, we fill the buffer // manually. bool read_pending_; - scoped_refptr<net::IOBuffer> read_buffer_; + scoped_refptr<IOBuffer> read_buffer_; int read_buffer_length_; ScopedRunnableMethodFactory<URLRequestFileDirJob> method_factory_; DISALLOW_COPY_AND_ASSIGN(URLRequestFileDirJob); }; -#endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H__ +} // namespace net + +#endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H_ diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc index 230ee06..adc6f44 100644 --- a/net/url_request/url_request_file_job.cc +++ b/net/url_request/url_request_file_job.cc @@ -23,7 +23,8 @@ #include "base/message_loop.h" #include "base/platform_file.h" #include "base/string_util.h" -#include "base/thread_restrictions.h" +#include "base/threading/worker_pool.h" +#include "base/threading/thread_restrictions.h" #include "build/build_config.h" #include "googleurl/src/gurl.h" #include "net/base/io_buffer.h" @@ -36,10 +37,6 @@ #include "net/url_request/url_request_error_job.h" #include "net/url_request/url_request_file_dir_job.h" -#if defined(OS_WIN) -#include "base/worker_pool.h" -#endif - namespace net { #if defined(OS_WIN) @@ -136,7 +133,7 @@ void URLRequestFileJob::Start() { if (!file_path_.value().compare(0, 2, L"\\\\")) { DCHECK(!async_resolver_); async_resolver_ = new AsyncResolver(this); - WorkerPool::PostTask(FROM_HERE, NewRunnableMethod( + base::WorkerPool::PostTask(FROM_HERE, NewRunnableMethod( async_resolver_.get(), &AsyncResolver::Resolve, file_path_), true); return; } diff --git a/net/url_request/url_request_filter.cc b/net/url_request/url_request_filter.cc index 946c2c3..d52fef5 100644 --- a/net/url_request/url_request_filter.cc +++ b/net/url_request/url_request_filter.cc @@ -8,16 +8,18 @@ #include "base/logging.h" +namespace net { + URLRequestFilter* URLRequestFilter::shared_instance_ = NULL; -/* static */ +// static URLRequestFilter* URLRequestFilter::GetInstance() { if (!shared_instance_) shared_instance_ = new URLRequestFilter; return shared_instance_; } -/* static */ +// static net::URLRequestJob* URLRequestFilter::Factory(net::URLRequest* request, const std::string& scheme) { // Returning null here just means that the built-in handler will be used. @@ -142,3 +144,5 @@ net::URLRequestJob* URLRequestFilter::FindRequestHandler( } return job; } + +} // namespace net diff --git a/net/url_request/url_request_filter.h b/net/url_request/url_request_filter.h index 716ad4d..9138b87 100644 --- a/net/url_request/url_request_filter.h +++ b/net/url_request/url_request_filter.h @@ -30,7 +30,6 @@ class GURL; namespace net { class URLRequestJob; -} // namespace net class URLRequestFilter { public: @@ -89,4 +88,6 @@ class URLRequestFilter { DISALLOW_COPY_AND_ASSIGN(URLRequestFilter); }; +} // namespace net + #endif // NET_URL_REQUEST_URL_REQUEST_FILTER_H_ diff --git a/net/url_request/url_request_ftp_job.h b/net/url_request/url_request_ftp_job.h index d503766..ed65214 100644 --- a/net/url_request/url_request_ftp_job.h +++ b/net/url_request/url_request_ftp_job.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -16,10 +16,10 @@ #include "net/ftp/ftp_transaction.h" #include "net/url_request/url_request_job.h" -class URLRequestContext; - namespace net { +class URLRequestContext; + // A URLRequestJob subclass that is built on top of FtpTransaction. It // provides an implementation for FTP. class URLRequestFtpJob : public URLRequestJob { diff --git a/net/url_request/url_request_http_job.h b/net/url_request/url_request_http_job.h index 78778c5..fbd8baf 100644 --- a/net/url_request/url_request_http_job.h +++ b/net/url_request/url_request_http_job.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -18,12 +18,11 @@ #include "net/url_request/url_request_job.h" #include "net/url_request/url_request_throttler_entry_interface.h" -class URLRequestContext; - namespace net { class HttpResponseInfo; class HttpTransaction; +class URLRequestContext; // A net::URLRequestJob subclass that is built on top of HttpTransaction. It // provides an implementation for both HTTP and HTTPS. diff --git a/net/url_request/url_request_job.h b/net/url_request/url_request_job.h index 6f91c9a..23a3232 100644 --- a/net/url_request/url_request_job.h +++ b/net/url_request/url_request_job.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -17,7 +17,6 @@ #include "net/base/filter.h" #include "net/base/load_states.h" -class URLRequestStatus; namespace net { @@ -28,6 +27,7 @@ class IOBuffer; class URLRequest; class URLRequestJobMetrics; class UploadData; +class URLRequestStatus; class X509Certificate; class URLRequestJob : public base::RefCounted<URLRequestJob>, @@ -225,13 +225,13 @@ class URLRequestJob : public base::RefCounted<URLRequestJob>, void NotifyReadComplete(int bytes_read); // Notifies the request that a start error has occurred. - void NotifyStartError(const URLRequestStatus& status); + void NotifyStartError(const net::URLRequestStatus& status); // NotifyDone marks when we are done with a request. It is really // a glorified set_status, but also does internal state checking and // job tracking. It should be called once per request, when the job is // finished doing all IO. - void NotifyDone(const URLRequestStatus& status); + void NotifyDone(const net::URLRequestStatus& status); // Some work performed by NotifyDone must be completed on a separate task // so as to avoid re-entering the delegate. This method exists to perform @@ -282,10 +282,10 @@ class URLRequestJob : public base::RefCounted<URLRequestJob>, net::URLRequest* request_; // The status of the job. - const URLRequestStatus GetStatus(); + const net::URLRequestStatus GetStatus(); // Set the status of the job. - void SetStatus(const URLRequestStatus& status); + void SetStatus(const net::URLRequestStatus& status); // Whether the job is doing performance profiling bool is_profiling_; diff --git a/net/url_request/url_request_job_manager.h b/net/url_request/url_request_job_manager.h index a0d3c87..34e3a58 100644 --- a/net/url_request/url_request_job_manager.h +++ b/net/url_request/url_request_job_manager.h @@ -11,7 +11,7 @@ #include <vector> #include "base/lock.h" -#include "base/platform_thread.h" +#include "base/threading/platform_thread.h" #include "net/url_request/url_request.h" template <typename T> struct DefaultSingletonTraits; @@ -84,7 +84,7 @@ class URLRequestJobManager { #ifndef NDEBUG // We use this to assert that CreateJob and the registration functions all // run on the same thread. - mutable PlatformThreadId allowed_thread_; + mutable base::PlatformThreadId allowed_thread_; mutable bool allowed_thread_initialized_; // The first guy to call this function sets the allowed thread. This way we @@ -94,10 +94,10 @@ class URLRequestJobManager { bool IsAllowedThread() const { #if 0 if (!allowed_thread_initialized_) { - allowed_thread_ = PlatformThread::CurrentId(); + allowed_thread_ = base::PlatformThread::CurrentId(); allowed_thread_initialized_ = true; } - return allowed_thread_ == PlatformThread::CurrentId(); + return allowed_thread_ == base::PlatformThread::CurrentId(); #else // The previous version of this check used GetCurrentThread on Windows to // get thread handles to compare. Unfortunately, GetCurrentThread returns diff --git a/net/url_request/url_request_job_metrics.h b/net/url_request/url_request_job_metrics.h index 15bbaf6..6552026 100644 --- a/net/url_request/url_request_job_metrics.h +++ b/net/url_request/url_request_job_metrics.h @@ -23,6 +23,9 @@ class URLRequestJobMetrics { URLRequestJobMetrics(); ~URLRequestJobMetrics(); + // Append the text report of the frame loading to the input string. + void AppendText(std::wstring* text); + // The original url the job has been created for. scoped_ptr<GURL> original_url_; @@ -44,9 +47,6 @@ class URLRequestJobMetrics { // Final status of the job. bool success_; - - // Append the text report of the frame loading to the input string. - void AppendText(std::wstring* text); }; } // namespace net diff --git a/net/url_request/url_request_job_tracker.h b/net/url_request/url_request_job_tracker.h index 4c8ecec..4a03cf7 100644 --- a/net/url_request/url_request_job_tracker.h +++ b/net/url_request/url_request_job_tracker.h @@ -40,7 +40,7 @@ class URLRequestJobTracker { // Called when the given job has completed, before notifying the request virtual void OnJobDone(URLRequestJob* job, - const URLRequestStatus& status) = 0; + const net::URLRequestStatus& status) = 0; // Called when the given job is about to follow a redirect to the given // new URL. The redirect type is given in status_code @@ -77,7 +77,7 @@ class URLRequestJobTracker { void RemoveJob(URLRequestJob* job); // Job status change notifications - void OnJobDone(URLRequestJob* job, const URLRequestStatus& status); + void OnJobDone(URLRequestJob* job, const net::URLRequestStatus& status); void OnJobRedirect(URLRequestJob* job, const GURL& location, int status_code); diff --git a/net/url_request/url_request_status.h b/net/url_request/url_request_status.h index ca376fb..332e7e9 100644 --- a/net/url_request/url_request_status.h +++ b/net/url_request/url_request_status.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. // @@ -9,6 +9,8 @@ #define NET_URL_REQUEST_URL_REQUEST_STATUS_H_ #pragma once +namespace net { + // Represents the result of a URL request. It encodes errors and various // types of success. class URLRequestStatus { @@ -64,4 +66,9 @@ class URLRequestStatus { int os_error_; }; +} // namespace net + +// TODO(tfarina): Fix the callers and remove this! +typedef net::URLRequestStatus URLRequestStatus; + #endif // NET_URL_REQUEST_URL_REQUEST_STATUS_H_ diff --git a/net/url_request/url_request_test_job.cc b/net/url_request/url_request_test_job.cc index 7fd019c..4aa7c16 100644 --- a/net/url_request/url_request_test_job.cc +++ b/net/url_request/url_request_test_job.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -16,7 +16,9 @@ // This emulates the global message loop for the test URL request class, since // this is only test code, it's probably not too dangerous to have this static // object. -static std::vector< scoped_refptr<URLRequestTestJob> > pending_jobs; +static std::vector< scoped_refptr<URLRequestTestJob> > g_pending_jobs; + +namespace net { // static getters for known URLs GURL URLRequestTestJob::test_url_1() { @@ -70,13 +72,13 @@ std::string URLRequestTestJob::test_error_headers() { } // static -net::URLRequestJob* URLRequestTestJob::Factory(net::URLRequest* request, - const std::string& scheme) { +URLRequestJob* URLRequestTestJob::Factory(URLRequest* request, + const std::string& scheme) { return new URLRequestTestJob(request); } -URLRequestTestJob::URLRequestTestJob(net::URLRequest* request) - : net::URLRequestJob(request), +URLRequestTestJob::URLRequestTestJob(URLRequest* request) + : URLRequestJob(request), auto_advance_(false), stage_(WAITING), offset_(0), @@ -84,9 +86,9 @@ URLRequestTestJob::URLRequestTestJob(net::URLRequest* request) async_buf_size_(0) { } -URLRequestTestJob::URLRequestTestJob(net::URLRequest* request, +URLRequestTestJob::URLRequestTestJob(URLRequest* request, bool auto_advance) - : net::URLRequestJob(request), + : URLRequestJob(request), auto_advance_(auto_advance), stage_(WAITING), offset_(0), @@ -94,14 +96,14 @@ URLRequestTestJob::URLRequestTestJob(net::URLRequest* request, async_buf_size_(0) { } -URLRequestTestJob::URLRequestTestJob(net::URLRequest* request, +URLRequestTestJob::URLRequestTestJob(URLRequest* request, const std::string& response_headers, const std::string& response_data, bool auto_advance) - : net::URLRequestJob(request), + : URLRequestJob(request), auto_advance_(auto_advance), stage_(WAITING), - response_headers_(new net::HttpResponseHeaders(response_headers)), + response_headers_(new HttpResponseHeaders(response_headers)), response_data_(response_data), offset_(0), async_buf_(NULL), @@ -127,7 +129,7 @@ void URLRequestTestJob::Start() { void URLRequestTestJob::StartAsync() { if (!response_headers_) { - response_headers_ = new net::HttpResponseHeaders(test_headers()); + response_headers_ = new HttpResponseHeaders(test_headers()); if (request_->url().spec() == test_url_1().spec()) { response_data_ = test_data_1(); stage_ = DATA_AVAILABLE; // Simulate a synchronous response for this one. @@ -140,7 +142,7 @@ void URLRequestTestJob::StartAsync() { // FIXME(brettw) we may want to use WININET errors or have some more types // of errors NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, - net::ERR_INVALID_URL)); + ERR_INVALID_URL)); // FIXME(brettw): this should emulate a network error, and not just fail // initiating a connection return; @@ -152,7 +154,7 @@ void URLRequestTestJob::StartAsync() { this->NotifyHeadersComplete(); } -bool URLRequestTestJob::ReadRawData(net::IOBuffer* buf, int buf_size, +bool URLRequestTestJob::ReadRawData(IOBuffer* buf, int buf_size, int *bytes_read) { if (stage_ == WAITING) { async_buf_ = buf; @@ -179,7 +181,7 @@ bool URLRequestTestJob::ReadRawData(net::IOBuffer* buf, int buf_size, return true; } -void URLRequestTestJob::GetResponseInfo(net::HttpResponseInfo* info) { +void URLRequestTestJob::GetResponseInfo(HttpResponseInfo* info) { if (response_headers_) info->headers = response_headers_; } @@ -207,7 +209,7 @@ bool URLRequestTestJob::IsRedirectResponse(GURL* location, void URLRequestTestJob::Kill() { stage_ = DONE; - net::URLRequestJob::Kill(); + URLRequestJob::Kill(); } void URLRequestTestJob::ProcessNextOperation() { @@ -244,18 +246,20 @@ void URLRequestTestJob::AdvanceJob() { this, &URLRequestTestJob::ProcessNextOperation)); return; } - pending_jobs.push_back(scoped_refptr<URLRequestTestJob>(this)); + g_pending_jobs.push_back(scoped_refptr<URLRequestTestJob>(this)); } // static bool URLRequestTestJob::ProcessOnePendingMessage() { - if (pending_jobs.empty()) + if (g_pending_jobs.empty()) return false; - scoped_refptr<URLRequestTestJob> next_job(pending_jobs[0]); - pending_jobs.erase(pending_jobs.begin()); + scoped_refptr<URLRequestTestJob> next_job(g_pending_jobs[0]); + g_pending_jobs.erase(g_pending_jobs.begin()); DCHECK(!next_job->auto_advance()); // auto_advance jobs should be in this q next_job->ProcessNextOperation(); return true; } + +} // namespace net diff --git a/net/url_request/url_request_test_job.h b/net/url_request/url_request_test_job.h index ec92dc2..252c173 100644 --- a/net/url_request/url_request_test_job.h +++ b/net/url_request/url_request_test_job.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -11,6 +11,8 @@ #include "net/url_request/url_request.h" #include "net/url_request/url_request_job.h" +namespace net { + // This job type is designed to help with simple unit tests. To use, you // probably want to inherit from it to set up the state you want. Then install // it as the protocol handler for the "test" scheme. @@ -33,20 +35,20 @@ // // Optionally, you can also construct test jobs that advance automatically // without having to call ProcessOnePendingMessage. -class URLRequestTestJob : public net::URLRequestJob { +class URLRequestTestJob : public URLRequestJob { public: // Constructs a job to return one of the canned responses depending on the // request url, with auto advance disabled. - explicit URLRequestTestJob(net::URLRequest* request); + explicit URLRequestTestJob(URLRequest* request); // Constructs a job to return one of the canned responses depending on the // request url, optionally with auto advance enabled. - explicit URLRequestTestJob(net::URLRequest* request, bool auto_advance); + explicit URLRequestTestJob(URLRequest* request, bool auto_advance); // Constructs a job to return the given response regardless of the request // url. The headers should include the HTTP status line and be formatted as - // expected by net::HttpResponseHeaders. - explicit URLRequestTestJob(net::URLRequest* request, + // expected by HttpResponseHeaders. + explicit URLRequestTestJob(URLRequest* request, const std::string& response_headers, const std::string& response_data, bool auto_advance); @@ -86,14 +88,14 @@ class URLRequestTestJob : public net::URLRequestJob { void set_auto_advance(bool auto_advance) { auto_advance_ = auto_advance; } // Factory method for protocol factory registration if callers don't subclass - static net::URLRequest::ProtocolFactory Factory; + static URLRequest::ProtocolFactory Factory; // Job functions virtual void Start(); - virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); + virtual bool ReadRawData(IOBuffer* buf, int buf_size, int *bytes_read); virtual void Kill(); virtual bool GetMimeType(std::string* mime_type) const; - virtual void GetResponseInfo(net::HttpResponseInfo* info); + virtual void GetResponseInfo(HttpResponseInfo* info); virtual int GetResponseCode() const; virtual bool IsRedirectResponse(GURL* location, int* http_status_code); @@ -120,7 +122,7 @@ class URLRequestTestJob : public net::URLRequestJob { // The headers the job should return, will be set in Start() if not provided // in the explicit ctor. - scoped_refptr<net::HttpResponseHeaders> response_headers_; + scoped_refptr<HttpResponseHeaders> response_headers_; // The data to send, will be set in Start() if not provided in the explicit // ctor. @@ -130,8 +132,13 @@ class URLRequestTestJob : public net::URLRequestJob { int offset_; // Holds the buffer for an asynchronous ReadRawData call - net::IOBuffer* async_buf_; + IOBuffer* async_buf_; int async_buf_size_; }; +} // namespace net + +// TODO(tfarina): Fix the callers and remove this! +typedef net::URLRequestTestJob URLRequestTestJob; + #endif // NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h index 50236fd..c336b41 100644 --- a/net/url_request/url_request_unittest.h +++ b/net/url_request/url_request_unittest.h @@ -17,7 +17,7 @@ #include "base/process_util.h" #include "base/string_util.h" #include "base/string16.h" -#include "base/thread.h" +#include "base/threading/thread.h" #include "base/time.h" #include "base/utf_string_conversions.h" #include "net/base/cert_verifier.h" @@ -173,6 +173,7 @@ class TestURLRequestContext : public URLRequestContext { http_auth_handler_factory_, network_delegate_, NULL), + NULL /* net_log */, net::HttpCache::DefaultBackend::InMemory(0)); // In-memory cookie store. cookie_store_ = new net::CookieMonster(NULL, NULL); diff --git a/net/url_request/view_cache_helper.h b/net/url_request/view_cache_helper.h index 03af714..1952916 100644 --- a/net/url_request/view_cache_helper.h +++ b/net/url_request/view_cache_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -11,15 +11,15 @@ #include "net/base/completion_callback.h" #include "net/base/io_buffer.h" -class URLRequestContext; - namespace disk_cache { class Backend; class Entry; -} +} // namespace disk_cache namespace net { +class URLRequestContext; + class ViewCacheHelper { public: ViewCacheHelper(); @@ -29,16 +29,20 @@ class ViewCacheHelper { // If this method returns ERR_IO_PENDING, |callback| will be notified when the // operation completes. |out| must remain valid until this operation completes // or the object is destroyed. - int GetEntryInfoHTML(const std::string& key, URLRequestContext* context, - std::string* out, CompletionCallback* callback); + int GetEntryInfoHTML(const std::string& key, + net::URLRequestContext* context, + std::string* out, + CompletionCallback* callback); // Formats the cache contents as HTML. Returns a net error code. // If this method returns ERR_IO_PENDING, |callback| will be notified when the // operation completes. |out| must remain valid until this operation completes // or the object is destroyed. |url_prefix| will be prepended to each entry // key as a link to the entry. - int GetContentsHTML(URLRequestContext* context, const std::string& url_prefix, - std::string* out, CompletionCallback* callback); + int GetContentsHTML(net::URLRequestContext* context, + const std::string& url_prefix, + std::string* out, + CompletionCallback* callback); private: enum State { @@ -56,8 +60,10 @@ class ViewCacheHelper { }; // Implements GetEntryInfoHTML and GetContentsHTML. - int GetInfoHTML(const std::string& key, URLRequestContext* context, - const std::string& url_prefix, std::string* out, + int GetInfoHTML(const std::string& key, + net::URLRequestContext* context, + const std::string& url_prefix, + std::string* out, CompletionCallback* callback); // This is a helper function used to trigger a completion callback. It may @@ -87,7 +93,7 @@ class ViewCacheHelper { // Called to signal completion of asynchronous IO. void OnIOComplete(int result); - scoped_refptr<URLRequestContext> context_; + scoped_refptr<net::URLRequestContext> context_; disk_cache::Backend* disk_cache_; disk_cache::Entry* entry_; void* iter_; diff --git a/net/url_request/view_cache_helper_unittest.cc b/net/url_request/view_cache_helper_unittest.cc index 5338ee5..3903c2b 100644 --- a/net/url_request/view_cache_helper_unittest.cc +++ b/net/url_request/view_cache_helper_unittest.cc @@ -25,7 +25,7 @@ class TestURLRequestContext : public URLRequestContext { }; TestURLRequestContext::TestURLRequestContext() - : cache_(reinterpret_cast<net::HttpTransactionFactory*>(NULL), + : cache_(reinterpret_cast<net::HttpTransactionFactory*>(NULL), NULL, net::HttpCache::DefaultBackend::InMemory(0)) { http_transaction_factory_ = &cache_; } |