blob: 5d52850561088cbd5136180e766d6535736f5499 [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// Copyright (c) 2006-2008 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.
initial.commit586acc5fe2008-07-26 22:42:524
[email protected]43530b32008-08-04 22:21:345#ifndef NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_
6#define NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_
initial.commit586acc5fe2008-07-26 22:42:527
[email protected]9396b252008-09-29 17:29:388#include "base/file_util.h"
9#include "net/base/completion_callback.h"
[email protected]21da6eb2008-11-03 17:18:1410#include "net/base/file_stream.h"
initial.commit586acc5fe2008-07-26 22:42:5211#include "net/url_request/url_request.h"
12#include "net/url_request/url_request_job.h"
initial.commit586acc5fe2008-07-26 22:42:5213
14// A request job that handles reading file URLs
[email protected]9396b252008-09-29 17:29:3815class URLRequestFileJob : public URLRequestJob {
initial.commit586acc5fe2008-07-26 22:42:5216 public:
17 URLRequestFileJob(URLRequest* request);
18 virtual ~URLRequestFileJob();
19
20 virtual void Start();
21 virtual void Kill();
22 virtual bool ReadRawData(char* buf, int buf_size, int *bytes_read);
23 virtual bool IsRedirectResponse(GURL* location, int* http_status_code);
initial.commit586acc5fe2008-07-26 22:42:5224 virtual bool GetMimeType(std::string* mime_type);
25
initial.commit586acc5fe2008-07-26 22:42:5226 static URLRequest::ProtocolFactory Factory;
27
28 protected:
29 // The OS-specific full path name of the file
30 std::wstring file_path_;
31
32 private:
[email protected]9396b252008-09-29 17:29:3833 void DidResolve(bool exists, const file_util::FileInfo& file_info);
34 void DidRead(int result);
[email protected]243f86a72008-08-09 08:35:2535
[email protected]9396b252008-09-29 17:29:3836 net::CompletionCallbackImpl<URLRequestFileJob> io_callback_;
[email protected]21da6eb2008-11-03 17:18:1437 net::FileStream stream_;
[email protected]9396b252008-09-29 17:29:3838 bool is_directory_;
initial.commit586acc5fe2008-07-26 22:42:5239
[email protected]9396b252008-09-29 17:29:3840#if defined(OS_WIN)
41 class AsyncResolver;
42 friend class AsyncResolver;
43 scoped_refptr<AsyncResolver> async_resolver_;
44#endif
initial.commit586acc5fe2008-07-26 22:42:5245
[email protected]9396b252008-09-29 17:29:3846 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob);
initial.commit586acc5fe2008-07-26 22:42:5247};
48
[email protected]43530b32008-08-04 22:21:3449#endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_