| 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 20 matching lines...) Expand all Loading... |
| 31 #include "googleurl/src/gurl.h" | 31 #include "googleurl/src/gurl.h" |
| 32 #include "net/base/io_buffer.h" | 32 #include "net/base/io_buffer.h" |
| 33 #include "net/base/load_flags.h" | 33 #include "net/base/load_flags.h" |
| 34 #include "net/base/mime_util.h" | 34 #include "net/base/mime_util.h" |
| 35 #include "net/base/net_errors.h" | 35 #include "net/base/net_errors.h" |
| 36 #include "net/base/net_util.h" | 36 #include "net/base/net_util.h" |
| 37 #include "net/http/http_util.h" | 37 #include "net/http/http_util.h" |
| 38 #include "net/url_request/url_request_error_job.h" | 38 #include "net/url_request/url_request_error_job.h" |
| 39 #include "net/url_request/url_request_file_dir_job.h" | 39 #include "net/url_request/url_request_file_dir_job.h" |
| 40 | 40 |
| 41 #if defined(OS_WIN) |
| 42 #include "base/win/shortcut.h" |
| 43 #endif |
| 44 |
| 41 namespace net { | 45 namespace net { |
| 42 | 46 |
| 43 class URLRequestFileJob::AsyncResolver | 47 class URLRequestFileJob::AsyncResolver |
| 44 : public base::RefCountedThreadSafe<URLRequestFileJob::AsyncResolver> { | 48 : public base::RefCountedThreadSafe<URLRequestFileJob::AsyncResolver> { |
| 45 public: | 49 public: |
| 46 explicit AsyncResolver(URLRequestFileJob* owner) | 50 explicit AsyncResolver(URLRequestFileJob* owner) |
| 47 : owner_(owner), owner_loop_(MessageLoop::current()) { | 51 : owner_(owner), owner_loop_(MessageLoop::current()) { |
| 48 } | 52 } |
| 49 | 53 |
| 50 void Resolve(const FilePath& file_path) { | 54 void Resolve(const FilePath& file_path) { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 } | 198 } |
| 195 | 199 |
| 196 #if defined(OS_WIN) | 200 #if defined(OS_WIN) |
| 197 // Follow a Windows shortcut. | 201 // Follow a Windows shortcut. |
| 198 // We just resolve .lnk file, ignore others. | 202 // We just resolve .lnk file, ignore others. |
| 199 if (!LowerCaseEqualsASCII(file_path_.Extension(), ".lnk")) | 203 if (!LowerCaseEqualsASCII(file_path_.Extension(), ".lnk")) |
| 200 return false; | 204 return false; |
| 201 | 205 |
| 202 FilePath new_path = file_path_; | 206 FilePath new_path = file_path_; |
| 203 bool resolved; | 207 bool resolved; |
| 204 resolved = file_util::ResolveShortcut(new_path, &new_path, NULL); | 208 resolved = base::win::ResolveShortcut(new_path, &new_path, NULL); |
| 205 | 209 |
| 206 // If shortcut is not resolved succesfully, do not redirect. | 210 // If shortcut is not resolved succesfully, do not redirect. |
| 207 if (!resolved) | 211 if (!resolved) |
| 208 return false; | 212 return false; |
| 209 | 213 |
| 210 *location = FilePathToFileURL(new_path); | 214 *location = FilePathToFileURL(new_path); |
| 211 *http_status_code = 301; | 215 *http_status_code = 301; |
| 212 return true; | 216 return true; |
| 213 #else | 217 #else |
| 214 return false; | 218 return false; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); | 334 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); |
| 331 } | 335 } |
| 332 | 336 |
| 333 remaining_bytes_ -= result; | 337 remaining_bytes_ -= result; |
| 334 DCHECK_GE(remaining_bytes_, 0); | 338 DCHECK_GE(remaining_bytes_, 0); |
| 335 | 339 |
| 336 NotifyReadComplete(result); | 340 NotifyReadComplete(result); |
| 337 } | 341 } |
| 338 | 342 |
| 339 } // namespace net | 343 } // namespace net |
| OLD | NEW |