Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / storage / browser / fileapi / file_system_url_request_job.h
blob00212102757922f95a02b5571babd1cda1070625
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.
5 #ifndef STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_H_
6 #define STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_H_
8 #include <string>
10 #include "base/files/file.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "net/http/http_byte_range.h"
15 #include "net/url_request/url_request_job.h"
16 #include "storage/browser/fileapi/file_system_url.h"
17 #include "storage/browser/storage_browser_export.h"
19 class GURL;
21 namespace base {
22 class FilePath;
25 namespace storage {
26 class FileStreamReader;
29 namespace storage {
30 class FileSystemContext;
32 // A request job that handles reading filesystem: URLs
33 class STORAGE_EXPORT_PRIVATE FileSystemURLRequestJob
34 : public net::URLRequestJob {
35 public:
36 FileSystemURLRequestJob(
37 net::URLRequest* request,
38 net::NetworkDelegate* network_delegate,
39 const std::string& storage_domain,
40 FileSystemContext* file_system_context);
42 // URLRequestJob methods:
43 void Start() override;
44 void Kill() override;
45 bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override;
46 bool IsRedirectResponse(GURL* location, int* http_status_code) override;
47 void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override;
48 void GetResponseInfo(net::HttpResponseInfo* info) override;
49 int GetResponseCode() const override;
51 // FilterContext methods (via URLRequestJob):
52 bool GetMimeType(std::string* mime_type) const override;
54 private:
55 class CallbackDispatcher;
57 ~FileSystemURLRequestJob() override;
59 void StartAsync();
60 void DidAttemptAutoMount(base::File::Error result);
61 void DidGetMetadata(base::File::Error error_code,
62 const base::File::Info& file_info);
63 void DidRead(int result);
64 void NotifyFailed(int rv);
66 const std::string storage_domain_;
67 FileSystemContext* file_system_context_;
68 scoped_ptr<storage::FileStreamReader> reader_;
69 FileSystemURL url_;
70 bool is_directory_;
71 scoped_ptr<net::HttpResponseInfo> response_info_;
72 int64 remaining_bytes_;
73 net::HttpByteRange byte_range_;
74 base::WeakPtrFactory<FileSystemURLRequestJob> weak_factory_;
76 DISALLOW_COPY_AND_ASSIGN(FileSystemURLRequestJob);
79 } // namespace storage
81 #endif // STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_H_