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

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

Issue 195923002: 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: Fix CrOS 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_url_request_job.h" 5 #include "webkit/browser/fileapi/file_system_url_request_job.h"
6 6
7 #include <vector> 7 #include <vector>
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 std::string cache_control(net::HttpRequestHeaders::kCacheControl); 50 std::string cache_control(net::HttpRequestHeaders::kCacheControl);
51 cache_control.append(": no-cache"); 51 cache_control.append(": no-cache");
52 headers->AddHeader(cache_control); 52 headers->AddHeader(cache_control);
53 53
54 return headers; 54 return headers;
55 } 55 }
56 56
57 FileSystemURLRequestJob::FileSystemURLRequestJob( 57 FileSystemURLRequestJob::FileSystemURLRequestJob(
58 URLRequest* request, 58 URLRequest* request,
59 NetworkDelegate* network_delegate, 59 NetworkDelegate* network_delegate,
60 const std::string& storage_domain,
60 FileSystemContext* file_system_context) 61 FileSystemContext* file_system_context)
61 : URLRequestJob(request, network_delegate), 62 : URLRequestJob(request, network_delegate),
63 storage_domain_(storage_domain),
62 file_system_context_(file_system_context), 64 file_system_context_(file_system_context),
63 is_directory_(false), 65 is_directory_(false),
64 remaining_bytes_(0), 66 remaining_bytes_(0),
65 weak_factory_(this) { 67 weak_factory_(this) {
66 } 68 }
67 69
68 FileSystemURLRequestJob::~FileSystemURLRequestJob() {} 70 FileSystemURLRequestJob::~FileSystemURLRequestJob() {}
69 71
70 void FileSystemURLRequestJob::Start() { 72 void FileSystemURLRequestJob::Start() {
71 base::MessageLoop::current()->PostTask( 73 base::MessageLoop::current()->PostTask(
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 if (response_info_) 152 if (response_info_)
151 return 200; 153 return 200;
152 return URLRequestJob::GetResponseCode(); 154 return URLRequestJob::GetResponseCode();
153 } 155 }
154 156
155 void FileSystemURLRequestJob::StartAsync() { 157 void FileSystemURLRequestJob::StartAsync() {
156 if (!request_) 158 if (!request_)
157 return; 159 return;
158 DCHECK(!reader_.get()); 160 DCHECK(!reader_.get());
159 url_ = file_system_context_->CrackURL(request_->url()); 161 url_ = file_system_context_->CrackURL(request_->url());
162 if (!url_.is_valid()) {
163 file_system_context_->AttemptAutoMountForURLRequest(
164 request_,
165 storage_domain_,
166 base::Bind(&FileSystemURLRequestJob::DidAttemptAutoMount,
167 weak_factory_.GetWeakPtr()));
168 return;
169 }
160 if (!file_system_context_->CanServeURLRequest(url_)) { 170 if (!file_system_context_->CanServeURLRequest(url_)) {
161 // In incognito mode the API is not usable and there should be no data. 171 // In incognito mode the API is not usable and there should be no data.
162 NotifyFailed(net::ERR_FILE_NOT_FOUND); 172 NotifyFailed(net::ERR_FILE_NOT_FOUND);
163 return; 173 return;
164 } 174 }
165 file_system_context_->operation_runner()->GetMetadata( 175 file_system_context_->operation_runner()->GetMetadata(
166 url_, 176 url_,
167 base::Bind(&FileSystemURLRequestJob::DidGetMetadata, 177 base::Bind(&FileSystemURLRequestJob::DidGetMetadata,
168 weak_factory_.GetWeakPtr())); 178 weak_factory_.GetWeakPtr()));
169 } 179 }
170 180
181 void FileSystemURLRequestJob::DidAttemptAutoMount(base::File::Error result) {
182 if (result >= 0 &&
183 file_system_context_->CrackURL(request_->url()).is_valid()) {
184 StartAsync();
185 } else {
186 NotifyFailed(net::ERR_FILE_NOT_FOUND);
187 }
188 }
189
171 void FileSystemURLRequestJob::DidGetMetadata( 190 void FileSystemURLRequestJob::DidGetMetadata(
172 base::File::Error error_code, 191 base::File::Error error_code,
173 const base::File::Info& file_info) { 192 const base::File::Info& file_info) {
174 if (error_code != base::File::FILE_OK) { 193 if (error_code != base::File::FILE_OK) {
175 NotifyFailed(error_code == base::File::FILE_ERROR_INVALID_URL ? 194 NotifyFailed(error_code == base::File::FILE_ERROR_INVALID_URL ?
176 net::ERR_INVALID_URL : net::ERR_FILE_NOT_FOUND); 195 net::ERR_INVALID_URL : net::ERR_FILE_NOT_FOUND);
177 return; 196 return;
178 } 197 }
179 198
180 // We may have been orphaned... 199 // We may have been orphaned...
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 255 }
237 256
238 return false; 257 return false;
239 } 258 }
240 259
241 void FileSystemURLRequestJob::NotifyFailed(int rv) { 260 void FileSystemURLRequestJob::NotifyFailed(int rv) {
242 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); 261 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
243 } 262 }
244 263
245 } // namespace fileapi 264 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/file_system_url_request_job.h ('k') | webkit/browser/fileapi/file_system_url_request_job_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698