| 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 "content/browser/service_worker/service_worker_cache.h" | 5 #include "content/browser/service_worker/service_worker_cache.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 const BoolCallback& callback) { | 108 const BoolCallback& callback) { |
| 109 callback_ = callback; | 109 callback_ = callback; |
| 110 blob_request_ = storage::BlobProtocolHandler::CreateBlobRequest( | 110 blob_request_ = storage::BlobProtocolHandler::CreateBlobRequest( |
| 111 blob_data_handle.Pass(), request_context, this); | 111 blob_data_handle.Pass(), request_context, this); |
| 112 blob_request_->Start(); | 112 blob_request_->Start(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // net::URLRequest::Delegate overrides for reading blobs. | 115 // net::URLRequest::Delegate overrides for reading blobs. |
| 116 virtual void OnReceivedRedirect(net::URLRequest* request, | 116 virtual void OnReceivedRedirect(net::URLRequest* request, |
| 117 const net::RedirectInfo& redirect_info, | 117 const net::RedirectInfo& redirect_info, |
| 118 bool* defer_redirect) OVERRIDE { | 118 bool* defer_redirect) override { |
| 119 NOTREACHED(); | 119 NOTREACHED(); |
| 120 } | 120 } |
| 121 virtual void OnAuthRequired(net::URLRequest* request, | 121 virtual void OnAuthRequired(net::URLRequest* request, |
| 122 net::AuthChallengeInfo* auth_info) OVERRIDE { | 122 net::AuthChallengeInfo* auth_info) override { |
| 123 NOTREACHED(); | 123 NOTREACHED(); |
| 124 } | 124 } |
| 125 virtual void OnCertificateRequested( | 125 virtual void OnCertificateRequested( |
| 126 net::URLRequest* request, | 126 net::URLRequest* request, |
| 127 net::SSLCertRequestInfo* cert_request_info) OVERRIDE { | 127 net::SSLCertRequestInfo* cert_request_info) override { |
| 128 NOTREACHED(); | 128 NOTREACHED(); |
| 129 } | 129 } |
| 130 virtual void OnSSLCertificateError(net::URLRequest* request, | 130 virtual void OnSSLCertificateError(net::URLRequest* request, |
| 131 const net::SSLInfo& ssl_info, | 131 const net::SSLInfo& ssl_info, |
| 132 bool fatal) OVERRIDE { | 132 bool fatal) override { |
| 133 NOTREACHED(); | 133 NOTREACHED(); |
| 134 } | 134 } |
| 135 virtual void OnBeforeNetworkStart(net::URLRequest* request, | 135 virtual void OnBeforeNetworkStart(net::URLRequest* request, |
| 136 bool* defer) OVERRIDE { | 136 bool* defer) override { |
| 137 NOTREACHED(); | 137 NOTREACHED(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE { | 140 virtual void OnResponseStarted(net::URLRequest* request) override { |
| 141 if (!request->status().is_success()) { | 141 if (!request->status().is_success()) { |
| 142 callback_.Run(false); | 142 callback_.Run(false); |
| 143 return; | 143 return; |
| 144 } | 144 } |
| 145 ReadFromBlob(); | 145 ReadFromBlob(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 virtual void ReadFromBlob() { | 148 virtual void ReadFromBlob() { |
| 149 int bytes_read = 0; | 149 int bytes_read = 0; |
| 150 bool done = | 150 bool done = |
| 151 blob_request_->Read(buffer_.get(), buffer_->size(), &bytes_read); | 151 blob_request_->Read(buffer_.get(), buffer_->size(), &bytes_read); |
| 152 if (done) | 152 if (done) |
| 153 OnReadCompleted(blob_request_.get(), bytes_read); | 153 OnReadCompleted(blob_request_.get(), bytes_read); |
| 154 } | 154 } |
| 155 | 155 |
| 156 virtual void OnReadCompleted(net::URLRequest* request, | 156 virtual void OnReadCompleted(net::URLRequest* request, |
| 157 int bytes_read) OVERRIDE { | 157 int bytes_read) override { |
| 158 if (!request->status().is_success()) { | 158 if (!request->status().is_success()) { |
| 159 callback_.Run(false); | 159 callback_.Run(false); |
| 160 return; | 160 return; |
| 161 } | 161 } |
| 162 | 162 |
| 163 if (bytes_read == 0) { | 163 if (bytes_read == 0) { |
| 164 callback_.Run(true); | 164 callback_.Run(true); |
| 165 return; | 165 return; |
| 166 } | 166 } |
| 167 | 167 |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 initialized_ = true; | 1096 initialized_ = true; |
| 1097 for (std::vector<base::Closure>::iterator it = init_callbacks_.begin(); | 1097 for (std::vector<base::Closure>::iterator it = init_callbacks_.begin(); |
| 1098 it != init_callbacks_.end(); | 1098 it != init_callbacks_.end(); |
| 1099 ++it) { | 1099 ++it) { |
| 1100 it->Run(); | 1100 it->Run(); |
| 1101 } | 1101 } |
| 1102 init_callbacks_.clear(); | 1102 init_callbacks_.clear(); |
| 1103 } | 1103 } |
| 1104 | 1104 |
| 1105 } // namespace content | 1105 } // namespace content |
| OLD | NEW |