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

Side by Side Diff: webkit/browser/fileapi/file_system_dir_url_request_job.cc

Issue 206253002: Revert of Add mechanism to auto mount file systems in response to a URL request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
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 "webkit/browser/fileapi/file_system_dir_url_request_job.h" 5 #include "webkit/browser/fileapi/file_system_dir_url_request_job.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 17 matching lines...) Expand all
28 using net::NetworkDelegate; 28 using net::NetworkDelegate;
29 using net::URLRequest; 29 using net::URLRequest;
30 using net::URLRequestJob; 30 using net::URLRequestJob;
31 using net::URLRequestStatus; 31 using net::URLRequestStatus;
32 32
33 namespace fileapi { 33 namespace fileapi {
34 34
35 FileSystemDirURLRequestJob::FileSystemDirURLRequestJob( 35 FileSystemDirURLRequestJob::FileSystemDirURLRequestJob(
36 URLRequest* request, 36 URLRequest* request,
37 NetworkDelegate* network_delegate, 37 NetworkDelegate* network_delegate,
38 const std::string& storage_domain,
39 FileSystemContext* file_system_context) 38 FileSystemContext* file_system_context)
40 : URLRequestJob(request, network_delegate), 39 : URLRequestJob(request, network_delegate),
41 storage_domain_(storage_domain),
42 file_system_context_(file_system_context), 40 file_system_context_(file_system_context),
43 weak_factory_(this) { 41 weak_factory_(this) {
44 } 42 }
45 43
46 FileSystemDirURLRequestJob::~FileSystemDirURLRequestJob() { 44 FileSystemDirURLRequestJob::~FileSystemDirURLRequestJob() {
47 } 45 }
48 46
49 bool FileSystemDirURLRequestJob::ReadRawData(net::IOBuffer* dest, int dest_size, 47 bool FileSystemDirURLRequestJob::ReadRawData(net::IOBuffer* dest, int dest_size,
50 int *bytes_read) { 48 int *bytes_read) {
51 int count = std::min(dest_size, static_cast<int>(data_.size())); 49 int count = std::min(dest_size, static_cast<int>(data_.size()));
(...skipping 24 matching lines...) Expand all
76 74
77 bool FileSystemDirURLRequestJob::GetCharset(std::string* charset) { 75 bool FileSystemDirURLRequestJob::GetCharset(std::string* charset) {
78 *charset = "utf-8"; 76 *charset = "utf-8";
79 return true; 77 return true;
80 } 78 }
81 79
82 void FileSystemDirURLRequestJob::StartAsync() { 80 void FileSystemDirURLRequestJob::StartAsync() {
83 if (!request_) 81 if (!request_)
84 return; 82 return;
85 url_ = file_system_context_->CrackURL(request_->url()); 83 url_ = file_system_context_->CrackURL(request_->url());
86 if (!url_.is_valid()) {
87 file_system_context_->AttemptAutoMountForURLRequest(
88 request_,
89 storage_domain_,
90 base::Bind(&FileSystemDirURLRequestJob::DidAttemptAutoMount,
91 weak_factory_.GetWeakPtr()));
92 return;
93 }
94 if (!file_system_context_->CanServeURLRequest(url_)) { 84 if (!file_system_context_->CanServeURLRequest(url_)) {
95 // In incognito mode the API is not usable and there should be no data. 85 // In incognito mode the API is not usable and there should be no data.
96 if (url_.is_valid() && VirtualPath::IsRootPath(url_.virtual_path())) { 86 if (url_.is_valid() && VirtualPath::IsRootPath(url_.virtual_path())) {
97 // Return an empty directory if the filesystem root is queried. 87 // Return an empty directory if the filesystem root is queried.
98 DidReadDirectory(base::File::FILE_OK, 88 DidReadDirectory(base::File::FILE_OK,
99 std::vector<DirectoryEntry>(), 89 std::vector<DirectoryEntry>(),
100 false); 90 false);
101 return; 91 return;
102 } 92 }
103 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, 93 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED,
104 net::ERR_FILE_NOT_FOUND)); 94 net::ERR_FILE_NOT_FOUND));
105 return; 95 return;
106 } 96 }
107 file_system_context_->operation_runner()->ReadDirectory( 97 file_system_context_->operation_runner()->ReadDirectory(
108 url_, 98 url_,
109 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); 99 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this));
110 } 100 }
111 101
112 void FileSystemDirURLRequestJob::DidAttemptAutoMount(base::File::Error result) {
113 if (result >= 0 &&
114 file_system_context_->CrackURL(request_->url()).is_valid()) {
115 StartAsync();
116 } else {
117 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED,
118 net::ERR_FILE_NOT_FOUND));
119 }
120 }
121
122 void FileSystemDirURLRequestJob::DidReadDirectory( 102 void FileSystemDirURLRequestJob::DidReadDirectory(
123 base::File::Error result, 103 base::File::Error result,
124 const std::vector<DirectoryEntry>& entries, 104 const std::vector<DirectoryEntry>& entries,
125 bool has_more) { 105 bool has_more) {
126 if (result != base::File::FILE_OK) { 106 if (result != base::File::FILE_OK) {
127 int rv = net::ERR_FILE_NOT_FOUND; 107 int rv = net::ERR_FILE_NOT_FOUND;
128 if (result == base::File::FILE_ERROR_INVALID_URL) 108 if (result == base::File::FILE_ERROR_INVALID_URL)
129 rv = net::ERR_INVALID_URL; 109 rv = net::ERR_INVALID_URL;
130 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); 110 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
131 return; 111 return;
(...skipping 20 matching lines...) Expand all
152 it->last_modified_time)); 132 it->last_modified_time));
153 } 133 }
154 134
155 if (!has_more) { 135 if (!has_more) {
156 set_expected_content_size(data_.size()); 136 set_expected_content_size(data_.size());
157 NotifyHeadersComplete(); 137 NotifyHeadersComplete();
158 } 138 }
159 } 139 }
160 140
161 } // namespace fileapi 141 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/file_system_dir_url_request_job.h ('k') | webkit/browser/fileapi/file_system_url_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698