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_
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"
26 class FileStreamReader
;
30 class FileSystemContext
;
32 // A request job that handles reading filesystem: URLs
33 class STORAGE_EXPORT_PRIVATE FileSystemURLRequestJob
34 : public net::URLRequestJob
{
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 virtual void Start() OVERRIDE
;
44 virtual void Kill() OVERRIDE
;
45 virtual bool ReadRawData(net::IOBuffer
* buf
,
47 int* bytes_read
) OVERRIDE
;
48 virtual bool IsRedirectResponse(GURL
* location
,
49 int* http_status_code
) OVERRIDE
;
50 virtual void SetExtraRequestHeaders(
51 const net::HttpRequestHeaders
& headers
) OVERRIDE
;
52 virtual void GetResponseInfo(net::HttpResponseInfo
* info
) OVERRIDE
;
53 virtual int GetResponseCode() const OVERRIDE
;
55 // FilterContext methods (via URLRequestJob):
56 virtual bool GetMimeType(std::string
* mime_type
) const OVERRIDE
;
59 class CallbackDispatcher
;
61 virtual ~FileSystemURLRequestJob();
64 void DidAttemptAutoMount(base::File::Error result
);
65 void DidGetMetadata(base::File::Error error_code
,
66 const base::File::Info
& file_info
);
67 void DidRead(int result
);
68 void NotifyFailed(int rv
);
70 const std::string storage_domain_
;
71 FileSystemContext
* file_system_context_
;
72 scoped_ptr
<storage::FileStreamReader
> reader_
;
75 scoped_ptr
<net::HttpResponseInfo
> response_info_
;
76 int64 remaining_bytes_
;
77 net::HttpByteRange byte_range_
;
78 base::WeakPtrFactory
<FileSystemURLRequestJob
> weak_factory_
;
80 DISALLOW_COPY_AND_ASSIGN(FileSystemURLRequestJob
);
83 } // namespace storage
85 #endif // STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_H_