diff options
Diffstat (limited to 'net/url_request/url_request_test_job.cc')
-rw-r--r-- | net/url_request/url_request_test_job.cc | 44 |
1 files changed, 24 insertions, 20 deletions
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 |