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 #include "storage/browser/fileapi/file_system_url_request_job_factory.h" | 5 #include "storage/browser/fileapi/file_system_url_request_job_factory.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "net/url_request/url_request.h" | 9 #include "net/url_request/url_request.h" |
10 #include "storage/browser/fileapi/file_system_dir_url_request_job.h" | 10 #include "storage/browser/fileapi/file_system_dir_url_request_job.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 FileSystemProtocolHandler::~FileSystemProtocolHandler() {} | 46 FileSystemProtocolHandler::~FileSystemProtocolHandler() {} |
47 | 47 |
48 net::URLRequestJob* FileSystemProtocolHandler::MaybeCreateJob( | 48 net::URLRequestJob* FileSystemProtocolHandler::MaybeCreateJob( |
49 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { | 49 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { |
50 const std::string path = request->url().path(); | 50 const std::string path = request->url().path(); |
51 | 51 |
52 // If the path ends with a /, we know it's a directory. If the path refers | 52 // If the path ends with a /, we know it's a directory. If the path refers |
53 // to a directory and gets dispatched to FileSystemURLRequestJob, that class | 53 // to a directory and gets dispatched to FileSystemURLRequestJob, that class |
54 // redirects back here, by adding a / to the URL. | 54 // redirects back here, by adding a / to the URL. |
55 if (!path.empty() && path[path.size() - 1] == '/') { | 55 if (!path.empty() && path.back() == '/') { |
56 return new FileSystemDirURLRequestJob( | 56 return new FileSystemDirURLRequestJob( |
57 request, network_delegate, storage_domain_, file_system_context_); | 57 request, network_delegate, storage_domain_, file_system_context_); |
58 } | 58 } |
59 return new FileSystemURLRequestJob( | 59 return new FileSystemURLRequestJob( |
60 request, network_delegate, storage_domain_, file_system_context_); | 60 request, network_delegate, storage_domain_, file_system_context_); |
61 } | 61 } |
62 | 62 |
63 } // anonymous namespace | 63 } // anonymous namespace |
64 | 64 |
65 net::URLRequestJobFactory::ProtocolHandler* CreateFileSystemProtocolHandler( | 65 net::URLRequestJobFactory::ProtocolHandler* CreateFileSystemProtocolHandler( |
66 const std::string& storage_domain, FileSystemContext* context) { | 66 const std::string& storage_domain, FileSystemContext* context) { |
67 DCHECK(context); | 67 DCHECK(context); |
68 return new FileSystemProtocolHandler(storage_domain, context); | 68 return new FileSystemProtocolHandler(storage_domain, context); |
69 } | 69 } |
70 | 70 |
71 } // namespace storage | 71 } // namespace storage |
OLD | NEW |