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

Side by Side Diff: webkit/fileapi/file_system_url_request_job_factory.cc

Issue 14895013: Move webkit/fileapi/file_system_mount_point_provider.h to webkit/browser/fileapi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "webkit/fileapi/file_system_url_request_job_factory.h"
6
7 #include <string>
8
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "net/url_request/url_request.h"
12 #include "webkit/fileapi/file_system_url_request_job.h"
13 #include "webkit/fileapi/file_system_dir_url_request_job.h"
14
15 namespace fileapi {
16
17 namespace {
18
19 class FileSystemProtocolHandler
20 : public net::URLRequestJobFactory::ProtocolHandler {
21 public:
22 explicit FileSystemProtocolHandler(FileSystemContext* context);
23 virtual ~FileSystemProtocolHandler();
24
25 virtual net::URLRequestJob* MaybeCreateJob(
26 net::URLRequest* request,
27 net::NetworkDelegate* network_delegate) const OVERRIDE;
28
29 private:
30 // No scoped_refptr because |file_system_context_| is owned by the
31 // ProfileIOData, which also owns this ProtocolHandler.
32 FileSystemContext* const file_system_context_;
33
34 DISALLOW_COPY_AND_ASSIGN(FileSystemProtocolHandler);
35 };
36
37 FileSystemProtocolHandler::FileSystemProtocolHandler(
38 FileSystemContext* context)
39 : file_system_context_(context) {
40 DCHECK(file_system_context_);
41 }
42
43 FileSystemProtocolHandler::~FileSystemProtocolHandler() {}
44
45 net::URLRequestJob* FileSystemProtocolHandler::MaybeCreateJob(
46 net::URLRequest* request, net::NetworkDelegate* network_delegate) const {
47 const std::string path = request->url().path();
48
49 // If the path ends with a /, we know it's a directory. If the path refers
50 // to a directory and gets dispatched to FileSystemURLRequestJob, that class
51 // redirects back here, by adding a / to the URL.
52 if (!path.empty() && path[path.size() - 1] == '/') {
53 return new FileSystemDirURLRequestJob(
54 request, network_delegate, file_system_context_);
55 }
56 return new FileSystemURLRequestJob(
57 request, network_delegate, file_system_context_);
58 }
59
60 } // anonymous namespace
61
62 net::URLRequestJobFactory::ProtocolHandler*
63 CreateFileSystemProtocolHandler(FileSystemContext* context) {
64 DCHECK(context);
65 return new FileSystemProtocolHandler(context);
66 }
67
68 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698