diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-08 19:26:06 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-08 19:26:06 +0000 |
commit | 2ab7450ff7c19209d86d8d3ac6641b0305acae43 (patch) | |
tree | 589265c44754de9b462dbe7e244c6f2f207f10b9 /content/browser/net | |
parent | 5a395b78e1c2dfaefd123d5d638ec8d16cf4356e (diff) | |
download | chromium_src-2ab7450ff7c19209d86d8d3ac6641b0305acae43.zip chromium_src-2ab7450ff7c19209d86d8d3ac6641b0305acae43.tar.gz chromium_src-2ab7450ff7c19209d86d8d3ac6641b0305acae43.tar.bz2 |
Delete url_request_mock_net_error_job.*.
As far as I can tell this code is unreferenced in the Chrome tree,
and dates back to the initial commit.
Review URL: http://codereview.chromium.org/7491100
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95854 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/net')
-rw-r--r-- | content/browser/net/url_request_mock_net_error_job.cc | 124 | ||||
-rw-r--r-- | content/browser/net/url_request_mock_net_error_job.h | 62 |
2 files changed, 0 insertions, 186 deletions
diff --git a/content/browser/net/url_request_mock_net_error_job.cc b/content/browser/net/url_request_mock_net_error_job.cc deleted file mode 100644 index 7dd475d..0000000 --- a/content/browser/net/url_request_mock_net_error_job.cc +++ /dev/null @@ -1,124 +0,0 @@ -// 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. - -#include "content/browser/net/url_request_mock_net_error_job.h" - -#include <string> -#include <vector> - -#include "base/compiler_specific.h" -#include "base/file_util.h" -#include "base/message_loop.h" -#include "base/task.h" -#include "base/utf_string_conversions.h" -#include "net/base/net_errors.h" -#include "net/base/net_util.h" -#include "net/base/x509_certificate.h" -#include "net/url_request/url_request_filter.h" - -// static -URLRequestMockNetErrorJob::URLMockInfoMap - URLRequestMockNetErrorJob::url_mock_info_map_; - -struct URLRequestMockNetErrorJob::MockInfo { - MockInfo() : ssl_cert(NULL) { } - MockInfo(std::wstring base, - std::vector<int> errors, - net::X509Certificate* ssl_cert) - : base(base), - errors(errors), - ssl_cert(ssl_cert) { } - - std::wstring base; - std::vector<int> errors; - scoped_refptr<net::X509Certificate> ssl_cert; -}; - -// static -void URLRequestMockNetErrorJob::AddMockedURL(const GURL& url, - const std::wstring& base, - const std::vector<int>& errors, - net::X509Certificate* ssl_cert) { -#ifndef NDEBUG - URLMockInfoMap::const_iterator iter = url_mock_info_map_.find(url); - DCHECK(iter == url_mock_info_map_.end()); -#endif - - url_mock_info_map_[url] = MockInfo(base, errors, ssl_cert); - net::URLRequestFilter::GetInstance() - ->AddUrlHandler(url, &URLRequestMockNetErrorJob::Factory); -} - -// static -void URLRequestMockNetErrorJob::RemoveMockedURL(const GURL& url) { - URLMockInfoMap::iterator iter = url_mock_info_map_.find(url); - DCHECK(iter != url_mock_info_map_.end()); - url_mock_info_map_.erase(iter); - net::URLRequestFilter::GetInstance()->RemoveUrlHandler(url); -} - -// static -net::URLRequestJob* URLRequestMockNetErrorJob::Factory( - net::URLRequest* request, - const std::string& scheme) { - GURL url = request->url(); - - URLMockInfoMap::const_iterator iter = url_mock_info_map_.find(url); - DCHECK(iter != url_mock_info_map_.end()); - - MockInfo mock_info = iter->second; - - // URLRequestMockNetErrorJob derives from net::URLRequestFileJob. We pass a - // FilePath so that the net::URLRequestFileJob methods will do the loading - // from the files. - std::wstring file_url(L"file:///"); - file_url.append(mock_info.base); - file_url.append(UTF8ToWide(url.path())); - // Convert the file:/// URL to a path on disk. - FilePath file_path; - net::FileURLToFilePath(GURL(WideToUTF8(file_url)), &file_path); - return new URLRequestMockNetErrorJob(request, mock_info.errors, - mock_info.ssl_cert, - file_path); -} - -URLRequestMockNetErrorJob::URLRequestMockNetErrorJob(net::URLRequest* request, - const std::vector<int>& errors, net::X509Certificate* cert, - const FilePath& file_path) - : URLRequestMockHTTPJob(request, file_path), - errors_(errors), - ssl_cert_(cert), - ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { -} - -URLRequestMockNetErrorJob::~URLRequestMockNetErrorJob() { -} - -void URLRequestMockNetErrorJob::Start() { - MessageLoop::current()->PostTask( - FROM_HERE, - method_factory_.NewRunnableMethod( - &URLRequestMockNetErrorJob::StartAsync)); -} - -void URLRequestMockNetErrorJob::StartAsync() { - if (errors_.empty()) { - URLRequestMockHTTPJob::Start(); - } else { - int error = errors_[0]; - errors_.erase(errors_.begin()); - - if (net::IsCertificateError(error)) { - DCHECK(ssl_cert_); - NotifySSLCertificateError(error, ssl_cert_.get()); - } else { - NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED, - error)); - } - } -} - -void URLRequestMockNetErrorJob::ContinueDespiteLastError() { - Start(); -} diff --git a/content/browser/net/url_request_mock_net_error_job.h b/content/browser/net/url_request_mock_net_error_job.h deleted file mode 100644 index e0ba914..0000000 --- a/content/browser/net/url_request_mock_net_error_job.h +++ /dev/null @@ -1,62 +0,0 @@ -// 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. - -// A net::URLRequestJob class that simulates network errors (including https -// related). -// It is based on URLRequestMockHttpJob. - -#ifndef CONTENT_BROWSER_NET_URL_REQUEST_MOCK_NET_ERROR_JOB_H_ -#define CONTENT_BROWSER_NET_URL_REQUEST_MOCK_NET_ERROR_JOB_H_ -#pragma once - -#include "base/task.h" -#include "content/browser/net/url_request_mock_http_job.h" - -class URLRequestMockNetErrorJob : public URLRequestMockHTTPJob { - public: - URLRequestMockNetErrorJob(net::URLRequest* request, - const std::vector<int>& errors, - net::X509Certificate* ssl_cert, - const FilePath& file_path); - - virtual void Start(); - virtual void ContinueDespiteLastError(); - - // Add the specified URL to the list of URLs that should be mocked. When this - // URL is hit, the specified |errors| will be played. If any of these errors - // is a cert error, |ssl_cert| will be used as the ssl cert when notifying of - // the error. |ssl_cert| can be NULL if |errors| does not contain any cert - // errors. |base| is the location on disk where the file mocking the URL - // contents and http-headers should be retrieved from. - static void AddMockedURL(const GURL& url, - const std::wstring& base, - const std::vector<int>& errors, - net::X509Certificate* ssl_cert); - - // Removes the specified |url| from the list of mocked urls. - static void RemoveMockedURL(const GURL& url); - - private: - virtual ~URLRequestMockNetErrorJob(); - - static net::URLRequest::ProtocolFactory Factory; - - void StartAsync(); - - // The errors to simulate. - std::vector<int> errors_; - - // The certificate to use for SSL errors. - scoped_refptr<net::X509Certificate> ssl_cert_; - - struct MockInfo; - typedef std::map<GURL, MockInfo> URLMockInfoMap; - static URLMockInfoMap url_mock_info_map_; - - ScopedRunnableMethodFactory<URLRequestMockNetErrorJob> method_factory_; - - DISALLOW_COPY_AND_ASSIGN(URLRequestMockNetErrorJob); -}; - -#endif // CONTENT_BROWSER_NET_URL_REQUEST_MOCK_NET_ERROR_JOB_H_ |