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

Unified Diff: net/url_request/url_request_file_job.cc

Issue 10700117: Replaced static URLRequestFileJob factory with non-static protocol handler for File jobs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed context from file_dir_job, merged with error_job cl Created 8 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: net/url_request/url_request_file_job.cc
diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc
index 5f5ea7ca48fc4bbdd947c916b7dd84043f7c9e6a..7fe968a7440598098c38ebd942de010c305e0cb2 100644
--- a/net/url_request/url_request_file_job.cc
+++ b/net/url_request/url_request_file_job.cc
@@ -84,8 +84,9 @@ class URLRequestFileJob::AsyncResolver
};
URLRequestFileJob::URLRequestFileJob(URLRequest* request,
- const FilePath& file_path)
- : URLRequestJob(request, request->context()->network_delegate()),
+ const FilePath& file_path,
+ NetworkDelegate* network_delegate)
+ : URLRequestJob(request, network_delegate),
file_path_(file_path),
stream_(NULL),
is_directory_(false),
@@ -99,7 +100,8 @@ URLRequestJob* URLRequestFileJob::Factory(URLRequest* request,
const bool is_file = FileURLToFilePath(request->url(), &file_path);
// Check file access permissions.
- if (!IsFileAccessAllowed(*request, file_path)) {
+ if (!IsFileAccessAllowed(
+ *request, file_path, request->context()->network_delegate())) {
return new URLRequestErrorJob(
request, request->context()->network_delegate(), ERR_ACCESS_DENIED);
}
@@ -113,11 +115,14 @@ URLRequestJob* URLRequestFileJob::Factory(URLRequest* request,
if (is_file &&
file_util::EndsWithSeparator(file_path) &&
file_path.IsAbsolute())
- return new URLRequestFileDirJob(request, file_path);
+ return new URLRequestFileDirJob(request,
+ request->context()->network_delegate(),
+ file_path);
// Use a regular file request job for all non-directories (including invalid
// file names).
- return new URLRequestFileJob(request, file_path);
+ return new URLRequestFileJob(
+ request, file_path, request->context()->network_delegate());
}
void URLRequestFileJob::Start() {
@@ -254,11 +259,8 @@ void URLRequestFileJob::SetExtraRequestHeaders(
// static
bool URLRequestFileJob::IsFileAccessAllowed(const URLRequest& request,
- const FilePath& path) {
- const URLRequestContext* context = request.context();
- if (!context)
- return false;
- const NetworkDelegate* delegate = context->network_delegate();
+ const FilePath& path,
+ NetworkDelegate* delegate) {
if (delegate)
return delegate->CanAccessFile(request, path);
erikwright (departed) 2012/07/13 14:50:36 I would just inline this at this point. Replace ca
shalev 2012/07/17 19:40:16 Done.
return false;
« chrome/browser/profiles/profile_impl_io_data.cc ('K') | « net/url_request/url_request_file_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698