| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/url_request/url_request_job.h" | 5 #include "net/url_request/url_request_job.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // SourceStream implementation: | 134 // SourceStream implementation: |
| 135 int Read(IOBuffer* dest_buffer, | 135 int Read(IOBuffer* dest_buffer, |
| 136 int buffer_size, | 136 int buffer_size, |
| 137 const CompletionCallback& callback) override { | 137 const CompletionCallback& callback) override { |
| 138 DCHECK(job_); | 138 DCHECK(job_); |
| 139 return job_->ReadRawDataHelper(dest_buffer, buffer_size, callback); | 139 return job_->ReadRawDataHelper(dest_buffer, buffer_size, callback); |
| 140 } | 140 } |
| 141 | 141 |
| 142 std::string Description() const override { return std::string(); } | 142 std::string Description() const override { return std::string(); } |
| 143 | 143 |
| 144 void DumpMemoryStats( |
| 145 base::trace_event::MemoryAllocatorDump* dump) const override {} |
| 146 |
| 144 private: | 147 private: |
| 145 // It is safe to keep a raw pointer because |job_| owns the last stream which | 148 // It is safe to keep a raw pointer because |job_| owns the last stream which |
| 146 // indirectly owns |this|. Therefore, |job_| will not be destroyed when |this| | 149 // indirectly owns |this|. Therefore, |job_| will not be destroyed when |this| |
| 147 // is alive. | 150 // is alive. |
| 148 URLRequestJob* const job_; | 151 URLRequestJob* const job_; |
| 149 | 152 |
| 150 DISALLOW_COPY_AND_ASSIGN(URLRequestJobSourceStream); | 153 DISALLOW_COPY_AND_ASSIGN(URLRequestJobSourceStream); |
| 151 }; | 154 }; |
| 152 | 155 |
| 153 URLRequestJob::URLRequestJob(URLRequest* request, | 156 URLRequestJob::URLRequestJob(URLRequest* request, |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 request_->Cancel(); | 356 request_->Cancel(); |
| 354 } | 357 } |
| 355 | 358 |
| 356 void URLRequestJob::NotifyURLRequestDestroyed() { | 359 void URLRequestJob::NotifyURLRequestDestroyed() { |
| 357 } | 360 } |
| 358 | 361 |
| 359 void URLRequestJob::GetConnectionAttempts(ConnectionAttempts* out) const { | 362 void URLRequestJob::GetConnectionAttempts(ConnectionAttempts* out) const { |
| 360 out->clear(); | 363 out->clear(); |
| 361 } | 364 } |
| 362 | 365 |
| 366 void URLRequestJob::DumpMemoryStats( |
| 367 base::trace_event::MemoryAllocatorDump* dump) const { |
| 368 if (source_stream_) |
| 369 source_stream_->DumpMemoryStats(dump); |
| 370 } |
| 371 |
| 363 // static | 372 // static |
| 364 GURL URLRequestJob::ComputeReferrerForRedirect( | 373 GURL URLRequestJob::ComputeReferrerForRedirect( |
| 365 URLRequest::ReferrerPolicy policy, | 374 URLRequest::ReferrerPolicy policy, |
| 366 const GURL& original_referrer, | 375 const GURL& original_referrer, |
| 367 const GURL& redirect_destination) { | 376 const GURL& redirect_destination) { |
| 368 bool secure_referrer_but_insecure_destination = | 377 bool secure_referrer_but_insecure_destination = |
| 369 original_referrer.SchemeIsCryptographic() && | 378 original_referrer.SchemeIsCryptographic() && |
| 370 !redirect_destination.SchemeIsCryptographic(); | 379 !redirect_destination.SchemeIsCryptographic(); |
| 371 url::Origin referrer_origin(original_referrer); | 380 url::Origin referrer_origin(original_referrer); |
| 372 bool same_origin = | 381 bool same_origin = |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 int64_t total_sent_bytes = GetTotalSentBytes(); | 851 int64_t total_sent_bytes = GetTotalSentBytes(); |
| 843 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_); | 852 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_); |
| 844 if (total_sent_bytes > last_notified_total_sent_bytes_) { | 853 if (total_sent_bytes > last_notified_total_sent_bytes_) { |
| 845 network_delegate_->NotifyNetworkBytesSent( | 854 network_delegate_->NotifyNetworkBytesSent( |
| 846 request_, total_sent_bytes - last_notified_total_sent_bytes_); | 855 request_, total_sent_bytes - last_notified_total_sent_bytes_); |
| 847 } | 856 } |
| 848 last_notified_total_sent_bytes_ = total_sent_bytes; | 857 last_notified_total_sent_bytes_ = total_sent_bytes; |
| 849 } | 858 } |
| 850 | 859 |
| 851 } // namespace net | 860 } // namespace net |
| OLD | NEW |