Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: net/url_request/url_request_file_job.cc

Issue 11293: Port directory lister to posix. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request_file_dir_job.cc ('k') | net/url_request/url_request_ftp_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 10 matching lines...) Expand all
21 21
22 #include "base/compiler_specific.h" 22 #include "base/compiler_specific.h"
23 #include "base/message_loop.h" 23 #include "base/message_loop.h"
24 #include "base/string_util.h" 24 #include "base/string_util.h"
25 #include "base/worker_pool.h" 25 #include "base/worker_pool.h"
26 #include "googleurl/src/gurl.h" 26 #include "googleurl/src/gurl.h"
27 #include "net/base/mime_util.h" 27 #include "net/base/mime_util.h"
28 #include "net/base/net_errors.h" 28 #include "net/base/net_errors.h"
29 #include "net/base/net_util.h" 29 #include "net/base/net_util.h"
30 #include "net/url_request/url_request.h" 30 #include "net/url_request/url_request.h"
31 #if defined(OS_WIN)
32 #include "net/url_request/url_request_file_dir_job.h" 31 #include "net/url_request/url_request_file_dir_job.h"
33 #endif
34 32
35 #if defined(OS_WIN) 33 #if defined(OS_WIN)
36 class URLRequestFileJob::AsyncResolver : 34 class URLRequestFileJob::AsyncResolver :
37 public base::RefCountedThreadSafe<URLRequestFileJob::AsyncResolver> { 35 public base::RefCountedThreadSafe<URLRequestFileJob::AsyncResolver> {
38 public: 36 public:
39 explicit AsyncResolver(URLRequestFileJob* owner) 37 explicit AsyncResolver(URLRequestFileJob* owner)
40 : owner_(owner), owner_loop_(MessageLoop::current()) { 38 : owner_(owner), owner_loop_(MessageLoop::current()) {
41 } 39 }
42 40
43 void Resolve(const std::wstring& file_path) { 41 void Resolve(const std::wstring& file_path) {
(...skipping 25 matching lines...) Expand all
69 MessageLoop* owner_loop_; 67 MessageLoop* owner_loop_;
70 }; 68 };
71 #endif 69 #endif
72 70
73 // static 71 // static
74 URLRequestJob* URLRequestFileJob::Factory( 72 URLRequestJob* URLRequestFileJob::Factory(
75 URLRequest* request, const std::string& scheme) { 73 URLRequest* request, const std::string& scheme) {
76 std::wstring file_path; 74 std::wstring file_path;
77 if (net::FileURLToFilePath(request->url(), &file_path)) { 75 if (net::FileURLToFilePath(request->url(), &file_path)) {
78 if (file_path[file_path.size() - 1] == file_util::kPathSeparator) { 76 if (file_path[file_path.size() - 1] == file_util::kPathSeparator) {
79 #if defined(OS_WIN)
80 // Only directories have trailing slashes. 77 // Only directories have trailing slashes.
81 return new URLRequestFileDirJob(request, file_path); 78 return new URLRequestFileDirJob(request, file_path);
82 #endif
83 } 79 }
84 } 80 }
85 81
86 // Use a regular file request job for all non-directories (including invalid 82 // Use a regular file request job for all non-directories (including invalid
87 // file names). 83 // file names).
88 URLRequestFileJob* job = new URLRequestFileJob(request); 84 URLRequestFileJob* job = new URLRequestFileJob(request);
89 job->file_path_ = file_path; 85 job->file_path_ = file_path;
90 return job; 86 return job;
91 } 87 }
92 88
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 return false; 232 return false;
237 233
238 *location = net::FilePathToFileURL(new_path); 234 *location = net::FilePathToFileURL(new_path);
239 *http_status_code = 301; 235 *http_status_code = 301;
240 return true; 236 return true;
241 #else 237 #else
242 return false; 238 return false;
243 #endif 239 #endif
244 } 240 }
245 241
OLDNEW
« no previous file with comments | « net/url_request/url_request_file_dir_job.cc ('k') | net/url_request/url_request_ftp_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698