Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / storage / browser / fileapi / file_system_dir_url_request_job.h
blob8715c96b0c74eaea2d32cc6254d11ad8679faaed
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_DIR_URL_REQUEST_JOB_H_
6 #define STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_DIR_URL_REQUEST_JOB_H_
8 #include <string>
9 #include <vector>
11 #include "base/files/file.h"
12 #include "base/files/file_path.h"
13 #include "base/memory/weak_ptr.h"
14 #include "net/url_request/url_request_job.h"
15 #include "storage/browser/fileapi/file_system_url.h"
16 #include "storage/browser/storage_browser_export.h"
18 namespace storage {
20 class FileSystemContext;
21 struct DirectoryEntry;
23 // A request job that handles reading filesystem: URLs for directories.
24 class STORAGE_EXPORT_PRIVATE FileSystemDirURLRequestJob
25 : public net::URLRequestJob {
26 public:
27 FileSystemDirURLRequestJob(
28 net::URLRequest* request,
29 net::NetworkDelegate* network_delegate,
30 const std::string& storage_domain,
31 FileSystemContext* file_system_context);
33 // URLRequestJob methods:
34 void Start() override;
35 void Kill() override;
36 bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override;
37 bool GetCharset(std::string* charset) override;
39 // FilterContext methods (via URLRequestJob):
40 bool GetMimeType(std::string* mime_type) const override;
41 // TODO(adamk): Implement GetResponseInfo and GetResponseCode to simulate
42 // an HTTP response.
44 private:
45 class CallbackDispatcher;
47 ~FileSystemDirURLRequestJob() override;
49 void StartAsync();
50 void DidAttemptAutoMount(base::File::Error result);
51 void DidReadDirectory(base::File::Error result,
52 const std::vector<DirectoryEntry>& entries,
53 bool has_more);
55 std::string data_;
56 FileSystemURL url_;
57 const std::string storage_domain_;
58 FileSystemContext* file_system_context_;
59 base::WeakPtrFactory<FileSystemDirURLRequestJob> weak_factory_;
61 DISALLOW_COPY_AND_ASSIGN(FileSystemDirURLRequestJob);
64 } // namespace storage
66 #endif // STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_DIR_URL_REQUEST_JOB_H_