Cast: Skip receiver log messages with time delta that can't be encoded.
[chromium-blink-merge.git] / content / browser / service_worker / service_worker_url_request_job.cc
blob19266f71adb0515d4f47db431265eb46ee906491
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
3 // found in the LICENSE file.
5 #include "content/browser/service_worker/service_worker_url_request_job.h"
7 #include "net/http/http_request_headers.h"
8 #include "net/http/http_response_headers.h"
9 #include "net/http/http_response_info.h"
10 #include "net/http/http_util.h"
12 namespace content {
14 ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob(
15 net::URLRequest* request,
16 net::NetworkDelegate* network_delegate)
17 : net::URLRequestJob(request, network_delegate),
18 weak_factory_(this) {
21 void ServiceWorkerURLRequestJob::Start() {
22 NOTIMPLEMENTED();
25 void ServiceWorkerURLRequestJob::Kill() {
26 net::URLRequestJob::Kill();
27 weak_factory_.InvalidateWeakPtrs();
30 net::LoadState ServiceWorkerURLRequestJob::GetLoadState() const {
31 // TODO(kinuko): refine this for better debug.
32 return net::URLRequestJob::GetLoadState();
35 bool ServiceWorkerURLRequestJob::GetCharset(std::string* charset) {
36 if (!http_info())
37 return false;
38 return http_info()->headers->GetCharset(charset);
41 bool ServiceWorkerURLRequestJob::GetMimeType(std::string* mime_type) const {
42 if (!http_info())
43 return false;
44 return http_info()->headers->GetMimeType(mime_type);
47 void ServiceWorkerURLRequestJob::GetResponseInfo(net::HttpResponseInfo* info) {
48 if (!http_info())
49 return;
50 *info = *http_info();
53 int ServiceWorkerURLRequestJob::GetResponseCode() const {
54 if (!http_info())
55 return -1;
56 return http_info()->headers->response_code();
59 void ServiceWorkerURLRequestJob::SetExtraRequestHeaders(
60 const net::HttpRequestHeaders& headers) {
61 std::string range_header;
62 std::vector<net::HttpByteRange> ranges;
63 if (!headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header) ||
64 !net::HttpUtil::ParseRangeHeader(range_header, &ranges)) {
65 return;
68 // We don't support multiple range requests in one single URL request.
69 if (ranges.size() == 1U)
70 byte_range_ = ranges[0];
73 bool ServiceWorkerURLRequestJob::ReadRawData(
74 net::IOBuffer* buf, int buf_size, int *bytes_read) {
75 NOTIMPLEMENTED();
76 *bytes_read = 0;
77 return true;
80 const net::HttpResponseInfo* ServiceWorkerURLRequestJob::http_info() const {
81 if (!http_response_info_)
82 return NULL;
83 if (range_response_info_)
84 return range_response_info_.get();
85 return http_response_info_.get();
88 ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() {
91 } // namespace content