| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "net/url_request/url_request_job_tracker.h" | 7 #include "net/url_request/url_request_job_tracker.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "net/url_request/url_request_job.h" | 10 #include "net/url_request/url_request_job.h" |
| 11 | 11 |
| 12 URLRequestJobTracker g_url_request_job_tracker; | 12 URLRequestJobTracker g_url_request_job_tracker; |
| 13 | 13 |
| 14 URLRequestJobTracker::URLRequestJobTracker() { | 14 URLRequestJobTracker::URLRequestJobTracker() { |
| 15 } | 15 } |
| 16 | 16 |
| 17 URLRequestJobTracker::~URLRequestJobTracker() { | 17 URLRequestJobTracker::~URLRequestJobTracker() { |
| 18 DLOG_IF(WARNING, active_jobs_.size() != 0) << | 18 DLOG_IF(WARNING, active_jobs_.size() != 0) << |
| 19 "Leaking " << active_jobs_.size() << " URLRequestJob object(s), this could " | 19 "Leaking " << active_jobs_.size() << " URLRequestJob object(s), this could " |
| 20 "be because the URLRequest forgot to free it (bad), or if the program was " | 20 "be because the net::URLRequest forgot to free it (bad), or if the program " |
| 21 "terminated while a request was active (normal)."; | 21 "was terminated while a request was active (normal)."; |
| 22 } | 22 } |
| 23 | 23 |
| 24 void URLRequestJobTracker::AddNewJob(URLRequestJob* job) { | 24 void URLRequestJobTracker::AddNewJob(URLRequestJob* job) { |
| 25 active_jobs_.push_back(job); | 25 active_jobs_.push_back(job); |
| 26 FOR_EACH_OBSERVER(JobObserver, observers_, OnJobAdded(job)); | 26 FOR_EACH_OBSERVER(JobObserver, observers_, OnJobAdded(job)); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void URLRequestJobTracker::RemoveJob(URLRequestJob* job) { | 29 void URLRequestJobTracker::RemoveJob(URLRequestJob* job) { |
| 30 JobList::iterator iter = std::find(active_jobs_.begin(), active_jobs_.end(), | 30 JobList::iterator iter = std::find(active_jobs_.begin(), active_jobs_.end(), |
| 31 job); | 31 job); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 49 FOR_EACH_OBSERVER(JobObserver, observers_, | 49 FOR_EACH_OBSERVER(JobObserver, observers_, |
| 50 OnJobRedirect(job, location, status_code)); | 50 OnJobRedirect(job, location, status_code)); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void URLRequestJobTracker::OnBytesRead(URLRequestJob* job, | 53 void URLRequestJobTracker::OnBytesRead(URLRequestJob* job, |
| 54 const char* buf, | 54 const char* buf, |
| 55 int byte_count) { | 55 int byte_count) { |
| 56 FOR_EACH_OBSERVER(JobObserver, observers_, | 56 FOR_EACH_OBSERVER(JobObserver, observers_, |
| 57 OnBytesRead(job, buf, byte_count)); | 57 OnBytesRead(job, buf, byte_count)); |
| 58 } | 58 } |
| OLD | NEW |