blob: 0ccaa5a7372383b5ca6ad8112927f16ffa34137f [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]498c1a6b22008-11-24 23:37:048#include "base/file_path.h"
[email protected]9396b252008-09-29 17:29:389#include "base/file_util.h"
10#include "net/base/completion_callback.h"
[email protected]21da6eb2008-11-03 17:18:1411#include "net/base/file_stream.h"
initial.commit586acc5fe2008-07-26 22:42:5212#include "net/url_request/url_request.h"
13#include "net/url_request/url_request_job.h"
initial.commit586acc5fe2008-07-26 22:42:5214
15// A request job that handles reading file URLs
[email protected]9396b252008-09-29 17:29:3816class URLRequestFileJob : public URLRequestJob {
initial.commit586acc5fe2008-07-26 22:42:5217 public:
[email protected]82891262008-12-24 00:21:2618 URLRequestFileJob(URLRequest* request, const FilePath& file_path);
initial.commit586acc5fe2008-07-26 22:42:5219 virtual ~URLRequestFileJob();
20
21 virtual void Start();
22 virtual void Kill();
[email protected]9dea9e1f2009-01-29 00:30:4723 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read);
initial.commit586acc5fe2008-07-26 22:42:5224 virtual bool IsRedirectResponse(GURL* location, int* http_status_code);
initial.commit586acc5fe2008-07-26 22:42:5225 virtual bool GetMimeType(std::string* mime_type);
26
initial.commit586acc5fe2008-07-26 22:42:5227 static URLRequest::ProtocolFactory Factory;
28
29 protected:
30 // The OS-specific full path name of the file
[email protected]498c1a6b22008-11-24 23:37:0431 FilePath file_path_;
initial.commit586acc5fe2008-07-26 22:42:5232
33 private:
[email protected]9396b252008-09-29 17:29:3834 void DidResolve(bool exists, const file_util::FileInfo& file_info);
35 void DidRead(int result);
[email protected]243f86a72008-08-09 08:35:2536
[email protected]9396b252008-09-29 17:29:3837 net::CompletionCallbackImpl<URLRequestFileJob> io_callback_;
[email protected]21da6eb2008-11-03 17:18:1438 net::FileStream stream_;
[email protected]9396b252008-09-29 17:29:3839 bool is_directory_;
initial.commit586acc5fe2008-07-26 22:42:5240
[email protected]9396b252008-09-29 17:29:3841#if defined(OS_WIN)
42 class AsyncResolver;
43 friend class AsyncResolver;
44 scoped_refptr<AsyncResolver> async_resolver_;
45#endif
initial.commit586acc5fe2008-07-26 22:42:5246
[email protected]9396b252008-09-29 17:29:3847 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob);
initial.commit586acc5fe2008-07-26 22:42:5248};
49
[email protected]43530b32008-08-04 22:21:3450#endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_