OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/extension_protocols.h" | 5 #include "extensions/browser/extension_protocols.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 base::Owned(last_modified_time))); | 212 base::Owned(last_modified_time))); |
213 DCHECK(posted); | 213 DCHECK(posted); |
214 } | 214 } |
215 | 215 |
216 virtual void SetExtraRequestHeaders( | 216 virtual void SetExtraRequestHeaders( |
217 const net::HttpRequestHeaders& headers) OVERRIDE { | 217 const net::HttpRequestHeaders& headers) OVERRIDE { |
218 // TODO(asargent) - we'll need to add proper support for range headers. | 218 // TODO(asargent) - we'll need to add proper support for range headers. |
219 // crbug.com/369895. | 219 // crbug.com/369895. |
220 std::string range_header; | 220 std::string range_header; |
221 if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) { | 221 if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) { |
222 if (verify_job_) | 222 if (verify_job_.get()) |
223 verify_job_ = NULL; | 223 verify_job_ = NULL; |
224 } | 224 } |
225 URLRequestFileJob::SetExtraRequestHeaders(headers); | 225 URLRequestFileJob::SetExtraRequestHeaders(headers); |
226 } | 226 } |
227 | 227 |
228 virtual void OnSeekComplete(int64 result) OVERRIDE { | 228 virtual void OnSeekComplete(int64 result) OVERRIDE { |
229 DCHECK_EQ(seek_position_, 0); | 229 DCHECK_EQ(seek_position_, 0); |
230 seek_position_ = result; | 230 seek_position_ = result; |
231 // TODO(asargent) - we'll need to add proper support for range headers. | 231 // TODO(asargent) - we'll need to add proper support for range headers. |
232 // crbug.com/369895. | 232 // crbug.com/369895. |
233 if (result > 0 && verify_job_) | 233 if (result > 0 && verify_job_.get()) |
234 verify_job_ = NULL; | 234 verify_job_ = NULL; |
235 } | 235 } |
236 | 236 |
237 virtual void OnReadComplete(net::IOBuffer* buffer, int result) OVERRIDE { | 237 virtual void OnReadComplete(net::IOBuffer* buffer, int result) OVERRIDE { |
238 if (result >= 0) | 238 if (result >= 0) |
239 UMA_HISTOGRAM_COUNTS("ExtensionUrlRequest.OnReadCompleteResult", result); | 239 UMA_HISTOGRAM_COUNTS("ExtensionUrlRequest.OnReadCompleteResult", result); |
240 else | 240 else |
241 UMA_HISTOGRAM_SPARSE_SLOWLY("ExtensionUrlRequest.OnReadCompleteError", | 241 UMA_HISTOGRAM_SPARSE_SLOWLY("ExtensionUrlRequest.OnReadCompleteError", |
242 -result); | 242 -result); |
243 if (result > 0) { | 243 if (result > 0) { |
244 bytes_read_ += result; | 244 bytes_read_ += result; |
245 if (verify_job_) { | 245 if (verify_job_.get()) { |
246 verify_job_->BytesRead(result, buffer->data()); | 246 verify_job_->BytesRead(result, buffer->data()); |
247 if (!remaining_bytes()) | 247 if (!remaining_bytes()) |
248 verify_job_->DoneReading(); | 248 verify_job_->DoneReading(); |
249 } | 249 } |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 private: | 253 private: |
254 virtual ~URLRequestExtensionJob() { | 254 virtual ~URLRequestExtensionJob() { |
255 UMA_HISTOGRAM_COUNTS("ExtensionUrlRequest.TotalKbRead", bytes_read_ / 1024); | 255 UMA_HISTOGRAM_COUNTS("ExtensionUrlRequest.TotalKbRead", bytes_read_ / 1024); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 return new net::HttpResponseHeaders(raw_headers); | 568 return new net::HttpResponseHeaders(raw_headers); |
569 } | 569 } |
570 | 570 |
571 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( | 571 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
572 bool is_incognito, | 572 bool is_incognito, |
573 extensions::InfoMap* extension_info_map) { | 573 extensions::InfoMap* extension_info_map) { |
574 return new ExtensionProtocolHandler(is_incognito, extension_info_map); | 574 return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
575 } | 575 } |
576 | 576 |
577 } // namespace extensions | 577 } // namespace extensions |
OLD | NEW |