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 // For loading files, we make use of overlapped i/o to ensure that reading from | 5 // For loading files, we make use of overlapped i/o to ensure that reading from |
6 // the filesystem (e.g., a network filesystem) does not block the calling | 6 // the filesystem (e.g., a network filesystem) does not block the calling |
7 // thread. An alternative approach would be to use a background thread or pool | 7 // thread. An alternative approach would be to use a background thread or pool |
8 // of threads, but it seems better to leverage the operating system's ability | 8 // of threads, but it seems better to leverage the operating system's ability |
9 // to do background file reads for us. | 9 // to do background file reads for us. |
10 // | 10 // |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, | 246 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, |
247 ERR_REQUEST_RANGE_NOT_SATISFIABLE)); | 247 ERR_REQUEST_RANGE_NOT_SATISFIABLE)); |
248 } | 248 } |
249 } | 249 } |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 // static | 253 // static |
254 bool URLRequestFileJob::IsFileAccessAllowed(const URLRequest& request, | 254 bool URLRequestFileJob::IsFileAccessAllowed(const URLRequest& request, |
255 const FilePath& path) { | 255 const FilePath& path) { |
256 const URLRequestContext* context = request.context(); | 256 const NetworkDelegate* delegate = request.context()->network_delegate(); |
257 if (!context) | |
258 return false; | |
259 const NetworkDelegate* delegate = context->network_delegate(); | |
260 if (delegate) | 257 if (delegate) |
261 return delegate->CanAccessFile(request, path); | 258 return delegate->CanAccessFile(request, path); |
262 return false; | 259 return false; |
263 } | 260 } |
264 | 261 |
265 URLRequestFileJob::~URLRequestFileJob() { | 262 URLRequestFileJob::~URLRequestFileJob() { |
266 DCHECK(!async_resolver_); | 263 DCHECK(!async_resolver_); |
267 } | 264 } |
268 | 265 |
269 void URLRequestFileJob::DidResolve( | 266 void URLRequestFileJob::DidResolve( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); | 338 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); |
342 } | 339 } |
343 | 340 |
344 remaining_bytes_ -= result; | 341 remaining_bytes_ -= result; |
345 DCHECK_GE(remaining_bytes_, 0); | 342 DCHECK_GE(remaining_bytes_, 0); |
346 | 343 |
347 NotifyReadComplete(result); | 344 NotifyReadComplete(result); |
348 } | 345 } |
349 | 346 |
350 } // namespace net | 347 } // namespace net |
OLD | NEW |