diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-20 02:04:38 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-20 02:04:38 +0000 |
commit | 488473f8ffd7cac62b4cd01bcda787a5ff88ab22 (patch) | |
tree | 13c9184f843fc2894415fb8d4f1a299421d70de2 /net/url_request | |
parent | 199b9fecc3564e005560f0853e8654ba377ec376 (diff) | |
download | chromium_src-488473f8ffd7cac62b4cd01bcda787a5ff88ab22.zip chromium_src-488473f8ffd7cac62b4cd01bcda787a5ff88ab22.tar.gz chromium_src-488473f8ffd7cac62b4cd01bcda787a5ff88ab22.tar.bz2 |
net: Add namespace net to more files. Part 2.
BUG=64263
TEST=compiled locally and trybots
Review URL: http://codereview.chromium.org/5980003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69689 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request')
-rw-r--r-- | net/url_request/url_request_job_tracker.cc | 22 | ||||
-rw-r--r-- | net/url_request/url_request_job_tracker.h | 35 | ||||
-rw-r--r-- | net/url_request/url_request_job_tracker_unittest.cc | 6 | ||||
-rw-r--r-- | net/url_request/url_request_redirect_job.cc | 18 | ||||
-rw-r--r-- | net/url_request/url_request_redirect_job.h | 10 |
5 files changed, 52 insertions, 39 deletions
diff --git a/net/url_request/url_request_job_tracker.cc b/net/url_request/url_request_job_tracker.cc index 3a8b6a1..49472d9 100644 --- a/net/url_request/url_request_job_tracker.cc +++ b/net/url_request/url_request_job_tracker.cc @@ -2,13 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <algorithm> - #include "net/url_request/url_request_job_tracker.h" +#include <algorithm> + #include "base/logging.h" #include "net/url_request/url_request_job.h" +namespace net { + URLRequestJobTracker g_url_request_job_tracker; URLRequestJobTracker::URLRequestJobTracker() { @@ -16,17 +18,17 @@ URLRequestJobTracker::URLRequestJobTracker() { URLRequestJobTracker::~URLRequestJobTracker() { DLOG_IF(WARNING, active_jobs_.size() != 0) << - "Leaking " << active_jobs_.size() << " net::URLRequestJob object(s), this " - "could be because the net::URLRequest forgot to free it (bad), or if the " + "Leaking " << active_jobs_.size() << " URLRequestJob object(s), this " + "could be because the URLRequest forgot to free it (bad), or if the " "program was terminated while a request was active (normal)."; } -void URLRequestJobTracker::AddNewJob(net::URLRequestJob* job) { +void URLRequestJobTracker::AddNewJob(URLRequestJob* job) { active_jobs_.push_back(job); FOR_EACH_OBSERVER(JobObserver, observers_, OnJobAdded(job)); } -void URLRequestJobTracker::RemoveJob(net::URLRequestJob* job) { +void URLRequestJobTracker::RemoveJob(URLRequestJob* job) { JobList::iterator iter = std::find(active_jobs_.begin(), active_jobs_.end(), job); if (iter == active_jobs_.end()) { @@ -38,21 +40,23 @@ void URLRequestJobTracker::RemoveJob(net::URLRequestJob* job) { FOR_EACH_OBSERVER(JobObserver, observers_, OnJobRemoved(job)); } -void URLRequestJobTracker::OnJobDone(net::URLRequestJob* job, +void URLRequestJobTracker::OnJobDone(URLRequestJob* job, const URLRequestStatus& status) { FOR_EACH_OBSERVER(JobObserver, observers_, OnJobDone(job, status)); } -void URLRequestJobTracker::OnJobRedirect(net::URLRequestJob* job, +void URLRequestJobTracker::OnJobRedirect(URLRequestJob* job, const GURL& location, int status_code) { FOR_EACH_OBSERVER(JobObserver, observers_, OnJobRedirect(job, location, status_code)); } -void URLRequestJobTracker::OnBytesRead(net::URLRequestJob* job, +void URLRequestJobTracker::OnBytesRead(URLRequestJob* job, const char* buf, int byte_count) { FOR_EACH_OBSERVER(JobObserver, observers_, OnBytesRead(job, buf, byte_count)); } + +} // namespace net diff --git a/net/url_request/url_request_job_tracker.h b/net/url_request/url_request_job_tracker.h index 560a0b1..4c8ecec 100644 --- a/net/url_request/url_request_job_tracker.h +++ b/net/url_request/url_request_job_tracker.h @@ -11,41 +11,40 @@ #include "base/observer_list.h" #include "net/url_request/url_request_status.h" +class GURL; + namespace net { class URLRequestJob; -} // namespace net - -class GURL; // This class maintains a list of active URLRequestJobs for debugging purposes. // This allows us to warn on leaked jobs and also allows an observer to track // what is happening, for example, for the network status monitor. // -// NOTE: net::URLRequest is single-threaded, so this class should only be used -// onthe same thread where all of the application's net::URLRequest calls are +// NOTE: URLRequest is single-threaded, so this class should only be used +// onthe same thread where all of the application's URLRequest calls are // made. // class URLRequestJobTracker { public: - typedef std::vector<net::URLRequestJob*> JobList; + typedef std::vector<URLRequestJob*> JobList; typedef JobList::const_iterator JobIterator; // The observer's methods are called on the thread that called AddObserver. class JobObserver { public: // Called after the given job has been added to the list - virtual void OnJobAdded(net::URLRequestJob* job) = 0; + virtual void OnJobAdded(URLRequestJob* job) = 0; // Called after the given job has been removed from the list - virtual void OnJobRemoved(net::URLRequestJob* job) = 0; + virtual void OnJobRemoved(URLRequestJob* job) = 0; // Called when the given job has completed, before notifying the request - virtual void OnJobDone(net::URLRequestJob* job, + virtual void OnJobDone(URLRequestJob* job, const 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 - virtual void OnJobRedirect(net::URLRequestJob* job, const GURL& location, + virtual void OnJobRedirect(URLRequestJob* job, const GURL& location, int status_code) = 0; // Called when a new chunk of unfiltered bytes has been read for @@ -53,7 +52,7 @@ class URLRequestJobTracker { // read event only. |buf| is a pointer to the data buffer that // contains those bytes. The data in |buf| is only valid for the // duration of the OnBytesRead callback. - virtual void OnBytesRead(net::URLRequestJob* job, const char* buf, + virtual void OnBytesRead(URLRequestJob* job, const char* buf, int byte_count) = 0; virtual ~JobObserver() {} @@ -63,7 +62,7 @@ class URLRequestJobTracker { ~URLRequestJobTracker(); // adds or removes an observer from the list. note, these methods should - // only be called on the same thread where net::URLRequest objects are used. + // only be called on the same thread where URLRequest objects are used. void AddObserver(JobObserver* observer) { observers_.AddObserver(observer); } @@ -74,16 +73,16 @@ class URLRequestJobTracker { // adds or removes the job from the active list, should be called by the // job constructor and destructor. Note: don't use "AddJob" since that // is #defined by windows.h :( - void AddNewJob(net::URLRequestJob* job); - void RemoveJob(net::URLRequestJob* job); + void AddNewJob(URLRequestJob* job); + void RemoveJob(URLRequestJob* job); // Job status change notifications - void OnJobDone(net::URLRequestJob* job, const URLRequestStatus& status); - void OnJobRedirect(net::URLRequestJob* job, const GURL& location, + void OnJobDone(URLRequestJob* job, const URLRequestStatus& status); + void OnJobRedirect(URLRequestJob* job, const GURL& location, int status_code); // Bytes read notifications. - void OnBytesRead(net::URLRequestJob* job, const char* buf, int byte_count); + void OnBytesRead(URLRequestJob* job, const char* buf, int byte_count); // allows iteration over all active jobs JobIterator begin() const { @@ -100,4 +99,6 @@ class URLRequestJobTracker { extern URLRequestJobTracker g_url_request_job_tracker; +} // namespace net + #endif // NET_URL_REQUEST_URL_REQUEST_JOB_TRACKER_H_ diff --git a/net/url_request/url_request_job_tracker_unittest.cc b/net/url_request/url_request_job_tracker_unittest.cc index fb257e7..bd62ef7 100644 --- a/net/url_request/url_request_job_tracker_unittest.cc +++ b/net/url_request/url_request_job_tracker_unittest.cc @@ -49,7 +49,7 @@ bool GetResponseBody(const GURL& url, std::string* out_body) { return true; } -class MockJobObserver : public URLRequestJobTracker::JobObserver { +class MockJobObserver : public net::URLRequestJobTracker::JobObserver { public: MOCK_METHOD1(OnJobAdded, void(net::URLRequestJob* job)); MOCK_METHOD1(OnJobRemoved, void(net::URLRequestJob* job)); @@ -176,9 +176,9 @@ class URLRequestJobTrackerTest : public PlatformTest { EXPECT_CALL(observer, OnJobRemoved(NotNull())); // Attach our observer and perform the resource fetch. - g_url_request_job_tracker.AddObserver(&observer); + net::g_url_request_job_tracker.AddObserver(&observer); Fetch(gurl); - g_url_request_job_tracker.RemoveObserver(&observer); + net::g_url_request_job_tracker.RemoveObserver(&observer); } void Fetch(const GURL& url) { diff --git a/net/url_request/url_request_redirect_job.cc b/net/url_request/url_request_redirect_job.cc index a6cd025..9c5605a 100644 --- a/net/url_request/url_request_redirect_job.cc +++ b/net/url_request/url_request_redirect_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. @@ -6,9 +6,11 @@ #include "base/message_loop.h" -URLRequestRedirectJob::URLRequestRedirectJob(net::URLRequest* request, +namespace net { + +URLRequestRedirectJob::URLRequestRedirectJob(URLRequest* request, GURL redirect_destination) - : net::URLRequestJob(request), redirect_destination_(redirect_destination) { + : URLRequestJob(request), redirect_destination_(redirect_destination) { } void URLRequestRedirectJob::Start() { @@ -16,10 +18,6 @@ void URLRequestRedirectJob::Start() { this, &URLRequestRedirectJob::StartAsync)); } -void URLRequestRedirectJob::StartAsync() { - NotifyHeadersComplete(); -} - bool URLRequestRedirectJob::IsRedirectResponse(GURL* location, int* http_status_code) { *location = redirect_destination_; @@ -28,3 +26,9 @@ bool URLRequestRedirectJob::IsRedirectResponse(GURL* location, } URLRequestRedirectJob::~URLRequestRedirectJob() {} + +void URLRequestRedirectJob::StartAsync() { + NotifyHeadersComplete(); +} + +} // namespace net diff --git a/net/url_request/url_request_redirect_job.h b/net/url_request/url_request_redirect_job.h index 4a7f9a7..425c70b 100644 --- a/net/url_request/url_request_redirect_job.h +++ b/net/url_request/url_request_redirect_job.h @@ -10,13 +10,15 @@ class GURL; -// A net::URLRequestJob that will redirect the request to the specified +namespace net { + +// A URLRequestJob that will redirect the request to the specified // URL. This is useful to restart a request at a different URL based // on the result of another job. -class URLRequestRedirectJob : public net::URLRequestJob { +class URLRequestRedirectJob : public URLRequestJob { public: // Constructs a job that redirects to the specified URL. - URLRequestRedirectJob(net::URLRequest* request, GURL redirect_destination); + URLRequestRedirectJob(URLRequest* request, GURL redirect_destination); virtual void Start(); virtual bool IsRedirectResponse(GURL* location, int* http_status_code); @@ -29,4 +31,6 @@ class URLRequestRedirectJob : public net::URLRequestJob { GURL redirect_destination_; }; +} // namespace net + #endif // NET_URL_REQUEST_URL_REQUEST_REDIRECT_JOB_H_ |