Lines Matching defs:job
100 void set_job(Job* job) {
101 DCHECK(job != NULL);
102 // Identify which job the request is waiting on.
103 job_ = job;
116 Job* job() const {
141 // The resolve job (running in worker pool) that this request is dependent on.
142 Job* job_;
185 class HostResolverImpl::Job
186 : public base::RefCountedThreadSafe<HostResolverImpl::Job> {
188 Job(int id, HostResolverImpl* resolver, const Key& key,
198 "Created job j%d for {hostname='%s', address_family=%d}",
204 // Attaches a request to this job. The job takes ownership of |req| and will
209 "Attached request r%d to job j%d", req->id(), id_));
219 requests_trace_->Add(StringPrintf("Starting job j%d", id_));
221 // Dispatch the job to a worker thread.
223 NewRunnableMethod(this, &Job::DoLookup), true)) {
231 FROM_HERE, NewRunnableMethod(this, &Job::OnLookupComplete));
235 // Cancels the current job. Callable from origin thread.
241 requests_trace_->Add(StringPrintf("Cancelled job j%d", id_));
243 // Mark the job as cancelled, so when worker thread completes it will
275 // Returns the first request attached to the job.
283 friend class base::RefCountedThreadSafe<HostResolverImpl::Job>;
285 ~Job() {
286 // Free the requests attached to this job.
293 "[resolver thread] Running job j%d", id_));
304 "[resolver thread] Completed job j%d", id_));
307 Task* reply = NewRunnableMethod(this, &Job::OnLookupComplete);
332 requests_trace_->Add(StringPrintf("Completing job j%d", id_));
354 RequestsList requests_; // The requests waiting on this job.
373 DISALLOW_COPY_AND_ASSIGN(Job);
411 // A pending request is one waiting to be attached to a job.
474 // Keeps track of a job that was just added/removed, and belongs to this pool.
480 // Returns true if a new job can be created for this pool.
486 // same hostname/address-family as |job|, and attaches them to |job|.
487 void MoveRequestsToJob(Job* job) {
494 if (req_key == job->key()) {
495 // Job takes ownership of |req|.
496 job->AddRequest(req);
516 // The maximum number of requests we allow to be waiting on a job,
565 // Delete the job pools.
634 // Next we need to attach our request to a "job". This job is responsible for
636 scoped_refptr<Job> job;
638 // If there is already an outstanding job to resolve |key|, use
640 job = FindOutstandingJob(key);
641 if (job) {
642 job->AddRequest(req);
652 // Completion happens during OnJobComplete(Job*).
656 // See OnJobComplete(Job*) for why it is important not to clean out
657 // cancelled requests from Job::requests_.
672 if (!req->job()) {
673 // If the request was not attached to a job yet, it must have been
675 // Otherwise if it was attached to a job, the job is responsible for
756 void HostResolverImpl::AddOutstandingJob(Job* job) {
757 scoped_refptr<Job>& found_job = jobs_[job->key()];
759 found_job = job;
761 JobPool* pool = GetPoolForRequest(job->initial_request());
765 HostResolverImpl::Job* HostResolverImpl::FindOutstandingJob(const Key& key) {
772 void HostResolverImpl::RemoveOutstandingJob(Job* job) {
773 JobMap::iterator it = jobs_.find(job->key());
775 DCHECK_EQ(it->second.get(), job);
778 JobPool* pool = GetPoolForRequest(job->initial_request());
782 void HostResolverImpl::OnJobComplete(Job* job,
785 RemoveOutstandingJob(job);
789 cache_->Set(job->key(), error, addrlist, base::TimeTicks::Now());
794 cur_completing_job_ = job;
796 // Try to start any queued requests now that a job-slot has freed up.
799 // Complete all of the requests that were attached to the job.
800 for (RequestsList::const_iterator it = job->requests().begin();
801 it != job->requests().end(); ++it) {
804 DCHECK_EQ(job, req->job());
811 // Check if the job was cancelled as a result of running the callback.
813 if (job->was_cancelled())
921 // We can't create another job if it would exceed the global total.
943 scoped_refptr<Job> job = CreateAndStartJob(top_req);
945 // Search for any other pending request which can piggy-back off this job.
948 pool->MoveRequestsToJob(job);
952 HostResolverImpl::Job* HostResolverImpl::CreateAndStartJob(Request* req) {
955 scoped_refptr<Job> job = new Job(next_job_id_++, this, key, requests_trace_);
956 job->AddRequest(req);
957 AddOutstandingJob(job);
958 job->Start();
959 return job.get();