OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 void Cancel() { | 55 void Cancel() { |
56 owner_ = NULL; | 56 owner_ = NULL; |
57 | 57 |
58 AutoLock locked(lock_); | 58 AutoLock locked(lock_); |
59 owner_loop_ = NULL; | 59 owner_loop_ = NULL; |
60 } | 60 } |
61 | 61 |
62 private: | 62 private: |
| 63 friend class base::RefCountedThreadSafe<URLRequestFileJob::AsyncResolver>; |
| 64 |
| 65 ~AsyncResolver() {} |
| 66 |
63 void ReturnResults(bool exists, const file_util::FileInfo& file_info) { | 67 void ReturnResults(bool exists, const file_util::FileInfo& file_info) { |
64 if (owner_) | 68 if (owner_) |
65 owner_->DidResolve(exists, file_info); | 69 owner_->DidResolve(exists, file_info); |
66 } | 70 } |
67 | 71 |
68 URLRequestFileJob* owner_; | 72 URLRequestFileJob* owner_; |
69 | 73 |
70 Lock lock_; | 74 Lock lock_; |
71 MessageLoop* owner_loop_; | 75 MessageLoop* owner_loop_; |
72 }; | 76 }; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 if (!resolved) | 292 if (!resolved) |
289 return false; | 293 return false; |
290 | 294 |
291 *location = net::FilePathToFileURL(new_path); | 295 *location = net::FilePathToFileURL(new_path); |
292 *http_status_code = 301; | 296 *http_status_code = 301; |
293 return true; | 297 return true; |
294 #else | 298 #else |
295 return false; | 299 return false; |
296 #endif | 300 #endif |
297 } | 301 } |
OLD | NEW |